grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 ”qc æã@sdZddlZejdkZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z Gdd„de ƒZGdd„deƒZGd d „d eƒZerddlZddlZddlZGd d „d ƒZn‹ddlZddlZddlZyddlZWnek r[ddlZYnXeed dƒZeedƒr‰ejZn ejZddddddddddddd dgZ er=ddlm!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(e j)ddddd d!d"d#gƒGd$d%„d%e*ƒZ+gZ,d&d'„Z-d;Z.d<Z/d=Z0d+d,„Z1d-dd.d„Z2d/d„Z3d-dd0d„Z4Gd1d„de5ƒZ6d2dd-dd3d4d5d„Z7d6d7„Z8d8d„Z9d9d„Z:e5ƒZ;Gd:d„de5ƒZ<dS)>a“Subprocesses with accessible I/O streams This module allows you to spawn processes, connect to their input/output/error pipes, and obtain their return codes. For a complete description of this module see the Python documentation. Main API ======== run(...): Runs a command, waits for it to complete, then returns a CompletedProcess instance. Popen(...): A class for flexibly executing a command in a new process Constants --------- DEVNULL: Special value that indicates that os.devnull should be used PIPE: Special value that indicates a pipe should be created STDOUT: Special value that indicates that stderr should go to stdout Older API ========= call(...): Runs a command, waits for it to complete, then returns the return code. check_call(...): Same as call() but raises CalledProcessError() if return code is not 0 check_output(...): Same as check_call() but returns the contents of stdout instead of a return code getoutput(...): Runs a command in the shell, waits for it to complete, then returns the output getstatusoutput(...): Runs a command in the shell, waits for it to complete, then returns a (status, output) tuple éNÚwin32)Ú monotonicc@seZdZdS)ÚSubprocessErrorN)Ú__name__Ú __module__Ú __qualname__©rrú//opt/alt/python35/lib64/python3.5/subprocess.pyr9s rc@s[eZdZdZdddd„Zdd„Zedd„ƒZejd d„ƒZdS) ÚCalledProcessErrorz£Raised when run() is called with check=True and the process returns a non-zero exit status. Attributes: cmd, returncode, stdout, stderr, output NcCs(||_||_||_||_dS)N)Ú returncodeÚcmdÚoutputÚstderr)Úselfr r r rrrr Ú__init__Cs   zCalledProcessError.__init__cCsd|j|jfS)Nz-Command '%s' returned non-zero exit status %d)r r )rrrr Ú__str__IszCalledProcessError.__str__cCs|jS)z+Alias for output attribute, to match stderr)r )rrrr ÚstdoutLszCalledProcessError.stdoutcCs ||_dS)N)r )rÚvaluerrr rQs) rrrÚ__doc__rrÚpropertyrÚsetterrrrr r <s  r c@s[eZdZdZdddd„Zdd„Zedd„ƒZejd d„ƒZdS) ÚTimeoutExpiredz›This exception is raised when the timeout expires while waiting for a child process. Attributes: cmd, output, stdout, stderr, timeout NcCs(||_||_||_||_dS)N)r Útimeoutr r)rr rr rrrr r_s   zTimeoutExpired.__init__cCsd|j|jfS)Nz'Command '%s' timed out after %s seconds)r r)rrrr reszTimeoutExpired.__str__cCs|jS)N)r )rrrr riszTimeoutExpired.stdoutcCs ||_dS)N)r )rrrrr rms) rrrrrrrrrrrrr rXs  rc@s.eZdZdZdZdZdZdZdS)Ú STARTUPINFOrN)rrrÚdwFlagsÚ hStdInputÚ hStdOutputÚ hStdErrorÚ wShowWindowrrrr rxs rZPIPE_BUFiÚ PollSelectorÚPopenÚPIPEÚSTDOUTÚcallÚ check_callÚgetstatusoutputÚ getoutputÚ check_outputÚrunÚDEVNULLÚCompletedProcess)ÚCREATE_NEW_CONSOLEÚCREATE_NEW_PROCESS_GROUPÚSTD_INPUT_HANDLEÚSTD_OUTPUT_HANDLEÚSTD_ERROR_HANDLEÚSW_HIDEÚSTARTF_USESTDHANDLESÚSTARTF_USESHOWWINDOWr+r,r-r.r/r0r1r2c@sLeZdZdZejdd„Zdd„Zdd„ZeZ eZ dS) ÚHandleFcCs |jsd|_||ƒdS)NT)Úclosed)rÚ CloseHandlerrr ÚClose©s  z Handle.ClosecCs,|jsd|_t|ƒStdƒ‚dS)NTzalready closed)r4ÚintÚ ValueError)rrrr ÚDetach®s   z Handle.DetachcCsd|jjt|ƒfS)Nz%s(%d))Ú __class__rr7)rrrr Ú__repr__´szHandle.__repr__N) rrrr4Ú_winapir5r6r9r;Ú__del__rrrrr r3¦s   r3c Csfx_tdd…D]M}|jdtjƒ}|dk rytj|ƒWqtk r]YqXqWdS)NÚ _deadstate)Ú_activeÚ_internal_pollÚsysÚmaxsizeÚremover8)ZinstÚresrrr Ú_cleanupÁs  rEééécCs»ddddddddd d d d d dddddi }g}xM|jƒD]?\}}ttj|ƒ}|dkrO|jd||ƒqOWx"tjD]}|jd|ƒqœW|S)znReturn a list of command-line arguments reproducing the current settings in sys.flags and sys.warnoptions.ÚdebugÚdÚoptimizeÚOÚdont_write_bytecodeÚBÚ no_user_siteÚsÚno_siteÚSÚignore_environmentÚEÚverboseÚvÚ bytes_warningÚbÚquietÚqrú-z-W)ÚitemsÚgetattrrAÚflagsÚappendÚ warnoptions)Z flag_opt_mapÚargsZflagZoptrVrrr Ú_args_from_interpreter_flagsÕs"  rbrcOsSt||Ž�=}y|jd|ƒSWn|jƒ|jƒ‚YnXWdQRXdS)zÞRun command with arguments. Wait for command to complete or timeout, then return the returncode attribute. The arguments are the same as for the Popen constructor. Example: retcode = call(["ls", "-l"]) rN)r ÚwaitÚkill)rÚ popenargsÚkwargsÚprrr r#ïs  cOsMt||Ž}|rI|jdƒ}|dkr:|d}t||ƒ‚dS)aORun command with arguments. Wait for command to complete. If the exit code was zero then return, otherwise raise CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute. The arguments are the same as for the call function. Example: check_call(["ls", "-l"]) raNr)r#Úgetr )rerfÚretcoder rrr r$s   c Osxd|krtdƒ‚d|krV|ddkrV|jddƒrLdnd|d>> check_output(["ls", "-l", "/dev/null"]) b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' The stdout argument is not allowed as it is used internally. To capture standard error in the result, use stderr=STDOUT. >>> check_output(["/bin/sh", "-c", ... "ls -l non_existent_file ; exit 0"], ... stderr=STDOUT) b'ls: non_existent_file: No such file or directory\n' There is an additional optional argument, "input", allowing you to pass a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it too will be used internally. Example: >>> check_output(["sed", "-e", "s/foo/bar/"], ... input=b"when in the course of fooman events\n") b'when in the course of barman events\n' If universal_newlines=True is passed, the "input" argument must be a string and the return value will be a string rather than bytes. rz3stdout argument not allowed, it will be overridden.ÚinputNÚuniversal_newlinesFÚórÚcheckT)r8rhr(r!r)rrerfrrr r's  "c@s@eZdZdZdddd„Zdd„Zdd„ZdS) r*aEA process that has finished running. This is returned by run(). Attributes: args: The list or str args passed to run(). returncode: The exit code of the process, negative for signals. stdout: The standard output (None if not captured). stderr: The standard error (None if not captured). NcCs(||_||_||_||_dS)N)rar rr)rrar rrrrr rJs   zCompletedProcess.__init__cCs–dj|jƒdj|jƒg}|jdk rL|jdj|jƒƒ|jdk rt|jdj|jƒƒdjt|ƒjdj|ƒƒS)Nz args={!r}zreturncode={!r}z stdout={!r}z stderr={!r}z{}({})z, ) Úformatrar rr_rÚtyperÚjoin)rrarrr r;PszCompletedProcess.__repr__cCs.|jr*t|j|j|j|jƒ‚dS)z6Raise CalledProcessError if the exit code is non-zero.N)r r rarr)rrrr Úcheck_returncodeYs z!CompletedProcess.check_returncode)rrrrrr;rrrrrr r*?s  rjrnFc Os|dk r.d|kr$tdƒ‚t|d>> import subprocess >>> subprocess.getstatusoutput('ls /bin/ls') (0, '/bin/ls') >>> subprocess.getstatusoutput('cat /bin/junk') (256, 'cat: /bin/junk: No such file or directory') >>> subprocess.getstatusoutput('/bin/junk') (256, 'sh: /bin/junk: not found') ÚshellTrkrrNrFÚ éÿÿÿÿrƒ)r'r"r r r )r ÚdataZstatusZexrrr r%Ûs  cCst|ƒdS)a%Return output (stdout or stderr) of executing cmd in a shell. Like getstatusoutput(), except the exit status is ignored and the return value is a string containing the command's output. Example: >>> import subprocess >>> subprocess.getoutput('ls /bin/ls') '/bin/ls' rF)r%)r rrr r&øs c@s5eZdZdZdZd>dddddeddddddddfdd„Zd d „Zd d „Zd d„Z e j dd„Z dd„Z dd„Zdddd„Zdd„Zdd„Zdd„Zerndd„Zdd „Zd!d"„Zdejejejd#d$„Zddd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Z e Z!nÃd/d„Zd0d"„Ze"j#e"j$e"j%e"j&e"j'e"j(d1d2„Z)de"j*e"j+e,j-d3d$„Zd4d5„Z.ddd6d&„Zd7d*„Zd8d9„Z/d:d,„Zd;d.„Z d<d=„Z!dS)?r a Execute a child program in a new process. For a complete description of the arguments see the Python documentation. Arguments: args: A string, or a sequence of program arguments. bufsize: supplied as the buffering argument to the open() function when creating the stdin/stdout/stderr pipe file objects executable: A replacement program to execute. stdin, stdout and stderr: These specify the executed programs' standard input, standard output and standard error file handles, respectively. preexec_fn: (POSIX only) An object to be called in the child process just before the child is executed. close_fds: Controls closing or inheriting of file descriptors. shell: If true, the command will be executed through the shell. cwd: Sets the current directory before the child is executed. env: Defines the environment variables for the new process. universal_newlines: If true, use universal line endings for file objects stdin, stdout and stderr. startupinfo and creationflags (Windows only) restore_signals (POSIX only) start_new_session (POSIX only) pass_fds (POSIX only) Attributes: stdin, stdout, stderr, pid, returncode FrFNrTcCs@tƒtjƒ|_d|_d|_|dkr:d}t|tƒsUtdƒ‚t rÖ|dk rst dƒ‚|dk p”|dk p”|dk }|t kr»|r²d}qÓd}q;|r;|r;t dƒ‚ne|t krèd}|r | r t j dtƒd}| dk r#t d ƒ‚|d kr;t d ƒ‚||_d|_d|_d|_d|_d|_| |_|j|||ƒ\}}}}}}t r|dkrËtj|jƒd ƒ}|dkrïtj|jƒd ƒ}|dkrtj|jƒd ƒ}|dkrdtj|d |ƒ|_| rdtj|jd dd|dkƒ|_|dkr£tj|d|ƒ|_| r£tj|jƒ|_|dkrâtj|d|ƒ|_| râtj|jƒ|_d|_yD|j|||||| | | || ||||||||ƒWn xLtd|j|j|jfƒD])}y|j ƒWqWt!k rYqWXqWW|js4g}|t"kr¬|j#|ƒ|t"krÅ|j#|ƒ|t"krÞ|j#|ƒt$|dƒrý|j#|j%ƒx4|D],}yt&j |ƒWqt!k r/YqXqW‚YnXdS)zCreate new Popen instance.NFrFzbufsize must be an integerz0preexec_fn is not supported on Windows platformsTzSclose_fds is not supported on Windows platforms if you redirect stdin/stdout/stderrzpass_fds overriding close_fds.z2startupinfo is only supported on Windows platformsrz4creationflags is only supported on Windows platformsÚwbZ write_throughÚline_bufferingÚrbÚ_devnullrƒrƒrƒrƒrƒrƒrƒ)'rEÚ threadingZLockÚ _waitpid_lockÚ_inputÚ_communication_startedÚ isinstancer7Ú TypeErrorÚ _mswindowsr8Ú_PLATFORM_DEFAULT_CLOSE_FDSÚwarningsÚwarnÚRuntimeWarningrarsrrÚpidr rkÚ _get_handlesÚmsvcrtZopen_osfhandler9ÚioÚopenÚ TextIOWrapperÚ_closed_child_pipe_fdsÚ_execute_childÚfilterÚcloseÚOSErrorr!r_ÚhasattrrˆÚos)rraÚbufsizeÚ executablersrrÚ preexec_fnÚ close_fdsr�ÚcwdÚenvrkÚ startupinfoÚ creationflagsÚrestore_signalsÚstart_new_sessionÚpass_fdsZ any_stdio_setÚp2creadÚp2cwriteÚc2preadÚc2pwriteÚerrreadÚerrwriteÚfZto_closeÚfdrrr r3s°                         '         (            zPopen.__init__cCs+|j|ƒ}|jddƒjddƒS)Nz r‚ú )ÚdecodeÚreplace)rr„Úencodingrrr Ú_translate_newlinesÀszPopen._translate_newlinescCs|S)Nr)rrrr Ú __enter__ÄszPopen.__enter__c CsX|jr|jjƒ|jr,|jjƒz|jrE|jjƒWd|jƒXdS)N)rr�rrsrc)rrprÚ tracebackrrr Ú__exit__Çs     zPopen.__exit__cCsI|js dS|jd|ƒ|jdkrEtdk rEtj|ƒdS)Nr>)Ú_child_createdr@r r?r_)rZ_maxsizerrr r=Ós  z Popen.__del__cCs1t|dƒs*tjtjtjƒ|_|jS)Nrˆ)rŸr r˜ÚdevnullÚO_RDWRrˆ)rrrr Ú _get_devnullÝszPopen._get_devnullcCsÑ|rky|jj|ƒWnNtk r.Yn=tk rj}z|jtjkrUn‚WYdd}~XnXy|jjƒWnNtk r�Yn=tk rÌ}z|jtjkr·n‚WYdd}~XnXdS)N)rsÚwriteÚBrokenPipeErrorržÚerrnoZEINVALr�)rrjÚexcrrr Ú _stdin_writeâs"  zPopen._stdin_writec CsJ|jr|rtdƒ‚|dkr×|j r×|j|j|jgjdƒdkr×d}d}|jr}|j|ƒnM|jr¥|jjƒ}|jjƒn%|jrÊ|jjƒ}|jjƒ|j ƒni|dk rót ƒ|}nd}z|j |||ƒ\}}Wdd|_X|j d|j |ƒƒ}||fS)a4Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional "input" argument should be data to be sent to the child process (if self.universal_newlines is True, this should be a string; if it is False, "input" should be bytes), or None, if no data should be sent to the child. communicate() returns a tuple (stdout, stderr). These will be bytes or, if self.universal_newlines was True, a string. z.Cannot send input after starting communicationNrGTr) rŒr8rsrrÚcountrÄÚreadr�rcÚ_timeÚ _communicateÚ_remaining_time)rrjrrrÚendtimeÚstsrrr rtûs. '       zPopen.communicatecCs |jƒS)zSCheck if child process has terminated. Set and return returncode attribute.)r@)rrrr ru,sz Popen.pollcCs|dkrdS|tƒSdS)z5Convenience for _communicate when computing timeouts.N)rÇ)rrÊrrr rÉ2s zPopen._remaining_timecCs5|dkrdStƒ|kr1t|j|ƒ‚dS)z2Convenience for checking if a timeout has expired.N)rÇrra)rrÊÚ orig_timeoutrrr Ú_check_timeout:s zPopen._check_timeoutc CsŒ|dkr(|dkr(|dkr(d Sd \}}d\}}d\}} |dkrªtjtjƒ}|dkrDtjddƒ\}} t|ƒ}tj| ƒnš|tkrêtjddƒ\}}t|ƒt|ƒ}}nZ|tkrtj |j ƒƒ}n6t |t ƒr/tj |ƒ}ntj |j ƒƒ}|j|ƒ}|dkr±tjtjƒ}|dkrKtjddƒ\} }t|ƒ}tj| ƒnš|tkrñtjddƒ\}}t|ƒt|ƒ}}nZ|tkrtj |j ƒƒ}n6t |t ƒr6tj |ƒ}ntj |j ƒƒ}|j|ƒ}|dkr¸tjtjƒ} | dkrgtjddƒ\} } t| ƒ} tj| ƒn¯|tkrøtjddƒ\}} t|ƒt| ƒ}} no|tkr |} nZ|tkr1tj |j ƒƒ} n6t |t ƒrRtj |ƒ} ntj |j ƒƒ} |j| ƒ} |||||| fS)z|Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite NrFrrƒrƒrƒrƒrƒrƒ)rƒrƒrƒrƒrƒrƒrƒrƒ)rƒrƒrƒrƒ)rƒrƒrƒrƒ)rƒrƒ)r<Z GetStdHandler-Z CreatePiper3r5r!r)r–Z get_osfhandler¿r�r7ÚfilenoÚ_make_inheritabler.r/r") rrsrrr¬r­r®r¯r°r±Ú_rrr r•Fsn$                    zPopen._get_handlescCs7tjtjƒ|tjƒddtjƒ}t|ƒS)z2Return a duplicate of handle, which is inheritablerrF)r<ZDuplicateHandleZGetCurrentProcessZDUPLICATE_SAME_ACCESSr3)rZhandleÚhrrr rÏŽs   zPopen._make_inheritablecCs¥| stdƒ‚t|tƒs.t|ƒ}|dkrCtƒ}d | ||fkr…|jtjO_| |_||_ ||_ | rÐ|jtj O_tj |_ tjjddƒ}dj||ƒ}z>tj||ddt| ƒ| |||ƒ \}}}}Wd| d kr'| jƒ|d kr=|jƒ|d krS|jƒt|dƒrrtj|jƒXd|_t|ƒ|_||_tj|ƒdS) z$Execute program (MS Windows version)z"pass_fds not supported on Windows.NrFZCOMSPECzcmd.exez {} /c "{}"rˆTrƒrƒrƒrƒ)ÚAssertionErrorr�Ústrr€rrr<r1rrrr2r0rr ÚenvironrhroZ CreateProcessr7r6rŸr�rˆr¼r3Ú_handler”r5)rrar¢r£r¤r«r¥r¦r§r¨r�r¬r­r®r¯r°r±Zunused_restore_signalsZunused_start_new_sessionZcomspecZhpZhtr”Útidrrr r›—sF                  zPopen._execute_childcCs@|jdkr9||jdƒ|kr9||jƒ|_|jS)zÎCheck if child process has terminated. Returns returncode attribute. This method is called by __del__, so it can only refer to objects in its local scope. Nr)r rÕ)rr>Z_WaitForSingleObjectZ_WAIT_OBJECT_0Z_GetExitCodeProcessrrr r@Ôs zPopen._internal_pollcCs¤|dk r|j|ƒ}|dkr3tj}nt|dƒ}|jdkr�tj|j|ƒ}|tjkrˆt|j |ƒ‚tj |jƒ|_|jS)zOWait for child process to terminate. Returns returncode attribute.Niè) rÉr<ZINFINITEr7r ÚWaitForSingleObjectrÕZ WAIT_TIMEOUTrraÚGetExitCodeProcess)rrrÊZtimeout_millisr}rrr rcås     z Popen.waitcCs!|j|jƒƒ|jƒdS)N)r_rÆr�)rZfhÚbufferrrr Ú _readerthread÷szPopen._readerthreadcCsò|jret|dƒ reg|_tjd|jd|j|jfƒ|_d|j_|jjƒ|j rÊt|dƒ rÊg|_ tjd|jd|j |j fƒ|_ d|j _|j jƒ|j rà|j |ƒ|jdk r)|jj|j|ƒƒ|jjƒr)t|j|ƒ‚|j dk rr|j j|j|ƒƒ|j jƒrrt|j|ƒ‚d}d}|jr�|j}|jjƒ|j r¼|j }|j jƒ|dk rÒ|d}|dk rè|d}||fS)NÚ _stdout_buffÚtargetraTÚ _stderr_buffr)rrŸrÛr‰ZThreadrÚZ stdout_threadZdaemonÚstartrrÝZ stderr_threadrsrÄrqrÉZis_aliverrar�)rrjrÊrÌrrrrr rÈüsF                  zPopen._communicatecCs˜|jdk rdS|tjkr/|jƒne|tjkrWtj|jtjƒn=|tjkrtj|jtjƒnt dj |ƒƒ‚dS)zSend a signal to the process.NzUnsupported signal: {}) r ÚsignalÚSIGTERMÚ terminateZ CTRL_C_EVENTr rdr”ZCTRL_BREAK_EVENTr8ro)rÚsigrrr Ú send_signal0s zPopen.send_signalc Csp|jdk rdSytj|jdƒWn?tk rktj|jƒ}|tjkr^‚||_YnXdS)zTerminates the process.NrF)r r<ZTerminateProcessrÕÚPermissionErrorrØZ STILL_ACTIVE)rÚrcrrr rá>s zPopen.terminatec Csºd\}}d\}}d \}} |dkr3n`|tkrTtjƒ\}}n?|tkro|jƒ}n$t|tƒr‡|}n |jƒ}|dkr¢n`|tkrÃtjƒ\}}n?|tkrÞ|jƒ}n$t|tƒrö|}n |jƒ}|dkrn“|tkr2tjƒ\}} nr|tkre|d krS|} q¤t j jƒ} n?|tkr€|jƒ} n$t|tƒr˜|} n |jƒ} |||||| fS) z|Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite rFNrƒrƒ)rƒrƒrƒrƒ)rƒrƒrƒrƒ)rƒrƒrƒ) r!r Úpiper)r¿r�r7rÎr"rAÚ __stdout__) rrsrrr¬r­r®r¯r°r±rrr r•SsJ                     c&"s»t|ttfƒr!|g}n t|ƒ}| rSddg|}ˆrSˆ|d<ˆdkri|d‰ˆ}tjƒ\}}g}x,|dkrµ|j|ƒtj|ƒ}qŠWx|D]}tj|ƒq½WzqzO|dk rQg}xh|j ƒD]Q\}}tj |ƒ}d|kr,t dƒ‚|j|dtj |ƒƒqùWnd}tj ˆƒ‰tj j ˆƒr„ˆf}n(t‡fdd †tj|ƒDƒƒ}t|ƒ}|j|ƒtj|||tttt|ƒƒƒ||| | | ||||||||ƒ|_d |_Wdtj|ƒXt|d dƒ}| dkrz| dkrz| |krztj| ƒ|dkr«| dkr«||kr«tj|ƒ|dkrÜ|dkrÜ||krÜtj|ƒ|dk rõtj|ƒd |_tƒ}x:tj|d ƒ}||7}| s?t|ƒd kr Pq WWdtj|ƒX|r·ytj|jdƒWntk r‡YnXy|j ddƒ\} }!}"Wn.t k r×d} d}!dt!|ƒ}"YnXtt"| j#dƒt$ƒ}#|"j#ddƒ}"t%|#t&ƒr«|!r«t|!dƒ}$|"dk}%|%rAd}"|$dkrœtj'|$ƒ}"|$t(j)krœ|%rˆ|"dt!|ƒ7}"n|"dt!|ƒ7}"|#|$|"ƒ‚|#|"ƒ‚dS) zExecute program (POSIX version)z/bin/shz-crNrHó=z!illegal environment variable namec3s-|]#}tjjtj|ƒˆƒVqdS)N)r ÚpathrqÚfsencode)Ú.0Údir)r¢rr ú Ász'Popen._execute_child..TrˆrFiPÃó:rGsSubprocessErroró0sBad exception data from child: ÚasciiÚerrorsÚ surrogatepasséZnoexecrlz: rƒrƒrƒrƒrƒrƒ)*r�rÓÚbytesÚlistr rær_Údupr�r\rêr8réÚdirnameÚtupleÚ get_exec_pathÚsetÚaddÚ_posixsubprocessZ fork_execÚsortedÚmapr7r”r¼r]ršÚ bytearrayrÆrzÚwaitpidÚChildProcessErrorÚsplitÚreprÚbuiltinsrµrÚ issubclassržÚstrerrorrÂÚENOENT)&rrar¢r£r¤r«r¥r¦r§r¨r�r¬r­r®r¯r°r±r©rªZorig_executableZ errpipe_readZ errpipe_writeZlow_fds_to_closeZlow_fdZenv_listÚkrVZexecutable_listZ fds_to_keepZ devnull_fdZ errpipe_dataÚpartZexception_nameZ hex_errnoZerr_msgZchild_exception_typeZ errno_numZchild_exec_never_calledr)r¢r r›‰s¶           %     $ $ $            cCsl||ƒr||ƒ |_nI||ƒr=||ƒ|_n+||ƒr\||ƒ |_n tdƒ‚dS)z:All callers to this function MUST hold self._waitpid_lock.zUnknown child exit status!N)r r)rrËZ _WIFSIGNALEDZ _WTERMSIGZ _WIFEXITEDZ _WEXITSTATUSZ _WIFSTOPPEDZ _WSTOPSIGrrr Ú_handle_exitstatus s   zPopen._handle_exitstatuscCsç|jdkrà|jjdƒs%dSzªyN|jdk rA|jS||j|ƒ\}}||jkru|j|ƒWnUtk rÍ}z5|dk r£||_n|j|kr»d|_WYdd}~XnXWd|jjƒX|jS)zõCheck if child process has terminated. Returns returncode attribute. This method is called by __del__, so it cannot reference anything outside of the local scope (nor can any methods it calls). NFr)r rŠÚacquirer”r ržrÂÚrelease)rr>Z_waitpidZ_WNOHANGZ_ECHILDr”rËÚerrr r@s    c CsMytj|j|ƒ\}}Wn!tk rB|j}d}YnX||fS)z:All callers to this function MUST hold self._waitpid_lock.r)r rr”r)rZ wait_flagsr”rËrrr Ú _try_waitBs    zPopen._try_waitc CsÍ|jdk r|jS|dk s.|dk re|dkrJtƒ|}n|dkre|j|ƒ}|dk r^d}xL|jjdƒrzj|jdk rŸP|jtjƒ\}}||jksØ|dksØt ‚||jkrõ|j |ƒPWd|jj ƒX|j|ƒ}|dkr4t |j |ƒ‚t|d|dƒ}tj|ƒqzWnhxe|jdkrÅ|j�F|jdk rŠP|jdƒ\}}||jkr»|j |ƒWdQRXqaW|jS)zOWait for child process to terminate. Returns returncode attribute.Ngü©ñÒMb@?FrrGgš™™™™™©?)r rÇrÉrŠr rr ÚWNOHANGr”rÒr r rraÚminÚtimeZsleep)rrrÊZdelayr”rËZ remainingrrr rcOsB   !   c#CsÐ|jre|j rey|jjƒWntk r8YnX|sey|jjƒWntk rdYnXd}d}|jsµi|_|jrœg|j|j<|jrµg|j|j<|jrÎ|j|j}|jrç|j|j}|j|ƒ|j r t |j ƒ}t ƒ�}|jr=|r=|j |jt jƒ|jr\|j |jt jƒ|jr{|j |jt jƒx¡|jƒr|j|ƒ}|dk rÃ|dkrÃt|j|ƒ‚|j|ƒ} |j||ƒx6| D].\} } | j|jkr­||j|jt…} y"|jtj| j| ƒ7_Wn/tk rt|j| jƒ| jjƒYqX|jt|j ƒkr|j| jƒ| jjƒqé| j|j|jfkrétj| jdƒ} | s|j| jƒ| jjƒ|j| jj| ƒqéWq~WWdQRX|j d|j|ƒƒ|dk rZdj!|ƒ}|dk rudj!|ƒ}|j"rÆ|dk r¢|j#||jj$ƒ}|dk rÆ|j#||jj$ƒ}||fS)Nri€rrm)%rsrŒÚflushrÁr�Z_fileobj2outputrrÚ _save_inputr‹Ú memoryviewÚ_PopenSelectorÚregisterÚ selectorsZ EVENT_WRITEZ EVENT_READZget_maprÉrraÚselectrÍZfileobjÚ _input_offsetÚ _PIPE_BUFr rÀr³Z unregisterrzrÆr_rcrqrkr¸r·)rrjrÊrÌrrZ input_viewZselectorrZreadyÚkeyZeventsÚchunkr„rrr rÈ€sŠ              "  &       cCs^|jrZ|jdkrZd|_||_|jrZ|dk rZ|jj|jjƒ|_dS)Nr)rsr‹rrkÚencoder·)rrjrrr rßs   zPopen._save_inputcCs&|jdkr"tj|j|ƒdS)zSend a signal to the process.N)r r rdr”)rrârrr rãêscCs|jtjƒdS)z/Terminate the process with SIGTERM N)rãrßrà)rrrr ráðscCs|jtjƒdS)z*Kill the process with SIGKILL N)rãrßÚSIGKILL)rrrr rdõsz Popen.killrƒ)0rrrrr¼r�rr¸r¹r»rArBr=r¿rÄrtrurÉrÍr�r•rÏr›r<r×Z WAIT_OBJECT_0rØr@rcrÚrÈrãrárdr Ú WIFSIGNALEDÚWTERMSIGÚ WIFEXITEDÚ WEXITSTATUSÚ WIFSTOPPEDÚWSTOPSIGr rrrÂZECHILDrrrrrr r s` (  ‡     1    H =  4    6 „   " 1 _  rƒéþÿÿÿéýÿÿÿ)=rrAÚplatformr�r—r rrßrr‘rÂrrÇÚ Exceptionrr rr‰r–r<rrürrÚ ImportErrorZdummy_threadingr]rrŸrrZSelectSelectorÚ__all__r+r,r-r.r/r0r1r2r{r7r3r?rEr!r"r)rbr#r$r'Úobjectr*r(r€r%r&r�r rrrr Ú*sn                 :     ,!2 I