U e5d„ã@s¸dZddlZddlZddlmZddlmZddlmZddlmZddlm Z ej Z ej Z ej Z Gd d „d ej ejƒZGd d „d ƒZddddejfd d„Zddddejdœdd„ZdS))Úcreate_subprocess_execÚcreate_subprocess_shelléNé)Úevents)Ú protocols)Ústreams)Útasks)ÚloggercsTeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z ‡Z S)ÚSubprocessStreamProtocolcsHtƒj|d�||_d|_|_|_d|_d|_g|_|j   ¡|_ dS)N©ÚloopF) ÚsuperÚ__init__Ú_limitÚstdinÚstdoutÚstderrÚ _transportÚ_process_exitedÚ _pipe_fdsÚ_loopZ create_futureÚ _stdin_closed)ÚselfÚlimitr ©Ú __class__©ú*/usr/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk r&| d|j›�¡|jdk rB| d|j›�¡|jdk r^| d|j›�¡d d |¡¡S)Nzstdin=zstdout=zstderr=z<{}>ú )rÚ__name__rÚappendrrÚformatÚjoin)rÚinforrrÚ__repr__s    z!SubprocessStreamProtocol.__repr__cCs®||_| d¡}|dk rDtj|j|jd�|_|j |¡|j  d¡| d¡}|dk r‚tj|j|jd�|_ |j  |¡|j  d¡| d¡}|dk rªtj ||d|jd�|_ dS)Nr©rr ér)ÚprotocolÚreaderr ) rÚget_pipe_transportrÚ StreamReaderrrrZ set_transportrr rÚ StreamWriterr)rÚ transportZstdout_transportZstderr_transportZstdin_transportrrrÚconnection_made)s, ÿ   ÿ   ýz(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6| |¡dS)Nrr&)rrZ feed_data)rÚfdÚdatar(rrrÚpipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs¸|dkrN|j}|dk r| ¡| |¡|dkr>|j d¡n |j |¡dS|dkr^|j}n|dkrn|j}nd}|dk r–|dkrŒ| ¡n | |¡||j kr¬|j   |¡|  ¡dS)Nrrr&) rÚcloseZconnection_lostrZ set_resultZ set_exceptionrrZfeed_eofrÚremoveÚ_maybe_close_transport)rr.ÚexcÚpiper(rrrÚpipe_connection_lostKs*      z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_| ¡dS)NT)rr3©rrrrÚprocess_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|jƒdkr$|jr$|j ¡d|_dS)Nr)Úlenrrrr1r7rrrr3js z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdS©N)rr)rÚstreamrrrÚ_get_close_waiteros z*SubprocessStreamProtocol._get_close_waiter) rÚ __module__Ú __qualname__rr$r-r0r6r8r3r<Ú __classcell__rrrrr s   r c@sjeZdZdd„Zdd„Zedd„ƒZdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dd„Z ddd„ZdS)ÚProcesscCs8||_||_||_|j|_|j|_|j|_| ¡|_dSr:)rZ _protocolrrrrZget_pidÚpid)rr,r'r rrrruszProcess.__init__cCsd|jj›d|j›d�S)Nú)rrrAr7rrrr$~szProcess.__repr__cCs |j ¡Sr:)rZget_returncoder7rrrÚ returncode�szProcess.returncodecÃs|j ¡IdHSr:)rZ_waitr7rrrÚwait…sz Process.waitcCs|j |¡dSr:)rÚ send_signal)rÚsignalrrrrF‰szProcess.send_signalcCs|j ¡dSr:)rÚ terminater7rrrrHŒszProcess.terminatecCs|j ¡dSr:)rÚkillr7rrrrI�sz Process.killc Ãs˜|j ¡}|j |¡|r,t d|t|ƒ¡z|j ¡IdHWn8tt fk rx}z|rht d||¡W5d}~XYnX|rŠt d|¡|j  ¡dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) rÚ get_debugrÚwriter Údebugr9ZdrainÚBrokenPipeErrorÚConnectionResetErrorr1)rÚinputrLr4rrrÚ _feed_stdin’s   ÿ  zProcess._feed_stdincÃsdSr:rr7rrrÚ_noop£sz Process._noopcÃsŒ|j |¡}|dkr|j}n|j}|j ¡rJ|dkr8dnd}t d||¡| ¡IdH}|j ¡r€|dkrndnd}t d||¡|  ¡|S)Nr&rrrz%r communicate: read %sz%r communicate: close %s) rr)rrrrJr rLÚreadr1)rr.r,r;ÚnameÚoutputrrrÚ _read_stream¦s   zProcess._read_streamNcÃsŽ|dk r| |¡}n| ¡}|jdk r2| d¡}n| ¡}|jdk rP| d¡}n| ¡}tj||||jd�IdH\}}}| ¡IdH||fS)Nrr&r ) rPrQrrUrrZgatherrrE)rrOrrrrrrÚ communicate·s      ÿzProcess.communicate)N)rr=r>rr$ÚpropertyrDrErFrHrIrPrQrUrVrrrrr@ts  r@c ‹sbˆdkrt ¡‰ntjdtdd�‡‡fdd„}ˆj||f|||dœ|—ŽIdH\}} t|| ˆƒS)NúZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r&©Ú stacklevelcs tˆˆd�S©Nr%©r rr%rrÚÖsÿz)create_subprocess_shell..©rrr)rÚget_event_loopÚwarningsÚwarnÚDeprecationWarningZsubprocess_shellr@) Úcmdrrrr rÚkwdsÚprotocol_factoryr,r'rr%rrÊs$ ýþýýr)rrrr rc �sfˆdkrt ¡‰ntjdtdd�‡‡fdd„}ˆj||f|ž|||dœ|—ŽIdH\} } t| | ˆƒS)NrXr&rYcs tˆˆd�Sr[r\rr%rrr]êsÿz(create_subprocess_exec..r^)rr_r`rarbZsubprocess_execr@) Zprogramrrrr rÚargsrdrer,r'rr%rrßs( ýþþüür)Ú__all__Ú subprocessr`ÚrrrrÚlogr ÚPIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r@Z_DEFAULT_LIMITrrrrrrÚs.     ÿbVÿ þ