3 ›äL]Rã@s`dZddlZddlZddlZdd„ZGdd„deƒZGdd„deƒZGd d „d eƒZd d „Z dS) a Abstraction of a one-way pipe where the read end can be used in `select.select`. Normally this is trivial, but Windows makes it nearly impossible. The pipe acts like an Event, which can be set or cleared. When set, the pipe will trigger as readable in `select `. éNcCs$tjdd…dkrtƒ}ntƒ}|S)NéÚwin)ÚsysÚplatformÚ PosixPipeÚ WindowsPipe)Úp©r ú3/tmp/pip-install-wfra5znf/paramiko/paramiko/pipe.pyÚ make_pipe!sr c@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)rcCs&tjƒ\|_|_d|_d|_d|_dS)NF)ÚosÚpipeÚ_rfdÚ_wfdÚ_setÚ_foreverÚ_closed)Úselfr r r Ú__init__*szPosixPipe.__init__cCs"tj|jƒtj|jƒd|_dS)NT)r Úcloserrr)rr r r r0s  zPosixPipe.closecCs|jS)N)r)rr r r Úfileno6szPosixPipe.filenocCs*|j s|jrdStj|jdƒd|_dS)NéF)rrr Úreadr)rr r r Úclear9szPosixPipe.clearcCs(|js |jrdSd|_tj|jdƒdS)NTó*)rrr Úwriter)rr r r Úset?s z PosixPipe.setcCsd|_|jƒdS)NT)rr)rr r r Ú set_foreverEszPosixPipe.set_foreverN) Ú__name__Ú __module__Ú __qualname__rrrrrrr r r r r)s rc@s@eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dS)rz‡ On Windows, only an OS-level "WinSock" may be used in select(), but reads and writes must be to the actual socket object. cCsztjtjtjƒ}|jdƒ|jdƒtjtjtjƒ|_|jjd|jƒdfƒ|jƒ\|_ }|j ƒd|_ d|_ d|_ dS)Nú 127.0.0.1rrF)r!r)ÚsocketÚAF_INETÚ SOCK_STREAMÚbindÚlistenÚ_rsockÚconnectÚ getsocknameÚacceptÚ_wsockrrrr)rZservÚaddrr r r rPs  zWindowsPipe.__init__cCs|jjƒ|jjƒd|_dS)NT)r'rr+r)rr r r r_s  zWindowsPipe.closecCs |jjƒS)N)r'r)rr r r reszWindowsPipe.filenocCs(|j s|jrdS|jjdƒd|_dS)NrF)rrr'Úrecv)rr r r rhs zWindowsPipe.clearcCs&|js |jrdSd|_|jjdƒdS)NTr)rrr+Úsend)rr r r rns zWindowsPipe.setcCsd|_|jƒdS)NT)rr)rr r r rtszWindowsPipe.set_foreverN) rrr Ú__doc__rrrrrrr r r r rJsrc@s$eZdZdd„Zdd„Zdd„ZdS)ÚOrPipecCsd|_d|_||_dS)NF)rÚ_partnerÚ_pipe)rr r r r rzszOrPipe.__init__cCsd|_|jjs|jjƒdS)NT)rr1r2r)rr r r rsz OrPipe.setcCsd|_|jjs|jjƒdS)NF)rr1r2r)rr r r r„sz OrPipe.clearN)rrr rrrr r r r r0ysr0cCs$t|ƒ}t|ƒ}||_||_||fS)zØ wraps a pipe into two pipe-like objects which are "or"d together to affect the real pipe. if either returned pipe is set, the wrapped pipe is set. when both are cleared, the wrapped pipe is cleared. )r0r1)r Úp1Úp2r r r Ú make_or_pipeŠs r5) r/rr r"r Úobjectrrr0r5r r r r Ús!/