%PDF- %PDF-
Direktori : /proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/ |
Current File : //proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyc |
� ��Abc @ sp d Z d d l Z d d l Z d d l Z d d l m Z m Z d e f d � � YZ d e f d � � YZ d S( s� Attempt to generalize the "feeder" part of a `.Channel`: an object which can be read from and closed, but is reading from a buffer fed by another thread. The read operations are blocking and can have a timeout set. i����N( t PY2t bt PipeTimeoutc B s e Z d Z RS( sP Indicates that a timeout was reached on a read from a `.BufferedPipe`. ( t __name__t __module__t __doc__( ( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyR s t BufferedPipec B s� e Z d Z d � Z e r3 d � Z d d � Z n d � Z d d � Z d � Z d � Z d � Z d d � Z d � Z d � Z d � Z RS( s� A buffer that obeys normal read (with timeout) & close semantics for a file or socket, but is fed data from another thread. This is used by `.Channel`. c C sL t j � | _ t j | j � | _ d | _ t j d � | _ t | _ d S( Nt B( t threadingt Lockt _lockt Conditiont _cvt Nonet _eventt arrayt _buffert Falset _closed( t self( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyt __init__. s c C s | j j | � d S( N( R t fromstring( R t data( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyt _buffer_frombytes7 s c C s | j | j � S( N( R t tostring( R t limit( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyt _buffer_tobytes: s c C s | j j | � d S( N( R t frombytes( R R ( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyR ? s c C s | j | j � S( N( R t tobytes( R R ( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyR B s c C sd | j j � zB | | _ | j s7 t | j � d k rD | j � n | j � Wd | j j � Xd S( s Set an event on this buffer. When data is ready to be read (or the buffer has been closed), the event will be set. When no data is ready, the event will be cleared. :param threading.Event event: the event to set/clear i N( R t acquireR R t lenR t sett cleart release( R t event( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyt set_eventE s c C se | j j � zC | j d k r/ | j j � n | j t | � � | j j � Wd | j j � Xd S( s� Feed new data into this pipe. This method is assumed to be called from a separate thread, so synchronization is done. :param data: the data to add, as a ``str`` or ``bytes`` N( R R R R R R R R t notifyAllR! ( R R ( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyt feed\ s c C sC | j j � z! t | j � d k r) t St SWd | j j � Xd S( sd Returns true if data is buffered and ready to be read from this feeder. A ``False`` result does not mean that the feeder has closed; it means you may need to wait before more data arrives. :return: ``True`` if a `read` call would immediately return at least one byte; ``False`` otherwise. i N( R R R R R t TrueR! ( R ( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyt read_readyl s c C sV t � } | j j � z+t | j � d k r� | j r; | S| d k rS t � � n x} t | j � d k r� | j r� t j � } | j j | � | d k rV | t j � | 8} | d k r� t � � q� qV qV Wn t | j � | k r'| j � } | j 2| j d k r@| j r@| j j � q@n | j | � } | j | 4Wd | j j � X| S( s| Read data from the pipe. 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 pipe has been closed. The optional ``timeout`` argument can be a nonnegative float expressing seconds, or ``None`` for no timeout. If a float is given, a `.PipeTimeout` will be raised if the timeout period value has elapsed before any data arrives. :param int nbytes: maximum number of bytes to read :param float timeout: maximum seconds to wait (or ``None``, the default, to wait forever) :return: the read data, as a ``str`` or ``bytes`` :raises: `.PipeTimeout` -- if a timeout was specified and no data was ready before that timeout i g N( t bytesR R R R R R t timeR t waitR R R R R! ( R t nbytest timeoutt outt then( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyt read~ s0 "c C sf | j j � zD | j � } | j 2| j d k rL | j rL | j j � n | SWd | j j � Xd S( s� Clear out the buffer and return all data that was in it. :return: any data that was in the buffer prior to clearing it out, as a `str` N( R R R R R R R R R! ( R R- ( ( sK /opt/plesk/python/2.7/lib/python2.7/site-packages/paramiko/buffered_pipe.pyt empty� s c C s[ | j j � z9 t | _ | j j � | j d k rE | j j � n Wd | j j � Xd S( s� Close this pipe object. Future calls to `read` after the buffer has been emptied will return immediately with an empty string. N( R R R&