Current File : //lib/python2.7/site-packages/paramiko/channel.pyo
�
=OXc@smdZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZmZddlm Z ddl!m"Z"d
�Z#de"fd��YZ$defd��YZ%de%fd��YZ&dS(s"
Abstraction for an SSH2 channel.
i����N(twraps(tutil(
tcMSG_CHANNEL_REQUESTtcMSG_CHANNEL_WINDOW_ADJUSTtcMSG_CHANNEL_DATAtcMSG_CHANNEL_EXTENDED_DATAtDEBUGtERRORtcMSG_CHANNEL_SUCCESStcMSG_CHANNEL_FAILUREtcMSG_CHANNEL_EOFtcMSG_CHANNEL_CLOSE(tMessage(tbytes_types(tSSHException(tBufferedFile(tBufferedPipetPipeTimeout(tpipe(tClosingContextManagercst���fd��}|S(s�
    Decorator for `.Channel` methods which performs an openness check.

    :raises SSHException:
        If the wrapped method is called on an unopened `.Channel`.
    csD|js%|js%|js%|jr4td��n�|||�S(NsChannel is not open(tclosedteof_receivedteof_senttactiveR(tselftargstkwds(tfunc(s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_check3s			
(R(RR((Rs4/usr/lib/python2.7/site-packages/paramiko/channel.pyt	open_only,s
tChannelcBs�eZdZd�Zd�Zd�Zedddddd��Zed	��Zed
��Z	ed��Z
eddddd��Zed
��Zed��Z
d�Zd�Zd�ZeddCdCedCd��Zed��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�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-e.d-��Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:d9�Z;d:�Z<d;�Z=d<�Z>d=�Z?d>�Z@d?�ZAd@�ZBdA�ZCdB�ZDRS(Ds
    A secure tunnel across an SSH `.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 `send` may block, unless you set a timeout.  This
    is exactly like a normal network socket, so it shouldn't be too surprising.
    
    Instances of this class may be used as context managers.
    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(sm
        Create a new channel.  The channel is not associated with any
        particular session or `.Transport` until the Transport attaches it.
        Normally you would only call this method from the constructor of a
        subclass of `.Channel`.

        :param int chanid:
            the ID of this channel, as passed by an existing `.Transport`.
        isparamiko.transporti����N(&tchanidt
remote_chanidtNonet	transporttFalseRRRRt	in_buffertin_stderr_bufferttimeoutRtultra_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_pipeteventtevent_readytcombine_stderrtexit_statustorigin_addr(RR((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt__init__Qs8																			cCsy|j�WnnXdS(N(tclose(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt__del__}scCs�d|j}|jr#|d7}n{|jr�|jrB|d7}n|jrX|d7}n|d|j7}t|j�dkr�|dt|j�f7}q�n|dt|j	�7}|d	7}|S(
sO
        Return a string representation of this object, for debugging.
        s<paramiko.Channel %ds	 (closed)s (EOF received)s (EOF sent)s (open) window=%dis
 in-buffer=%ds -> t>(
RRRRRR.tlenR$treprR"(Rtout((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt__repr__�s
	
		
	
 
tvt100iPiicCs�t�}|jt�|j|j�|jd�|jt�|j|�|j|�|j|�|j|�|j|�|jt��|j	�|j
j|�|j�dS(sM
        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 `invoke_shell`.
        It isn't necessary (or desirable) to call this method if you're going
        to exectue a single command with `exec_command`.

        :param str term: the terminal type to emulate (for example, ``'vt100'``)
        :param int width: width (in characters) of the terminal screen
        :param int height: height (in characters) of the terminal screen
        :param int width_pixels: width (in pixels) of the terminal screen
        :param int height_pixels: height (in pixels) of the terminal screen

        :raises SSHException:
            if the request was rejected or the channel was closed
        spty-reqN(
Rtadd_byteRtadd_intR t
add_stringtadd_booleantTruetbytest_event_pendingR"t_send_user_messaget_wait_for_event(Rttermtwidththeighttwidth_pixelst
height_pixelstm((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytget_pty�s	








cCsht�}|jt�|j|j�|jd�|jt�|j�|j	j
|�|j�dS(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 `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.

        :raises SSHException: if the request was rejected or the channel was
            closed
        tshellN(RRHRRIR RJRKRLRNR"RORP(RRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytinvoke_shell�s	



cCsut�}|jt�|j|j�|jd�|jt�|j|�|j�|j	j
|�|j�dS(s
        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 str command: a shell command to execute.

        :raises SSHException: if the request was rejected or the channel was
            closed
        texecN(RRHRRIR RJRKRLRNR"RORP(RtcommandRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytexec_command�s	




cCsut�}|jt�|j|j�|jd�|jt�|j|�|j�|j	j
|�|j�dS(s�
        Request a subsystem on the server (for example, ``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 str subsystem: name of the subsystem being requested.

        :raises SSHException:
            if the request was rejected or the channel was closed
        t	subsystemN(RRHRRIR RJRKRLRNR"RORP(RR]RV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytinvoke_subsystem�s	




cCs�t�}|jt�|j|j�|jd�|jt�|j|�|j|�|j|�|j|�|jj	|�dS(s>
        Resize the pseudo-terminal.  This can be used to change the width and
        height of the terminal emulation created in a previous `get_pty` call.

        :param int width: new width (in characters) of the terminal screen
        :param int height: new height (in characters) of the terminal screen
        :param int width_pixels: new width (in pixels) of the terminal screen
        :param int height_pixels: new height (in pixels) of the terminal screen

        :raises SSHException:
            if the request was rejected or the channel was closed
        s
window-changeN(
RRHRRIR RJRKR#R"RO(RRRRSRTRURV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt
resize_ptys	






cCsixb|j�D]T\}}y|j||�Wq
tk
r`}d}t|j|�|��q
Xq
WdS(s�
        Updates this channel's remote shell environment.

        .. note::
            This operation is additive - i.e. the current environment is not
            reset before the given environment variables are set.

        .. warning::
            Servers may silently reject some environment variables; see the
            warning in `set_environment_variable` for details.

        :param dict environment:
            a dictionary containing the name and respective values to set
        :raises SSHException:
            if any of the environment variables was rejected by the server or
            the channel was closed
        s)Failed to set environment variable "{0}".N(titemstset_environment_variableRtformat(Rtenvironmenttnametvalueteterr((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytupdate_environmentscCsnt�}|jt�|j|j�|jd�|jt�|j|�|j|�|jj	|�dS(sN
        Set the value of an environment variable.

        .. warning::
            The server may reject this request depending on its ``AcceptEnv``
            setting; such rejections will fail silently (which is common client
            practice for this particular request type). Make sure you
            understand your server's configuration before using!

        :param str name: name of the environment variable
        :param str value: value of the environment variable

        :raises SSHException:
            if the request was rejected or the channel was closed
        tenvN(
RRHRRIR RJRKR#R"RO(RRdReRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyRa8s	




cCs|jp|jj�S(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 `recv_exit_status`. Note that the server may not
        return an exit status in some cases (like bad servers).

        :return:
            ``True`` if `recv_exit_status` will return immediately, else
            ``False``.

        .. versionadded:: 1.7.3
        (RR4tis_set(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytexit_status_readyRs
cCs|jj�|jS(s4
        Return the exit status from the process on the server.  This is
        mostly useful for retrieving the results of an `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.

        .. warning::
            In some situations, receiving remote output larger than the current
            `.Transport` or session's ``window_size`` (e.g. that set by the
            ``default_window_size`` kwarg for `.Transport.__init__`) will cause
            `.recv_exit_status` to hang indefinitely if it is called prior to a
            sufficiently large `~Channel..read` (or if there are no threads
            calling `~Channel.read` in the background).

            In these cases, ensuring that `.recv_exit_status` is called *after*
            `~Channel.read` (or, again, using threads) can avoid the hang.

        :return: the exit code (as an `int`) of the process on the server.

        .. versionadded:: 1.2
        (R4twaitR=(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytrecv_exit_statusas
cCsat�}|jt�|j|j�|jd�|jt�|j|�|jj	|�dS(sS
        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 int status: the exit code of the process

        .. versionadded:: 1.2
        sexit-statusN(
RRHRRIR RJRKR#R"RO(RtstatusRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytsend_exit_status|s
	



cCs�|dkrd}n|dkr<tjtjd��}nt�}|jt�|j|j	�|j
d�|jt�|j|�|j
|�|j
|�|j|�|j
�|jj|�|j�|jj|�|S(sU
        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 :rfc:`4254`::

            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 knowledge 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
        `.Transport.accept`.  The handler's calling signature is::

            handler(channel: Channel, (address: str, port: int))

        :param int screen_number: the x11 screen number (0, 10, etc.)
        :param str auth_protocol:
            the name of the X11 authentication method used; if none is given,
            ``"MIT-MAGIC-COOKIE-1"`` is used
        :param str auth_cookie:
            hexadecimal string containing the x11 auth cookie; if none is
            given, a secure random 128-bit value is generated
        :param bool single_connection:
            if True, only a single x11 connection will be forwarded (by
            default, any number of x11 connections can arrive over this
            session)
        :param function handler:
            an optional handler to use for incoming X11 connections
        :return: the auth_cookie used
        sMIT-MAGIC-COOKIE-1isx11-reqN(R!tbinasciithexlifytosturandomRRHRRIR RJRKRLRNR"RORPt_set_x11_handler(Rt
screen_numbert
auth_protocoltauth_cookietsingle_connectionthandlerRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytrequest_x11�s$)		








cCsdt�}|jt�|j|j�|jd�|jt�|jj	|�|jj
|�tS(sx
        Request for a forward SSH Agent on this channel.
        This is only valid for an ssh-agent from OpenSSH !!!

        :param function handler:
            a required handler to use for incoming SSH Agent connections

        :return: True if we are ok, else False (at that time we always return ok)

        :raises: SSHException in case of channel problem.
        sauth-agent-req@openssh.com(RRHRRIR RJRKR#R"ROt_set_forward_agent_handlerRL(RRyRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytrequest_forward_agent�s
	


cCs|jS(sG
        Return the `.Transport` associated with this channel.
        (R"(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt
get_transport�scCs
||_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
        `get_name` method.

        :param str name: new channel name
        N(R6(RRd((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytset_name�scCs|jS(sU
        Get the name of this channel that was previously set by `set_name`.
        (R6(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytget_name�scCs|jS(s3
        Return the `int` ID # for this channel.

        The channel ID is unique across a `.Transport` and usually a small
        number.  It's also the number passed to
        `.ServerInterface.check_channel_request` when determining whether to
        accept a channel request in server mode.
        (R(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytget_id�s	cCs�t�}|jj�z5|j}||_|rJ|rJ|jj�}nWd|jj�Xt|�dkr~|j|�n|S(s
        Set whether stderr should be combined into stdout on this channel.
        The default is ``False``, but in some cases it may be convenient to
        have both streams combined.

        If this is ``False``, and `exec_command` is called (or ``invoke_shell``
        with no pty), output to stderr will not show up through the `recv`
        and `recv_ready` calls.  You will have to use `recv_stderr` and
        `recv_stderr_ready` to get stderr output.

        If this is ``True``, data will never show up via `recv_stderr` or
        `recv_stderr_ready`.

        :param bool combine:
            ``True`` if stderr output should be combined into stdout on this
            channel.
        :return: the previous setting (a `bool`).

        .. versionadded:: 1.1
        Ni(	RMR*tacquireR<R%temptytreleaseRCt_feed(Rtcombinetdatatold((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytset_combine_stderrs	
		
cCs
||_dS(s�
        Set a timeout on blocking read/write operations.  The ``timeout``
        argument can be a nonnegative float expressing seconds, or ``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 ``None`` disables
        timeouts on socket operations.

        ``chan.settimeout(0.0)`` is equivalent to ``chan.setblocking(0)``;
        ``chan.settimeout(None)`` is equivalent to ``chan.setblocking(1)``.

        :param float timeout:
            seconds to wait for a pending read/write operation before raising
            ``socket.timeout``, or ``None`` for no timeout.
        N(R&(RR&((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt
settimeout*scCs|jS(s�
        Returns the timeout in seconds (as a float) associated with socket
        operations, or ``None`` if no timeout is set.  This reflects the last
        call to `setblocking` or `settimeout`.
        (R&(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt
gettimeout<scCs'|r|jd�n
|jd�dS(sZ
        Set blocking or non-blocking mode of the channel: if ``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 `recv` call doesn't find any data, or if a
        `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 `recv`, so if the
        channel is closed in the read direction, it will never block.

        ``chan.setblocking(0)`` is equivalent to ``chan.settimeout(0)``;
        ``chan.setblocking(1)`` is equivalent to ``chan.settimeout(None)``.

        :param int blocking:
            0 to set non-blocking mode; non-0 to set blocking mode.
        gN(R�R!(Rtblocking((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytsetblockingDscCs
|jj�S(s
        Return the address of the remote side of this Channel, if possible.

        This simply wraps `.Transport.getpeername`, used to provide enough of a
        socket-like interface to allow asyncore to work. (asyncore likes to
        call ``'getpeername'``.)
        (R"tgetpeername(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR�[scCs�|jj�zO|jdk	r8|jj�d|_n|jsK|jrOdS|j�}Wd|jj�Xx-|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 `.Transport`
        is closed or when they are garbage collected.
        N(R*R�R9R!R@RRt_close_internalR�R"RO(RtmsgsRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR@es


cCs
|jj�S(sv
        Returns true if data is buffered and ready to be read from this
        channel.  A ``False`` result does not mean that the channel has closed;
        it means you may need to wait before more data arrives.

        :return:
            ``True`` if a `recv` call on this channel would immediately return
            at least one byte; ``False`` otherwise.
        (R$t
read_ready(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt
recv_readys
cCs�y|jj||j�}Wntk
r;tj��nX|jt|��}|dkr�t�}|jt	�|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 ``nbytes``.  If a string of length zero
        is returned, the channel stream has closed.

        :param int nbytes: maximum number of bytes to read.
        :return: received data, as a `bytes`

        :raises socket.timeout:
            if no data is ready before the timeout set by `settimeout`.
        i(R$treadR&Rtsockett_check_add_windowRCRRHRRIR R"RO(RtnbytesREtackRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytrecv�s

	

cCs
|jj�S(s�
        Returns true if data is buffered and ready to be read from this
        channel's stderr stream.  Only channels using `exec_command` or
        `invoke_shell` without a pty will ever have data on the stderr
        stream.

        :return:
            ``True`` if a `recv_stderr` call on this channel would immediately
            return at least one byte; ``False`` otherwise.

        .. versionadded:: 1.1
        (R%R�(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytrecv_stderr_ready�s
cCs�y|jj||j�}Wntk
r;tj��nX|jt|��}|dkr�t�}|jt	�|j
|j�|j
|�|jj
|�n|S(s�
        Receive data from the channel's stderr stream.  Only channels using
        `exec_command` or `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 ``nbytes``.  If a string of length zero is returned, the
        channel stream has closed.

        :param int nbytes: maximum number of bytes to read.
        :return: received data as a `str`

        :raises socket.timeout: if no data is ready before the timeout set by
            `settimeout`.

        .. versionadded:: 1.1
        i(R%R�R&RR�R�RCRRHRRIR R"RO(RR�RER�RV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytrecv_stderr�s
	

cCsI|jj�z'|js"|jr&tS|jdkSWd|jj�XdS(s#
        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 `send` call will succeed immediately and return
        the number of bytes actually written.

        :return:
            ``True`` if a `send` call on this channel would immediately succeed
            or fail
        iN(R*R�RRRLR.R�(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt
send_ready�s

cCs6t�}|jt�|j|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 str s: data to send
        :return: number of bytes actually sent, as an `int`

        :raises socket.timeout: if no data could be sent before the timeout set
            by `settimeout`.
        (RRHRRIR t_send(RtsRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytsend�s	
cCsCt�}|jt�|j|j�|jd�|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 str s: data to send.
        :return: number of bytes actually sent, as an `int`.

        :raises socket.timeout:
            if no data could be sent before the timeout set by `settimeout`.

        .. versionadded:: 1.1
        i(RRHRRIR R�(RR�RV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytsend_stderrs
	

cCs*x#|r%|j|�}||}qWdS(s�
        Send data to the channel, without allowing partial results.  Unlike
        `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 str s: data to send.

        :raises socket.timeout:
            if sending stalled for longer than the timeout set by `settimeout`.
        :raises socket.error:
            if an error occurred before the entire string was sent.
        
        .. note::
            If the channel is closed while only part of the data has been
            sent, there is no way to determine how much data (if any) was sent.
            This is irritating, but identically follows Python's API.
        N(R�R!(RR�tsent((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytsendalls	cCs*x#|r%|j|�}||}qWdS(sQ
        Send data to the channel's "stderr" stream, without allowing partial
        results.  Unlike `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 str s: data to send to the client as "stderr" output.

        :raises socket.timeout:
            if sending stalled for longer than the timeout set by `settimeout`.
        :raises socket.error:
            if an error occurred before the entire string was sent.
            
        .. versionadded:: 1.1
        N(R�R!(RR�R�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytsendall_stderr1s	cGst|gt|��S(s(
        Return a file-like object associated with this channel.  The optional
        ``mode`` and ``bufsize`` arguments are interpreted the same way as by
        the built-in ``file()`` function in Python.

        :return: `.ChannelFile` object which can be used for Python file I/O.
        (tChannelFiletlist(Rtparams((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytmakefileFscGst|gt|��S(sj
        Return a file-like object associated with this channel's stderr
        stream.   Only channels using `exec_command` or `invoke_shell`
        without a pty will ever have data on the stderr stream.

        The optional ``mode`` and ``bufsize`` arguments are interpreted the
        same way as by the built-in ``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: `.ChannelFile` object which can be used for Python file I/O.

        .. versionadded:: 1.1
        (tChannelStderrFileR�(RR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytmakefile_stderrPscCs�|jj�zt|jdk	r,|jj�Stj�|_tj|j�\}}|jj	|�|j
j	|�|jj�SWd|jj�XdS(s�
        Returns an OS-level file descriptor which can be used for polling, but
        but not for reading or writing.  This is primarily to allow Python's
        ``select`` module to work.

        The first time ``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 (`int`)

        .. warning::
            This method causes channel reads to be slightly less efficient.
        N(R*R�R9R!tfilenoRt	make_pipetmake_or_pipeR$t	set_eventR%R�(Rtp1tp2((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR�as

cCs�|dks|dkr$d|_n|dks<|dkr�|jj�z|j�}Wd|jj�X|dk	r�|jj|�q�ndS(s�
        Shut down one or both halves of the connection.  If ``how`` is 0,
        further receives are disallowed.  If ``how`` is 1, further sends
        are disallowed.  If ``how`` is 2, further sends and receives are
        disallowed.  This closes the stream in one or both directions.

        :param int how:
            0 (stop receiving), 1 (stop sending), or 2 (stop receiving and
              sending).
        iiiN(RR*R�t	_send_eofR�R!R"RO(RthowRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytshutdowns
cCs|jd�dS(s|
        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 ``shutdown(0)``, for people who don't make it a habit to
        memorize unix constants from the 1970s.

        .. versionadded:: 1.2
        iN(R�(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt
shutdown_read�s
cCs|jd�dS(s{
        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 ``shutdown(1)``, for people who don't make it a habit to
        memorize unix constants from the 1970s.

        .. versionadded:: 1.2
        iN(R�(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pytshutdown_write�s
cCs|jS(N(R(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_closed�scCs(||_tj|jj��|_dS(N(R"RR7tget_log_channelR8(RR"((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_set_transport�s	cCs@||_||_|d|_d|_|jtd|�dS(Ni
isMax packet in: %d bytes(R-R/R1R2t_logR(Rtwindow_sizetmax_packet_size((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_set_window�s
		
	cCsK||_||_|jj|�|_d|_|jtd|j�dS(NisMax packet out: %d bytes(R R.R"t_sanitize_packet_sizeR0RR�R(RRR�R�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_set_remote_channel�s				cCs1|jtd|j�t|_|jj�dS(NsSesch channel %d request ok(R�RRRLR;R:tset(RRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_request_success�s	
cCsb|jj�z|j�}Wd|jj�Xx-|D]%}|dk	r5|jj|�q5q5WdS(N(R*R�R�R�R!R"RO(RRVR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_request_failed�s

cCs8t|t�r|}n|j�}|jj|�dS(N(t
isinstanceR
t
get_binaryR$tfeed(RRVR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR��s	cCsi|j�}|j�}|dkr<|jtd|�dS|jrU|j|�n|jj|�dS(Nis)unknown extended_data type %d; discarding(tget_intR�R�RR<R�R%R�(RRVtcodeR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_feed_extended�s	cCsn|j�}|jj�z@|jr<|jtd|�n|j|7_|jj�Wd|jj	�XdS(Nswindow up %d(
R�R*R�R'R�RR.R,t	notifyAllR�(RRVR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_window_adjust�s
	cCs�|j�}|j�}|jj}t}|dkr[|j�|_|jj�t	}n�|dkrpt	}n�|dkr�|j
�}|j�}|j�}|j�}	|j�}
|j
�}|dkr�t}q0|j|||||	|
|�}n3|dkr0|dkrt}q0|j
|�}n|dkr�|j
�}|j
�}
|dkrit}q0|j|||
�}n�|dkr�|j
�}|dkr�t}q0|j||�}nm|dkr|j�}|dkr�t}q0|j||�}n+|dkrt|j�}|j�}|j�}	|j�}
|dkrVt}q0|j||||	|
�}n�|d	kr�|j�}|j�}|j�}|j�}|dkr�t}q0|j|||||�}nM|d
kr|dkrt}q0|j|�}n|jtd|�t}|r�t�}|rU|jt�n
|jt�|j|j�|jj|�ndS(Nsexit-statussxon-xoffspty-reqRXRiRZR]s
window-changesx11-reqsauth-agent-req@openssh.comsUnhandled channel request "%s"(tget_texttget_booleanR"t
server_objectR#R�R=R4R�RLt
get_stringR!tcheck_channel_pty_requesttcheck_channel_shell_requesttcheck_channel_env_requesttcheck_channel_exec_requesttcheck_channel_subsystem_requestt#check_channel_window_change_requestR�tcheck_channel_x11_requestt#check_channel_forward_agent_requestR�RRRHRR	RIR RO(RRVtkeyt
want_replytservertokRQRRRSt
pixelwidthtpixelheighttmodesRdRetcmdRxt
auth_protoRwRu((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_handle_request�s�
											
cCs�|jj�zR|js^t|_|jj�|jj�|jdk	r^|jj	�q^nWd|jj
�X|jtd|j
�dS(NsEOF received (%s)(R*R�RRLR$R@R%R9R!tset_foreverR�R�RR6(RRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_handle_eofMs
		

cCsu|jj�z#|j�}|jj|j�Wd|jj�Xx-|D]%}|dk	rH|jj|�qHqHWdS(N(	R*R�R�R"t_unlink_channelRR�R!RO(RRVR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt
_handle_closeZs

cCs�t|�}|jj�zO|jr7tjd��n|j|�}|dkrVdS|j|| �Wd|jj�X|j	j
|�|S(NsSocket is closedi(RCR*R�RR�terrort_wait_for_send_windowRJR�R"RO(RR�RVtsize((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR�gs
	cGs)|jj|d|jd||�dS(Ns[chan s] (R8tlogR6(RtleveltmsgR((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR�zscCs|jj�t|_dS(N(R:tclearR#R;(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyRN}s
cCsN|jj�|jrdS|jj�}|dkrDtd�}n|�dS(NsChannel closed.(R:RlR;R"t
get_exceptionR!R(RRf((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyRP�s
	cCsmt|_|jj�|jj�|jj�|jj�|j	j�|j
dk	ri|j
j�ndS(N(
RLRR$R@R%R,R�R:R�R4R9R!R�(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_set_closed�s	




cCsV|jr
dSt�}|jt�|j|j�t|_|jt	d|j
�|S(Ns
EOF sent (%s)(RR!RRHR
RIR RLR�RR6(RRV((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR��s		
	cCs]|js|jrdS|j�}t�}|jt�|j|j�|j	�||fS(N(NN(
RRR!R�RRHRRIR R�(Rtm1tm2((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR��s	

cCsP|jr
dS|jj�z!|j�|jj|j�Wd|jj�XdS(N(RR*R�R�R"R�RR�(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_unlink�s	

cCs�|jj�z�|js,|js,|jr0dS|jrP|jtd|�n|j|7_|j|j	krudS|jr�|jtd|j�n|j}d|_|SWd|jj
�XdS(Nisaddwindow %dsaddwindow send %d(R*R�RRRR'R�RR2R1R�(RtnRE((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR��s
				cCs_|js|jrdS|jdkr�|jdkrCtj��n|j}x�|jdkr�|jsp|jrtdStj�}|jj|�|dk	rO|tj�|8}|dkr�tj��q�qOqOWn|js�|jr�dS|j|kr|j}n|j	d|kr)|j	d}n|j|8_|j
r[|jtd|j�n|S(sD
        (You are already holding the lock.)
        Wait for the send window to open up, and allocate up to ``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(
RRR.R&R�ttimeR,RlR!R0R'R�R(RR�R&tthen((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR��s2			N(Et__name__t
__module__t__doc__R?RARFRRWRYR\R^R_RhRaRkRmRoR!R#RzR|R}R~RR�R�R�R�R�R�R@R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�tpropertyR�R�R�R�R�R�R�R�R�R�R�R�R�R�RNRPR�R�R�R�R�R�(((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR@s�	,		 				;		
			%				
					!						
										
				U	
	
				
			
		R�cBs8eZdZddd�Zd�Zd�Zd�ZRS(s�
    A file-like wrapper around `.Channel`.  A ChannelFile is created by calling
    `Channel.makefile`.

    .. warning::
        To correctly emulate the file object created from a socket's `makefile
        <python:socket.socket.makefile>` method, a `.Channel` and its
        `.ChannelFile` should be able to be closed or garbage-collected
        independently. Currently, closing the `ChannelFile` does nothing but
        flush the buffer.
    tri����cCs*||_tj|�|j||�dS(N(tchannelRR?t	_set_mode(RR�tmodetbufsize((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR?s	
cCsdt|j�dS(sP
        Returns a string representation of this object, for debugging.
        s<paramiko.ChannelFile from RB(RDR�(R((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyRFscCs|jj|�S(N(R�R�(RR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_readscCs|jj|�t|�S(N(R�R�RC(RR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt_writes(R�R�R�R?RFR�R�(((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR��s
		R�cBs)eZddd�Zd�Zd�ZRS(R�i����cCstj||||�dS(N(R�R?(RR�R�R�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR?scCs|jj|�S(N(R�R�(RR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR�scCs|jj|�t|�S(N(R�R�RC(RR�((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR�s(R�R�R?R�R�(((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyR�s	('R�RpRrR�R�R(t	functoolsRtparamikoRtparamiko.commonRRRRRRRR	R
Rtparamiko.messageRtparamiko.py3compatR
tparamiko.ssh_exceptionRt
paramiko.fileRtparamiko.buffered_pipeRRRt
paramiko.utilRRRR�R�(((s4/usr/lib/python2.7/site-packages/paramiko/channel.pyt<module>s.F	�����