%PDF- %PDF-
| Direktori : /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/ |
| Current File : //opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyc |
�
��Abc @ s� d d l Z d d l Z d d l Z d d l m Z d d l Z d d l Z d \ Z Z y d d l Z Wn e k
r� Z
e
Z n Xd d l m Z d d l
m Z d e f d � � YZ d S( i����N( t select( t ProxyCommandFailure( t ClosingContextManagert ProxyCommandc B sY e Z d Z d � Z d � Z d � Z d � Z e d � � Z e d � � Z d � Z
RS( s�
Wraps a subprocess running ProxyCommand-driven programs.
This class implements a the socket-like interface needed by the
`.Transport` and `.Packetizer` classes. Using this class instead of a
regular socket makes it possible to talk with a Popen'd command that will
proxy traffic between the client and a server hosted in another machine.
Instances of this class may be used as context managers.
c
C sj t d k r t � n t j | � | _ t j | j d t j d t j d t j d d �| _ d | _ d S( s
Create a new CommandProxy instance. The instance created by this
class can be passed as an argument to the `.Transport` class.
:param str command_line:
the command that should be executed and used as the proxy.
t stdint stdoutt stderrt bufsizei N(
t
subprocesst Nonet subprocess_import_errort shlext splitt cmdt Popent PIPEt processt timeout( t selft command_line( ( sC /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyt __init__3 s c C sU y | j j j | � Wn1 t k
rJ } t d j | j � | j � � n Xt | � S( s�
Write the content received from the SSH client to the standard
input of the forked command.
:param str content: string to be sent to the forked command
t ( R R t writet IOErrorR t joinR
t strerrort len( R t contentt e( ( sC /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyt sendG s
"c
C sP y� d } t j � } x� t | � | k r� d } | j d k r} t j � | } | | j k rm t j � � n | j | } n t | j j g g g | � \ } } } | r | d | j j k r | t j | j j j
� | t | � � 7} q q W| SWnQ t j k
r| r| S� n1 t k
rK} t d j
| j � | j � � n Xd S( s�
Read from the standard output of the forked program.
:param int size: how many chars should be read
:return: the string of bytes read, which may be shorter than requested
t i R N( t timeR R R t socketR R R t ost readt filenoR R R R
R (
R t sizet buffert startt select_timeoutt elapsedt rt wt xR ( ( sC /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyt recvX s* ' *c C s t j | j j t j � d S( N( R! t killR t pidt signalt SIGTERM( R ( ( sC /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyt closey s c C s | j j d k S( N( R t
returncodeR ( R ( ( sC /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyt closed| s c C s | j S( N( R3 ( R ( ( sC /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyt _closed� s c C s
| | _ d S( N( R ( R R ( ( sC /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyt
settimeout� s ( t __name__t
__module__t __doc__R R R, R1 t propertyR3 R4 R5 ( ( ( sC /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/proxy.pyR '