File: //proc/thread-self/root/proc/self/root/lib64/python2.7/site-packages/mercurial/sshpeer.pyc
�
1�3\c @@ s d d l m Z d d l Z d d l Z d d l m Z d d l m Z m Z m Z m
Z
m Z m Z m
Z
d d l m Z m Z d � Z d � Z d e f d
� � YZ d � Z d d � Z d
� Z d � Z d e j f d � � YZ d e f d � � YZ e d � Z d d d � Z d S( i ( t absolute_importNi ( t _( t errort pycompatt utilt wireprotoservert wireprototypest wireprotov1peert wireprotov1server( t procutilt
stringutilc C@ s4 | s
| St j d | � r | Sd | j d d � S( s= quote a string for the remote shell ... which we assume is shs [a-zA-Z0-9@%_+=:,./-]*$s '%s't 's '\''( t ret matcht replace( t s( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt _serverquote s
c C@ sU | rQ t j | � } | rQ x0 | j � D] } | j t d � | d � q( WqQ n d S( sY display all data currently available on pipe as remote output.
This is non blocking.s remote: s
N( R t readpipet
splitlinest statusR ( t uit pipeR t l( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt _forwardoutput$ s
t
doublepipec B@ sb e Z d Z d � Z d � Z d � Z d � Z d � Z d � Z d
d � Z
d � Z d � Z RS( s3 Operate a side-channel pipe in addition of a main one
The side-channel pipe contains server output to be forwarded to the user
input. The double pipe will behave as the "main" pipe, but will ensure the
content of the "side" pipe is properly processed while we wait for blocking
call on the "main" pipe.
If large amounts of data are read from "main", the forward will cease after
the first bytes start to appear. This simplifies the implementation
without affecting actual output of sshpeer too much as we rarely issue
large read for data not yet emitted by the server.
The main pipe is expected to be a 'bufferedinputpipe' from the util module
that handle all the os specific bits. This class lives in this module
because it focus on behavior specific to the ssh protocol.c C@ s | | _ | | _ | | _ d S( N( t _uit _maint _side( t selfR t maint side( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt __init__? s c C@ s� t | j t j � r+ | j j r+ t t f S| j j � | j j � g } y t j | � } Wn t k
ru | } n X| j j � | k | j j � | k f S( s� wait until some data are available on main or side
return a pair of boolean (ismainready, issideready)
(This will only wait for data if the setup is supported by `util.poll`)
(
t
isinstanceR R t bufferedinputpipet hasbuffert Truet filenoR t pollt NotImplementedError( R t fdst act( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt _waitD s
c C@ s | j d | � S( Nt write( t _call( R t data( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR* X s c C@ s? | j d | � } | d k r; | r; t | j | j � n | S( Nt readi ( R+ R R R ( R t sizet r( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR- [ s c C@ s? | j d | � } | d k r; | r; t | j | j � n | S( Nt unbufferedreadi ( R+ R R R ( R R. R/ ( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR0 f s c C@ s
| j d � S( Nt readline( R+ ( R ( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR1 q s c C@ s� | d k r | s | j j r6 t | j | j � d Sxp t r� | j � \ } } | rm t | j | j � n | r9 t | j | � } | d k r� | � S| | � Sq9 q9 Wd S( sK call <methname> on "main", forward output of "side" while blocking
t N( t NoneR t closedR R R R# R) t getattr( R t methnameR, t mainreadyt sidereadyt meth( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR+ t s c C@ s
| j j � S( N( R t close( R ( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR: � s c C@ s
| j j � S( N( R t flush( R ( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR; � s N(
t __name__t
__module__t __doc__R R) R* R- R0 R1 R3 R+ R: R; ( ( ( s7 /usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR . s c C@ s� | r | j � n | r&