Pc@s dZddlZddlZddlZddlZddlZddlZddlTddlm Z ddl m Z ddl m Z ddlmZddlmZmZdd lmZd Zd efd YZd efdYZdefdYZdS(s" Abstraction for an SSH2 channel. iN(t*(tutil(tMessage(t SSHException(t BufferedFile(t BufferedPipet PipeTimeout(tpipeitChannelcBs-eZdZdZdZdZddddZdZd Zd Z ddd Z d Z d Z dZ dd>d>ed>dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd Z d!Z!d"Z"d#Z#d$Z$d%Z%d&Z&d'Z'd(Z(d)Z)d*Z*d+Z+d,Z,d-Z-d.Z.d/Z/d0Z0d1Z1d2Z2d3Z3d4Z4d5Z5d6Z6d7Z7d8Z8d9Z9d:Z:d;Z;d<Z<d=Z=RS(?s A secure tunnel across an SSH L{Transport}. A Channel is meant to behave like a socket, and has an API that should be indistinguishable from the python socket API. Because SSH2 has a windowing kind of flow control, if you stop reading data from a Channel and its buffer fills up, the server will be unable to send you any more data until you read some of it. (This won't affect other channels on the same transport -- all channels on a single transport are flow-controlled independently.) Similarly, if the server isn't reading data you send, calls to L{send} may block, unless you set a timeout. This is exactly like a normal network socket, so it shouldn't be too surprising. cCs3||_d|_d|_t|_d|_d|_t|_ t|_ d|_ t|_ t|_ tj|_tj|j|_d|_d|_d|_d|_d|_d|_tj|_t||_tjd|_d|_ tj|_!t|_"t|_#d|_$d|_%dS(s Create a new channel. The channel is not associated with any particular session or L{Transport} until the Transport attaches it. Normally you would only call this method from the constructor of a subclass of L{Channel}. @param chanid: the ID of this channel, as passed by an existing L{Transport}. @type chanid: int isparamiko.transportiN(&tchanidt remote_chanidtNonet transporttFalsetactivet eof_receivedteof_sentRt in_buffertin_stderr_bufferttimeouttclosedt ultra_debugt threadingtLocktlockt Conditiont out_buffer_cvtin_window_sizetout_window_sizetin_max_packet_sizetout_max_packet_sizetin_window_thresholdtin_window_sofartEventt status_eventtstrt_nameRt get_loggertloggert_pipeteventt event_readytcombine_stderrt exit_statust origin_addr(tselfR ((s+..\python\site-packages\paramiko\channel.pyt__init__:s8                     cCsy|jWnnXdS(N(tclose(R-((s+..\python\site-packages\paramiko\channel.pyt__del__bscCsd|j}|jr#|d7}n{|jr|jrB|d7}n|jrX|d7}n|d|j7}t|jdkr|dt|jf7}qn|dt|j 7}|d 7}|S( sd Return a string representation of this object, for debugging. @rtype: str s t>( R RRRRRtlenRtreprR (R-tout((s+..\python\site-packages\paramiko\channel.pyt__repr__hs          tvt100iPicCs|js%|js%|js%|j r4tdnt}|jtt|j |j |j d|j t |j ||j ||j ||j dj d|j d|j|jj||jdS(s Request a pseudo-terminal from the server. This is usually used right after creating a client channel, to ask the server to provide some basic terminal semantics for a shell invoked with L{invoke_shell}. It isn't necessary (or desirable) to call this method if you're going to exectue a single command with L{exec_command}. @param term: the terminal type to emulate (for example, C{'vt100'}) @type term: str @param width: width (in characters) of the terminal screen @type width: int @param height: height (in characters) of the terminal screen @type height: int @raise SSHException: if the request was rejected or the channel was closed sChannel is not openspty-reqitN(RRRRRRtadd_bytetchrtMSG_CHANNEL_REQUESTtadd_intR t add_stringt add_booleantTruet_event_pendingR t_send_user_messaget_wait_for_event(R-ttermtwidththeighttm((s+..\python\site-packages\paramiko\channel.pytget_pty}s%        cCs|js%|js%|js%|j r4tdnt}|jtt|j |j |j d|j d|j |jj||jdS(s Request an interactive shell session on this channel. If the server allows it, the channel will then be directly connected to the stdin, stdout, and stderr of the shell. Normally you would call L{get_pty} before this, in which case the shell will operate through the pty, and the channel will be connected to the stdin and stdout of the pty. When the shell exits, the channel will be closed and can't be reused. You must open a new channel if you wish to open another shell. @raise SSHException: if the request was rejected or the channel was closed sChannel is not opentshelliN(RRRRRRR8R9R:R;R R<R=R?R R@RA(R-RE((s+..\python\site-packages\paramiko\channel.pyt invoke_shells%    cCs|js%|js%|js%|j r4tdnt}|jtt|j |j |j d|j t |j ||j|jj||jdS(s3 Execute a command on the server. If the server allows it, the channel will then be directly connected to the stdin, stdout, and stderr of the command being executed. When the command finishes executing, the channel will be closed and can't be reused. You must open a new channel if you wish to execute another command. @param command: a shell command to execute. @type command: str @raise SSHException: if the request was rejected or the channel was closed sChannel is not opentexecN(RRRRRRR8R9R:R;R R<R=R>R?R R@RA(R-tcommandRE((s+..\python\site-packages\paramiko\channel.pyt exec_commands%     cCs|js%|js%|js%|j r4tdnt}|jtt|j |j |j d|j t |j ||j|jj||jdS(s Request a subsystem on the server (for example, C{sftp}). If the server allows it, the channel will then be directly connected to the requested subsystem. When the subsystem finishes, the channel will be closed and can't be reused. @param subsystem: name of the subsystem being requested. @type subsystem: str @raise SSHException: if the request was rejected or the channel was closed sChannel is not opent subsystemN(RRRRRRR8R9R:R;R R<R=R>R?R R@RA(R-RLRE((s+..\python\site-packages\paramiko\channel.pytinvoke_subsystems%     cCs|js%|js%|js%|j r4tdnt}|jtt|j |j |j d|j t |j ||j ||j dj d|j|jj||jdS(s Resize the pseudo-terminal. This can be used to change the width and height of the terminal emulation created in a previous L{get_pty} call. @param width: new width (in characters) of the terminal screen @type width: int @param height: new height (in characters) of the terminal screen @type height: int @raise SSHException: if the request was rejected or the channel was closed sChannel is not opens window-changeiN(RRRRRRR8R9R:R;R R<R=R>R?R R@RA(R-RCRDRE((s+..\python\site-packages\paramiko\channel.pyt resize_ptys %      cCs|jp|jjS(s Return true if the remote process has exited and returned an exit status. You may use this to poll the process status if you don't want to block in L{recv_exit_status}. Note that the server may not return an exit status in some cases (like bad servers). @return: True if L{recv_exit_status} will return immediately @rtype: bool @since: 1.7.3 (RR"tisSet(R-((s+..\python\site-packages\paramiko\channel.pytexit_status_ready s cCs)|jj|jjs"t|jS(s Return the exit status from the process on the server. This is mostly useful for retrieving the reults of an L{exec_command}. If the command hasn't finished yet, this method will wait until it does, or until the channel is closed. If no exit status is provided by the server, -1 is returned. @return: the exit code of the process on the server. @rtype: int @since: 1.2 (R"twaitROtAssertionErrorR+(R-((s+..\python\site-packages\paramiko\channel.pytrecv_exit_statuss cCsgt}|jtt|j|j|jd|jt|j||j j |dS(so Send the exit status of an executed command to the client. (This really only makes sense in server mode.) Many clients expect to get some sort of status code back from an executed command after it completes. @param status: the exit code of the process @type status: int @since: 1.2 s exit-statusN( RR8R9R:R;R R<R=R R R@(R-tstatusRE((s+..\python\site-packages\paramiko\channel.pytsend_exit_status+s    icCs(|js%|js%|js%|j r4tdn|dkrId}n|dkrvtj|jj j d}nt }|j t t|j|j|jd|jt|j||j||j||j||j|jj||j|jj||S(s Request an x11 session on this channel. If the server allows it, further x11 requests can be made from the server to the client, when an x11 application is run in a shell session. From RFC4254:: It is RECOMMENDED that the 'x11 authentication cookie' that is sent be a fake, random cookie, and that the cookie be checked and replaced by the real cookie when a connection request is received. If you omit the auth_cookie, a new secure random 128-bit value will be generated, used, and returned. You will need to use this value to verify incoming x11 requests and replace them with the actual local x11 cookie (which requires some knoweldge of the x11 protocol). If a handler is passed in, the handler is called from another thread whenever a new x11 connection arrives. The default handler queues up incoming x11 connections, which may be retrieved using L{Transport.accept}. The handler's calling signature is:: handler(channel: Channel, (address: str, port: int)) @param screen_number: the x11 screen number (0, 10, etc) @type screen_number: int @param auth_protocol: the name of the X11 authentication method used; if none is given, C{"MIT-MAGIC-COOKIE-1"} is used @type auth_protocol: str @param auth_cookie: hexadecimal string containing the x11 auth cookie; if none is given, a secure random 128-bit value is generated @type auth_cookie: str @param single_connection: if True, only a single x11 connection will be forwarded (by default, any number of x11 connections can arrive over this session) @type single_connection: bool @param handler: an optional handler to use for incoming X11 connections @type handler: function @return: the auth_cookie used sChannel is not opensMIT-MAGIC-COOKIE-1isx11-reqN(RRRRRR tbinasciithexlifyR trngtreadRR8R9R:R;R R<R=R>R?R@RAt_set_x11_handler(R-t screen_numbert auth_protocolt auth_cookietsingle_connectionthandlerRE((s+..\python\site-packages\paramiko\channel.pyt request_x11As()%   !         cCs|jS(s Return the L{Transport} associated with this channel. @return: the L{Transport} that was used to create this channel. @rtype: L{Transport} (R (R-((s+..\python\site-packages\paramiko\channel.pyt get_transportscCs ||_dS(s Set a name for this channel. Currently it's only used to set the name of the channel in logfile entries. The name can be fetched with the L{get_name} method. @param name: new channel name @type name: str N(R$(R-tname((s+..\python\site-packages\paramiko\channel.pytset_names cCs|jS(s Get the name of this channel that was previously set by L{set_name}. @return: the name of this channel. @rtype: str (R$(R-((s+..\python\site-packages\paramiko\channel.pytget_namescCs|jS(sc Return the ID # for this channel. The channel ID is unique across a L{Transport} and usually a small number. It's also the number passed to L{ServerInterface.check_channel_request} when determining whether to accept a channel request in server mode. @return: the ID of this channel. @rtype: int (R (R-((s+..\python\site-packages\paramiko\channel.pytget_ids cCsd}|jjz5|j}||_|rG| rG|jj}nWd|jjXt|dkr{|j|n|S(s< Set whether stderr should be combined into stdout on this channel. The default is C{False}, but in some cases it may be convenient to have both streams combined. If this is C{False}, and L{exec_command} is called (or C{invoke_shell} with no pty), output to stderr will not show up through the L{recv} and L{recv_ready} calls. You will have to use L{recv_stderr} and L{recv_stderr_ready} to get stderr output. If this is C{True}, data will never show up via L{recv_stderr} or L{recv_stderr_ready}. @param combine: C{True} if stderr output should be combined into stdout on this channel. @type combine: bool @return: previous setting. @rtype: bool @since: 1.1 R7Ni(RtacquireR*RtemptytreleaseR2t_feed(R-tcombinetdatatold((s+..\python\site-packages\paramiko\channel.pytset_combine_stderrs    cCs ||_dS(s Set a timeout on blocking read/write operations. The C{timeout} argument can be a nonnegative float expressing seconds, or C{None}. If a float is given, subsequent channel read/write operations will raise a timeout exception if the timeout period value has elapsed before the operation has completed. Setting a timeout of C{None} disables timeouts on socket operations. C{chan.settimeout(0.0)} is equivalent to C{chan.setblocking(0)}; C{chan.settimeout(None)} is equivalent to C{chan.setblocking(1)}. @param timeout: seconds to wait for a pending read/write operation before raising C{socket.timeout}, or C{None} for no timeout. @type timeout: float N(R(R-R((s+..\python\site-packages\paramiko\channel.pyt settimeoutscCs|jS(s Returns the timeout in seconds (as a float) associated with socket operations, or C{None} if no timeout is set. This reflects the last call to L{setblocking} or L{settimeout}. @return: timeout in seconds, or C{None}. @rtype: float (R(R-((s+..\python\site-packages\paramiko\channel.pyt gettimeouts cCs'|r|jdn |jddS(sp Set blocking or non-blocking mode of the channel: if C{blocking} is 0, the channel is set to non-blocking mode; otherwise it's set to blocking mode. Initially all channels are in blocking mode. In non-blocking mode, if a L{recv} call doesn't find any data, or if a L{send} call can't immediately dispose of the data, an error exception is raised. In blocking mode, the calls block until they can proceed. An EOF condition is considered "immediate data" for L{recv}, so if the channel is closed in the read direction, it will never block. C{chan.setblocking(0)} is equivalent to C{chan.settimeout(0)}; C{chan.setblocking(1)} is equivalent to C{chan.settimeout(None)}. @param blocking: 0 to set non-blocking mode; non-0 to set blocking mode. @type blocking: int gN(RnR (R-tblocking((s+..\python\site-packages\paramiko\channel.pyt setblockingscCs |jjS(s Return the address of the remote side of this Channel, if possible. This is just a wrapper around C{'getpeername'} on the Transport, used to provide enough of a socket-like interface to allow asyncore to work. (asyncore likes to call C{'getpeername'}.) @return: the address if the remote host, if known @rtype: tuple(str, int) (R t getpeername(R-((s+..\python\site-packages\paramiko\channel.pyRrs cCs|jjzO|jdk r8|jjd|_n|j sK|jrOdS|j}Wd|jjXx-|D]%}|dk rt|j j |qtqtWdS(s+ Close the channel. All future read/write operations on the channel will fail. The remote end will receive no more data (after queued data is flushed). Channels are automatically closed when their L{Transport} is closed or when they are garbage collected. N( RRfR'R R/RRt_close_internalRhR R@(R-tmsgsRE((s+..\python\site-packages\paramiko\channel.pyR/s     cCs |jjS(s Returns true if data is buffered and ready to be read from this channel. A C{False} result does not mean that the channel has closed; it means you may need to wait before more data arrives. @return: C{True} if a L{recv} call on this channel would immediately return at least one byte; C{False} otherwise. @rtype: boolean (Rt read_ready(R-((s+..\python\site-packages\paramiko\channel.pyt recv_ready,s cCsy|jj||j}Wntk r=}tjnX|jt|}|dkrt}|jt t |j |j |j ||j j|n|S(s  Receive data from the channel. The return value is a string representing the data received. The maximum amount of data to be received at once is specified by C{nbytes}. If a string of length zero is returned, the channel stream has closed. @param nbytes: maximum number of bytes to read. @type nbytes: int @return: data. @rtype: str @raise socket.timeout: if no data is ready before the timeout set by L{settimeout}. i(RRYRRtsockett_check_add_windowR2RR8R9tMSG_CHANNEL_WINDOW_ADJUSTR;R R R@(R-tnbytesR4tetackRE((s+..\python\site-packages\paramiko\channel.pytrecv8s   cCs |jjS(s Returns true if data is buffered and ready to be read from this channel's stderr stream. Only channels using L{exec_command} or L{invoke_shell} without a pty will ever have data on the stderr stream. @return: C{True} if a L{recv_stderr} call on this channel would immediately return at least one byte; C{False} otherwise. @rtype: boolean @since: 1.1 (RRu(R-((s+..\python\site-packages\paramiko\channel.pytrecv_stderr_readyWs cCsy|jj||j}Wntk r=}tjnX|jt|}|dkrt}|jt t |j |j |j ||j j|n|S(s Receive data from the channel's stderr stream. Only channels using L{exec_command} or L{invoke_shell} without a pty will ever have data on the stderr stream. The return value is a string representing the data received. The maximum amount of data to be received at once is specified by C{nbytes}. If a string of length zero is returned, the channel stream has closed. @param nbytes: maximum number of bytes to read. @type nbytes: int @return: data. @rtype: str @raise socket.timeout: if no data is ready before the timeout set by L{settimeout}. @since: 1.1 i(RRYRRRwRxR2RR8R9RyR;R R R@(R-RzR4R{R|RE((s+..\python\site-packages\paramiko\channel.pyt recv_stderrfs   cCsI|jjz'|js"|jr&tS|jdkSWd|jjXdS(s9 Returns true if data can be written to this channel without blocking. This means the channel is either closed (so any write attempt would return immediately) or there is at least one byte of space in the outbound buffer. If there is at least one byte of space in the outbound buffer, a L{send} call will succeed immediately and return the number of bytes actually written. @return: C{True} if a L{send} call on this channel would immediately succeed or fail @rtype: boolean iN(RRfRRR>RRh(R-((s+..\python\site-packages\paramiko\channel.pyt send_readys cCst|}|jjz`|j|}|dkr;dSt}|jtt|j|j |j || Wd|jj X|j j ||S(s- Send data to the channel. Returns the number of bytes sent, or 0 if the channel stream is closed. Applications are responsible for checking that all data has been sent: if only some of the data was transmitted, the application needs to attempt delivery of the remaining data. @param s: data to send @type s: str @return: number of bytes actually sent @rtype: int @raise socket.timeout: if no data could be sent before the timeout set by L{settimeout}. iN(R2RRft_wait_for_send_windowRR8R9tMSG_CHANNEL_DATAR;R R<RhR R@(R-tstsizeRE((s+..\python\site-packages\paramiko\channel.pytsends    cCst|}|jjzm|j|}|dkr;dSt}|jtt|j|j |jd|j || Wd|jj X|j j ||S(s Send data to the channel on the "stderr" stream. This is normally only used by servers to send output from shell commands -- clients won't use this. Returns the number of bytes sent, or 0 if the channel stream is closed. Applications are responsible for checking that all data has been sent: if only some of the data was transmitted, the application needs to attempt delivery of the remaining data. @param s: data to send. @type s: str @return: number of bytes actually sent. @rtype: int @raise socket.timeout: if no data could be sent before the timeout set by L{settimeout}. @since: 1.1 iiN(R2RRfRRR8R9tMSG_CHANNEL_EXTENDED_DATAR;R R<RhR R@(R-RRRE((s+..\python\site-packages\paramiko\channel.pyt send_stderrs     cCsEx>|r@|jr$tjdn|j|}||}qWdS(s Send data to the channel, without allowing partial results. Unlike L{send}, this method continues to send data from the given string until either all data has been sent or an error occurs. Nothing is returned. @param s: data to send. @type s: str @raise socket.timeout: if sending stalled for longer than the timeout set by L{settimeout}. @raise socket.error: if an error occured before the entire string was sent. @note: If the channel is closed while only part of the data hase been sent, there is no way to determine how much data (if any) was sent. This is irritating, but identically follows python's API. sSocket is closedN(RRwterrorRR (R-Rtsent((s+..\python\site-packages\paramiko\channel.pytsendalls   cCsEx>|r@|jr$tjdn|j|}||}qWdS(sg Send data to the channel's "stderr" stream, without allowing partial results. Unlike L{send_stderr}, this method continues to send data from the given string until all data has been sent or an error occurs. Nothing is returned. @param s: data to send to the client as "stderr" output. @type s: str @raise socket.timeout: if sending stalled for longer than the timeout set by L{settimeout}. @raise socket.error: if an error occured before the entire string was sent. @since: 1.1 sSocket is closedN(RRwRRR (R-RR((s+..\python\site-packages\paramiko\channel.pytsendall_stderrs   cGst|gt|S(s5 Return a file-like object associated with this channel. The optional C{mode} and C{bufsize} arguments are interpreted the same way as by the built-in C{file()} function in python. @return: object which can be used for python file I/O. @rtype: L{ChannelFile} (t ChannelFiletlist(R-tparams((s+..\python\site-packages\paramiko\channel.pytmakefiles cGst|gt|S(s Return a file-like object associated with this channel's stderr stream. Only channels using L{exec_command} or L{invoke_shell} without a pty will ever have data on the stderr stream. The optional C{mode} and C{bufsize} arguments are interpreted the same way as by the built-in C{file()} function in python. For a client, it only makes sense to open this file for reading. For a server, it only makes sense to open this file for writing. @return: object which can be used for python file I/O. @rtype: L{ChannelFile} @since: 1.1 (tChannelStderrFileR(R-R((s+..\python\site-packages\paramiko\channel.pytmakefile_stderr#scCs|jjzt|jdk r,|jjStj|_tj|j\}}|jj ||j j ||jjSWd|jj XdS(s Returns an OS-level file descriptor which can be used for polling, but but I{not} for reading or writing. This is primaily to allow python's C{select} module to work. The first time C{fileno} is called on a channel, a pipe is created to simulate real OS-level file descriptor (FD) behavior. Because of this, two OS-level FDs are created, which will use up FDs faster than normal. (You won't notice this effect unless you have hundreds of channels open at the same time.) @return: an OS-level file descriptor @rtype: int @warning: This method causes channel reads to be slightly less efficient. N( RRfR'R tfilenoRt make_pipet make_or_pipeRt set_eventRRh(R-tp1tp2((s+..\python\site-packages\paramiko\channel.pyR5s  cCs|dks|dkr$d|_n|dks<|dkr|jjz|j}Wd|jjX|dk r|jj|qndS(s Shut down one or both halves of the connection. If C{how} is 0, further receives are disallowed. If C{how} is 1, further sends are disallowed. If C{how} is 2, further sends and receives are disallowed. This closes the stream in one or both directions. @param how: 0 (stop receiving), 1 (stop sending), or 2 (stop receiving and sending). @type how: int iiiN(RRRft _send_eofRhR R R@(R-thowRE((s+..\python\site-packages\paramiko\channel.pytshutdownTs    cCs|jddS(sy Shutdown the receiving side of this socket, closing the stream in the incoming direction. After this call, future reads on this channel will fail instantly. This is a convenience method, equivalent to C{shutdown(0)}, for people who don't make it a habit to memorize unix constants from the 1970s. @since: 1.2 iN(R(R-((s+..\python\site-packages\paramiko\channel.pyt shutdown_readks cCs|jddS(sx Shutdown the sending side of this socket, closing the stream in the outgoing direction. After this call, future writes on this channel will fail instantly. This is a convenience method, equivalent to C{shutdown(1)}, for people who don't make it a habit to memorize unix constants from the 1970s. @since: 1.2 iN(R(R-((s+..\python\site-packages\paramiko\channel.pytshutdown_writews cCs(||_tj|jj|_dS(N(R RR%tget_log_channelR&(R-R ((s+..\python\site-packages\paramiko\channel.pyt_set_transports cCs@||_||_|d|_d|_|jtd|dS(Ni isMax packet in: %d bytes(RRRR t_logtDEBUG(R-t window_sizetmax_packet_size((s+..\python\site-packages\paramiko\channel.pyt _set_windows     cCsE||_||_t|t|_d|_|jtd|dS(NisMax packet out: %d bytes(R RtmaxtMIN_PACKET_SIZERRRR(R-R RR((s+..\python\site-packages\paramiko\channel.pyt_set_remote_channels    cCs1|jtd|jt|_|jjdS(NsSesch channel %d request ok(RRR R>R)R(tset(R-RE((s+..\python\site-packages\paramiko\channel.pyt_request_successs  cCsb|jjz|j}Wd|jjXx-|D]%}|dk r5|jj|q5q5WdS(N(RRfRsRhR R R@(R-RERt((s+..\python\site-packages\paramiko\channel.pyt_request_faileds   cCs;t|tkr|}n |j}|jj|dS(N(ttypeR#t get_stringRtfeed(R-RER((s+..\python\site-packages\paramiko\channel.pyRis  cCsi|j}|j}|dkr<|jtd|dS|jrU|j|n|jj|dS(Nis)unknown extended_data type %d; discarding(tget_intRRtERRORR*RiRR(R-REtcodeR((s+..\python\site-packages\paramiko\channel.pyt_feed_extendeds    cCsn|j}|jjz@|jr<|jtd|n|j|7_|jjWd|jj XdS(Ns window up %d( RRRfRRRRRt notifyAllRh(R-RERz((s+..\python\site-packages\paramiko\channel.pyt_window_adjusts   cCs|j}|j}|jj}t}|dkr[|j|_|jjt }nQ|dkrpt }n<|dkr|j}|j}|j}|j} |j} |j} |dkrt}q|j ||||| | | }n|dkr0|dkrt}q|j |}n||dkrr|j} |dkr]t}q|j || }n:|dkr|j} |dkrt}q|j|| }n|dkr#|j}|j}|j} |j} |dkrt}q|j|||| | }n|dkr|j}|j}|j}|j}|dkrtt}q|j|||||}n|jtd |t}|r t}|r|jttn|jtt|j|j|jj|ndS( Ns exit-statussxon-xoffspty-reqRGRIRLs window-changesx11-reqsUnhandled channel request "%s"(Rt get_booleanR t server_objectR RR+R"RR>R tcheck_channel_pty_requesttcheck_channel_shell_requesttcheck_channel_exec_requesttcheck_channel_subsystem_requestt#check_channel_window_change_requesttcheck_channel_x11_requestRRRR8R9tMSG_CHANNEL_SUCCESStMSG_CHANNEL_FAILURER;R R@(R-REtkeyt want_replytservertokRBRCRDt pixelwidtht pixelheighttmodestcmdRbR^t auth_protoR]R[((s+..\python\site-packages\paramiko\channel.pyt_handle_requests|                                             cCs|jjzR|js^t|_|jj|jj|jdk r^|jj q^nWd|jj X|j t d|j dS(NsEOF received (%s)(RRfRR>RR/RR'R t set_foreverRhRRR$(R-RE((s+..\python\site-packages\paramiko\channel.pyt _handle_eofs     cCsu|jjz#|j}|jj|jWd|jjXx-|D]%}|dk rH|jj|qHqHWdS(N( RRfRsR t_unlink_channelR RhR R@(R-RERt((s+..\python\site-packages\paramiko\channel.pyt _handle_closes    cGs)|jj|d|jd||dS(Ns[chan s] (R&tlogR$(R-tleveltmsgtargs((s+..\python\site-packages\paramiko\channel.pyR-scCs|jjt|_dS(N(R(tclearR R)(R-((s+..\python\site-packages\paramiko\channel.pyR?0s cCsc|jj|jjs"t|jr/dS|jj}|dkrYtd}n|dS(NsChannel closed.( R(RQRORRR)R t get_exceptionR R(R-R{((s+..\python\site-packages\paramiko\channel.pyRA4s   cCsmt|_|jj|jj|jj|jj|j j|j dk ri|j j ndS(N( R>RRR/RRRR(RR"R'R R(R-((s+..\python\site-packages\paramiko\channel.pyt _set_closed>s      cCs\|jr dSt}|jtt|j|jt|_|j t d|j |S(Ns EOF sent (%s)( RR RR8R9tMSG_CHANNEL_EOFR;R R>RRR$(R-RE((s+..\python\site-packages\paramiko\channel.pyRJs   cCsc|j s|jrdS|j}t}|jtt|j|j |j ||fS(N(NN( RRR RRR8R9tMSG_CHANNEL_CLOSER;R R(R-tm1tm2((s+..\python\site-packages\paramiko\channel.pyRsUs   cCsP|jr dS|jjz!|j|jj|jWd|jjXdS(N(RRRfRR RR Rh(R-((s+..\python\site-packages\paramiko\channel.pyt_unlinkbs   cCs|jjz|js,|js,|j r0dS|jrP|jtd|n|j|7_|j|j krudS|jr|jtd|jn|j}d|_|SWd|jj XdS(Nis addwindow %dsaddwindow send %d( RRfRRRRRRR RRh(R-tnR4((s+..\python\site-packages\paramiko\channel.pyRxms     cCs_|js|jrdS|jdkr|jdkrCtjn|j}x|jdkr|jsp|jrtdStj}|jj||dkrO|tj|8}|dkrtjqqOqOWn|js|jrdS|j|kr|j}n|j d|kr)|j d}n|j|8_|j r[|j t d|jn|S(sC (You are already holding the lock.) Wait for the send window to open up, and allocate up to C{size} bytes for transmission. If no space opens up before the timeout, a timeout exception is raised. Returns the number of bytes available to send (may be less than requested). igi@swindow down to %dN( RRRRRwttimeRRQR RRRR(R-RRtthen((s+..\python\site-packages\paramiko\channel.pyRs2       N(>t__name__t __module__t__doc__R.R0R5RFRHRKRMRNRPRSRUR R R`RaRcRdReRmRnRoRqRrR/RvR}R~RRRRRRRRRRRRRRRRRRiRRRRRRR?RARRRsRRxR(((s+..\python\site-packages\paramiko\channel.pyR+sv  (  #      > (      #  " &            I    RcBs8eZdZdddZdZdZdZRS(s A file-like wrapper around L{Channel}. A ChannelFile is created by calling L{Channel.makefile}. @bug: To correctly emulate the file object created from a socket's C{makefile} method, a L{Channel} and its C{ChannelFile} should be able to be closed or garbage-collected independently. Currently, closing the C{ChannelFile} does nothing but flush the buffer. tricCs*||_tj||j||dS(N(tchannelRR.t _set_mode(R-Rtmodetbufsize((s+..\python\site-packages\paramiko\channel.pyR.s  cCsdt|jdS(se Returns a string representation of this object, for debugging. @rtype: str ss*