o ?OgK@spdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z ddl Z zddlZWn eyEdZYnwgdZz ddlZddlZdZWneymdZddlZddlZddlZYn0wddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)e*gdGd d d e+Z,Gd d d e,Z-Gd dde,Z.erGdddZ/Gddde0Z1ne2eddZ3e4edrej5Z6nej7Z6erdZ8ddZ9ngZ8ddZ9dZ:dZ;dZdd d!d"Z?d#d$Z@dd d%d&ZAGd'd(d(eBZCddddd)d*d+ZDd,d-ZEd.d/ZFd0d1ZGd2d3ZHeHZIdZJGd4d5d5ZKdS)6aSubprocesses 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 (exitcode, output) tuple N) monotonic)PopenPIPESTDOUTcall check_callgetstatusoutput getoutput check_outputrunCalledProcessErrorDEVNULLSubprocessErrorTimeoutExpiredCompletedProcessTF)CREATE_NEW_CONSOLECREATE_NEW_PROCESS_GROUPSTD_INPUT_HANDLESTD_OUTPUT_HANDLESTD_ERROR_HANDLESW_HIDESTARTF_USESTDHANDLESSTARTF_USESHOWWINDOWABOVE_NORMAL_PRIORITY_CLASSBELOW_NORMAL_PRIORITY_CLASSHIGH_PRIORITY_CLASSIDLE_PRIORITY_CLASSNORMAL_PRIORITY_CLASSREALTIME_PRIORITY_CLASSCREATE_NO_WINDOWDETACHED_PROCESSCREATE_DEFAULT_ERROR_MODECREATE_BREAKAWAY_FROM_JOB)rrrrrrrr STARTUPINFOrrrrrrrr r!r"c@s eZdZdS)rN)__name__ __module__ __qualname__r'r'1/opt/alt/python310/lib64/python3.10/subprocess.pyres rc@<eZdZdZd ddZddZeddZejd dZdS) r zRaised when run() is called with check=True and the process returns a non-zero exit status. Attributes: cmd, returncode, stdout, stderr, output NcC||_||_||_||_dSN) returncodecmdoutputstderr)selfr,r-r.r/r'r'r(__init__o zCalledProcessError.__init__cCs`|jr(|jdkr(z d|jt|j fWSty'd|j|j fYSwd|j|jfS)NrzCommand '%s' died with %r.z)Command '%s' died with unknown signal %d.z.Command '%s' returned non-zero exit status %d.)r,r-signalZSignals ValueErrorr0r'r'r(__str__us   zCalledProcessError.__str__cC|jS)z+Alias for output attribute, to match stderrr.r5r'r'r(stdoutszCalledProcessError.stdoutcC ||_dSr+r8r0valuer'r'r(r9 NN r$r%r&__doc__r1r6propertyr9setterr'r'r'r(r hs  r c@r)) rzThis exception is raised when the timeout expires while waiting for a child process. Attributes: cmd, output, stdout, stderr, timeout NcCr*r+)r-timeoutr.r/)r0r-rCr.r/r'r'r(r1r2zTimeoutExpired.__init__cCsd|j|jfS)Nz'Command '%s' timed out after %s seconds)r-rCr5r'r'r(r6s zTimeoutExpired.__str__cCr7r+r8r5r'r'r(r9szTimeoutExpired.stdoutcCr:r+r8r;r'r'r(r9r=r>r?r'r'r'r(rs  rc@s,eZdZdddddddddZddZdS)r#rNdwFlags hStdInput hStdOutput hStdError wShowWindowlpAttributeListcCs0||_||_||_||_||_|pdgi|_dS)N handle_listrD)r0rErFrGrHrIrJr'r'r(r1s zSTARTUPINFO.__init__cCs@|j}d|vrt|d|d<t|j|j|j|j|j|dS)NrKrD) rJcopylistr#rErFrGrHrI)r0Z attr_listr'r'r(rLs zSTARTUPINFO.copy)r$r%r&r1rLr'r'r'r(r#s  r#c@s2eZdZdZejfddZddZddZeZ dS) HandleFcCs|js d|_||dSdS)NT)closed)r0 CloseHandler'r'r(Closes z Handle.ClosecCs|js d|_t|Std)NTzalready closed)rOintr4r5r'r'r(Detachsz Handle.DetachcCsd|jjt|fS)Nz%s(%d)) __class__r$rRr5r'r'r(__repr__szHandle.__repr__N) r$r%r&rO_winapirPrQrSrU__del__r'r'r'r(rNs rNZPIPE_BUFi PollSelectorcCsdSr+r'r'r'r'r(_cleanuprYc CsZtdurdStddD]}|jtjd}|dur*zt|Wq ty)Yq wq dS)N _deadstate)_active_internal_pollsysmaxsizeremover4)instresr'r'r(rYs cCs*g}tjj}|dkr|dd||S)zgReturn a list of command-line arguments reproducing the current optimization settings in sys.flags.r-O)r_flagsoptimizeappend)argsr<r'r'r("_optim_args_from_interpreter_flags s rmc CsNddddddd}t}|D]\}}ttj|}|dkr'|d ||qtjjr2|d ntjjr;|d tjjrD|d tj d d }tjj }ttdi}d|v}|dkrc| dn|rj| d|rq| d|D] }|d|qs|r| ddD]}||vr||} | dur|} nd|| f} | d| fq|S)z}Return a list of command-line arguments reproducing the current settings in sys.flags, sys.warnoptions and sys._xoptions.dBSvbq)debugdont_write_bytecodeno_siteverbose bytes_warningquietrrgz-Iz-Ez-sN _xoptionsdevzerror::BytesWarningzdefault::BytesWarningdefaultz-W)-Xr{)Z faulthandler tracemallocZ importtimeZ showrefcountutf8Tz%s=%sr~) rmitemsgetattrr_rirkisolatedignore_environment no_user_site warnoptionsrxraextend) Z flag_opt_maprlflagoptrqZwarnoptsrxZxoptionsdev_moder<argr'r'r(_args_from_interpreter_flagssT           rrCcOsRt|i|}z|j|dWWdS|1s"wYdS)zRun 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)rwaitkill)rC popenargskwargspr'r'r(rQs rcOs:t|i|}|r|d}|dur|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"]) rlNr)rgetr )rrretcoder-r'r'r(rbs   rcOsvd|vrtdd|vr/|ddur/|ds&|ds&|ds&|dr)d }nd }||d<t|t|d d |jS) aRun command with arguments and return its output. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen constructor. Example: >>> 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' By default, all communication is in bytes, and therefore any "input" should be bytes, and the return value will be bytes. If in text mode, any "input" should be a string, and the return value will be a string decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. r9z3stdout argument not allowed, it will be overridden.inputNuniversal_newlinestextencodingerrorsT)r9rCcheck)r4rr rr9)rCrremptyr'r'r(r us#r c@s4eZdZdZd ddZddZeejZ ddZ dS) raEA 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). NcCr*r+)rlr,r9r/)r0rlr,r9r/r'r'r(r1r2zCompletedProcess.__init__cCshd|jd|jg}|jdur|d|j|jdur(|d|jdt|jd|S)Nz args={!r}zreturncode={!r}z stdout={!r}z stderr={!r}z{}({})z, ) formatrlr,r9rkr/typer$join)r0rlr'r'r(rUs    zCompletedProcess.__repr__cCs |jrt|j|j|j|jdS)z6Raise CalledProcessError if the exit code is non-zero.N)r,r rlr9r/r5r'r'r(check_returncodes z!CompletedProcess.check_returncoder>) r$r%r&r@r1rU classmethodtypes GenericAlias__class_getitem__rr'r'r'r(rs   r)rcapture_outputrCrc Os$|dur|ddurtdt|d<|r/|ddus#|ddur'tdt|d<t|d<t|i|L}z |j||d\}}Wn'tyb} z|trY|\| _| _ | d} ~ w|| } |r{| r{t | |j ||dWdn1swYt|j | ||S) a|Run command with arguments and return a CompletedProcess instance. The returned instance will have attributes args, returncode, stdout and stderr. By default, stdout and stderr are not captured, and those attributes will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them, or pass capture_output=True to capture both. If check is True and the exit code was non-zero, it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute, and output & stderr attributes if those streams were captured. If timeout is given, and the process takes too long, a TimeoutExpired exception will be raised. There is an optional argument "input", allowing you to pass bytes or 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 will be used internally. By default, all communication is in bytes, and therefore any "input" should be bytes, and the stdout and stderr will be bytes. If in text mode, any "input" should be a string, and stdout and stderr will be strings decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. The other arguments are the same as for the Popen constructor. Nstdinz/stdin and input arguments may not both be used.r9r/z@stdout and stderr arguments may not be used with capture_output.rr.r/)rr4rr communicaterr _mswindowsr9r/rpollr rlr) rrrCrrrZprocessr9r/excrr'r'r(r s>r cCsg}d}ttj|D]d}g}|r|dd|vpd|vp| }|r'|d|D]1}|dkr5||q)|dkrL|dt|dg}|dq)|rU||g}||q)|rb|||rn|||dq d|S) a Translate a sequence of arguments into a command line string, using the same rules as the MS C runtime: 1) Arguments are delimited by white space, which is either a space or a tab. 2) A string surrounded by double quotation marks is interpreted as a single argument, regardless of white space contained within. A quoted string can be embedded in an argument. 3) A double quotation mark preceded by a backslash is interpreted as a literal double quotation mark. 4) Backslashes are interpreted literally, unless they immediately precede a double quotation mark. 5) If backslashes immediately precede a double quotation mark, every pair of backslashes is interpreted as a literal backslash. If the number of backslashes is odd, the last backslash escapes the next double quotation mark as described in rule 3. F  "\z\"r)maposfsdecoderklenrr)seqresultZ needquoterZbs_bufcr'r'r( list2cmdlines6          rc Csnz t|ddtd}d}Wnty$}z |j}|j}WYd}~nd}~ww|dddkr3|dd}||fS)aReturn (exitcode, output) of executing cmd in a shell. Execute the string 'cmd' in a shell with 'check_output' and return a 2-tuple (status, output). The locale encoding is used to decode the output and process newlines. A trailing newline is stripped from the output. The exit status for the command can be interpreted according to the rules for the function 'wait'. Example: >>> import subprocess >>> subprocess.getstatusoutput('ls /bin/ls') (0, '/bin/ls') >>> subprocess.getstatusoutput('cat /bin/junk') (1, 'cat: /bin/junk: No such file or directory') >>> subprocess.getstatusoutput('/bin/junk') (127, 'sh: /bin/junk: not found') >>> subprocess.getstatusoutput('/bin/kill $$') (-15, '') T)shellrr/rNrd )r rr r.r,)r-dataZexitcodeZexr'r'r(r\s rcCs t|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' r|)r)r-r'r'r(r {s r c Cststtds dStjdvrdSzZ.d?d/Z"e/j0e/j1e/j2fd@dAZ3de/j4e/j5e6j7fdBd1Z'dCdDZ8dEd3Z(dFd7Z*dGdHZ9dId9Z+dJd;Z,dKdLZ-dS)QraP 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. text: If true, decode stdin, stdout and stderr using the given encoding (if set) or the system default otherwise. universal_newlines: Alias of text, provided for backwards compatibility. startupinfo and creationflags (Windows only) restore_signals (POSIX only) start_new_session (POSIX only) group (POSIX only) extra_groups (POSIX only) user (POSIX only) umask (POSIX only) pass_fds (POSIX only) encoding and errors: Text mode encoding and error handling to use for file objects stdin, stdout and stderr. Attributes: stdin, stdout, stderr, pid, returncode FrdNTrr')usergroup extra_groupsrrrumaskpipesizec+Cstt|_d|_d|_|durd}t|tstd|dur#d}t|ts,tdt r7|dur6t dn|rC|sCt dt d}| durKt d |d krSt d ||_d|_d|_d|_d|_d|_||_||_||_|dur| durt| t|krtd ||||\}}}}}}t r|dkrt|d }|dkrt|d }|dkrt|d }|p|p|p| |_|jr|durd |_}d|_d|_|jr|dkrd} d}nd} d}!|dur,t t!dst dt|t"rzd dl#}"Wn t$yt dw|"%|j&}!nt|tr|}!n td't(||!d kr,t d|!d}#|durt t!ds=t dt|t"rGt dg}#|D];}$t|$t"rqzd dl#}"Wn t$yet dw|#)|"%|$j&qKt|$tr~|#)|$qKtd't(|$|#D]}%|%d krt d|%qd}&|durt t!dst dt|t"rzd dl*}'Wn t$yt dw|'+|j,}&n t|tr|}&ntd|&d krt d|&zp|dkrt-.|d||_|jrt-j/|jd| ||d |_|dkrt-.|d!||_|jrt-j/|j||d"|_|dkr7t-.|d!||_|jr7t-j/|j||d"|_|0|||||| | | || ||||||||!|#|&||WdSt1d|j|j|jfD]}(z|(2Wqbt3yvYqbw|jsg})|t4kr|))||t4kr|))||t4kr|))|t |d#r|))|j5|)D]#}*zt rt|*t6r|*7nt!2|*Wqt3yYqw)$zCreate new Popen instance.NFrdzbufsize must be an integerzpipesize must be an integerz0preexec_fn is not supported on Windows platformszpass_fds overriding close_fds.Tz2startupinfo is only supported on Windows platformsrz4creationflags is only supported on Windows platformszlCannot disambiguate when both text and universal_newlines are supplied but different. Pass one or the other.localeg?r|setregidz>The 'group' parameter is not supported on the current platformzHThe group parameter cannot be a string on systems without the grp modulez,Group must be a string or an integer, not {}z!Group ID cannot be negative, got setgroupszEThe 'extra_groups' parameter is not supported on the current platformz#Groups must be a list, not a stringzIItems in extra_groups cannot be strings on systems without the grp modulez9Items in extra_groups must be a string or integer, not {}setreuidz=The 'user' parameter is not supported on the current platformzGThe user parameter cannot be a string on systems without the pwd modulez#User must be a string or an integerz User ID cannot be negative, got wb) write_throughline_bufferingrrrb)rr_devnull)8rY threadingZLock _waitpid_lock_input_communication_started isinstancerR TypeErrorrr4warningswarnRuntimeWarningrlrr9r/pidr,rrrboolr _get_handlesmsvcrtZopen_osfhandlerS text_mode_sigint_wait_secs_closed_child_pipe_fdsrrstrgrp ImportErrorZgetgrnamZgr_gidrrrkpwdgetpwnamZpw_uidioopen TextIOWrapper_execute_childfiltercloserrrrNrQ)+r0rlbufsize executablerr9r/ preexec_fn close_fdsrcwdenvr startupinfo creationflagsrestore_signalsstart_new_sessionpass_fdsrrrrrrrrp2creadp2cwritec2preadc2pwriteerrreaderrwritergidrgidsZ extra_groupZ gid_checkuidrfZto_closefdr'r'r(r1sV                                            zPopen.__init__cCs@d|jjd|jd|jd}t|dkr|ddd}|S)NPLz...>)rTr$r,rlr)r0Zobj_reprr'r'r(rUs  zPopen.__repr__cCr7r+)rr5r'r'r(rszPopen.universal_newlinescCst||_dSr+)rr)r0rr'r'r(rscCs |||}|ddddS)Nz r )decodereplace)r0rrrr'r'r(_translate_newliness zPopen._translate_newlinescCs|Sr+r'r5r'r'r( __enter__ rZzPopen.__enter__cCs|jr|j|jr|jz0|jr|jW|tkr;|jdkr6z |j|jdWn ty5Ynwd|_dS|dS|tkrf|jdkr]z |j|jdWn ty\Ynwd|_YdS|w)Nrr) r9rr/rKeyboardInterruptr_waitrr)r0exc_typer< tracebackr'r'r(__exit__ s8          zPopen.__exit__cCs\|jsdS|jdur|d|jt|d|j|d|jdur*tdur,t|dSdSdS)Nzsubprocess %s is still running)sourcer[)_child_createdr,rResourceWarningr^r]rk)r0Z_maxsizeZ_warnr'r'r(rW)s   z Popen.__del__cCs"t|dsttjtj|_|jS)Nr)rrrdevnullO_RDWRrr5r'r'r( _get_devnull8s zPopen._get_devnullc Cs|r-z|j|Wn"tyYnty,}z|jtjkr!nWYd}~nd}~wwz|jWdSty?YdStyY}z|jtjkrMnWYd}~dSd}~wwr+)rwriteBrokenPipeErrorrerrnoZEINVALr)r0rrr'r'r( _stdin_write=s.      zPopen._stdin_writec CsR|jr |r td|durM|jsM|j|j|jgddkrMd}d}|jr*||n|jr8|j}|jn |jrE|j}|j| ||fS|durWt |}nd}z>z | |||\}}Wn-t y|durzt |j||}n|j}d|_z|j|dWtyYwwWd|_nd|_w|j ||d}||fS)a9Interact with process: Send data to stdin and close it. 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, or None, if no data should be sent to the child. communicate() returns a tuple (stdout, stderr). By default, all communication is in bytes, and therefore any "input" should be bytes, and the (stdout, stderr) will be bytes. If in text mode (indicated by self.text_mode), any "input" should be a string, and (stdout, stderr) will be strings decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. z.Cannot send input after starting communicationNrrrT)rr4rr9r/countr#readrr_time _communicaterminr_remaining_timerr)r0rrCr9r/endtimesigint_timeoutstsr'r'r(rVsP         zPopen.communicatecCs|S)zSCheck if child process has terminated. Set and return returncode attribute.)r^r5r'r'r(rsz Popen.pollcCs|durdS|tS)z5Convenience for _communicate when computing timeouts.N)r&)r0r*r'r'r(r)s zPopen._remaining_timecCsP|durdS|s t|kr&t|j||rd|nd|r"d|ddddS)z2Convenience for checking if a timeout has expired.Nrr)r&rrlr)r0r* orig_timeoutZ stdout_seqZ stderr_seqskip_check_and_raiser'r'r(_check_timeouts zPopen._check_timeoutc Cs||dur t|}z|j|dWSty=|dur%t|j||}n|j}d|_z|j|dWty<Yww)z=Wait for child process to terminate; returns self.returncode.Nrr)r&rrr(rr)r)r0rCr*r+r'r'r(rs&   z Popen.waitc Cst|dd}tm}tr,|dkr||j|dkr!||j|dkr+||jn9|dkr?|dkr?||kr?|tj||dkrR|dkrR||krR|tj||dkre|dkre||kre|tj||durp|tj|Wdn1szwYd|_dS)NrrdT) r contextlib ExitStackrcallbackrQrrr) r0rrrrrrZ devnull_fdstackr'r'r(_close_pipe_fdss*      zPopen._close_pipe_fdsc Csp|dur|dur|durdSd\}}d\}}d\}} |dur:ttj}|dur9tdd\}} t|}t| n4|tkrPtdd\}}t|t|}}n|tkr\t | }nt |t rgt |}nt | }||}|durttj}|durtdd\} }t|}t| n4|tkrtdd\}}t|t|}}n|tkrt | }nt |t rt |}nt | }||}|durttj} | durtdd\} } t| } t| n?|tkrtdd\}} t|t| }} n(|tkr |} n |tkrt | } nt |t r$t |} nt | } || } |||||| fS)|Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite N)rdrdrdrdrdrdrdrdr)rVZ GetStdHandlerZ CreatePiperNrPrr rZ get_osfhandlerrrRfileno_make_inheritablerrr) r0rr9r/rrrrrr_r'r'r(rsv                  zPopen._get_handlescCs&tt|tddtj}t|S)z2Return a duplicate of handle, which is inheritablerr|)rVZDuplicateHandleZGetCurrentProcessZDUPLICATE_SAME_ACCESSrN)r0handlehr'r'r(r84s  zPopen._make_inheritablecCstdd|DS)zFilter out console handles that can't be used in lpAttributeList["handle_list"] and make sure the list isn't empty. This also removes duplicate handles.cSs,h|]}|d@dkst|tjkr|qS))rVZ GetFileTypeZFILE_TYPE_CHAR).0r:r'r'r( Ds z,Popen._filter_handle_list..)rM)r0rKr'r'r(_filter_handle_list=szPopen._filter_handle_listc!Cs|rJdt|tr n't|tr| rtdt|g}nt|tjr/| r)tdt|g}nt|}|dur   zPopen._posix_spawnc-st|ttfr |g}nt|tjr| rtd|g}nt|}| r6ttdr(dnd}|dg|}r6|d<dur>|dt d|||t rtj r|dur|s|s|dur| d ksc| d kr|d ksk|d kr|d kss|d kr|s|dur|dur|dur|dkr| |||| | | ||| dS}t\}}g}|d kr||t|}|d ks|D]}t|qzz||durg}|D]\}}t|}d |vrtd ||d t|qnd}ttj rf} ntfddt|D} t|}!|!|t|| |tttt|!||| | | |||||||||||||_d|_Wt|nt|w| | | | |||t!}" t"|d}#|"|#7}"|#rat#|"dkrbnqMWt|nt|w|"rzt$|jd\}$}%|$|jkr|%|%ntj&|_'Wn t(yYnwz|")dd \}&}'}(|(*}(Wntyd}&d}'d+t|"}(Ynwt,t-|&*dt.})t/|)t0r|'rt|'d}*|(dk}+|+rd}(|},n|},|*dkrt1|*}(|)|*|(|,|)|(dS)zExecute program (POSIX version)r@Zgetandroidapilevelz/system/bin/shz/bin/shz-crNrArdrr<=z!illegal environment variable namec3s$|] }tjt|VqdSr+)rrErfsencode)r=dirrr'r( s  z'Popen._execute_child..TiP:sSubprocessError0z#Bad exception data from child: {!r}asciiZnoexecr)2rrrBrrCrrMrr_rH_USE_POSIX_SPAWNrEdirnamerbrZrkduprrrdr4r get_exec_pathsetadd_posixsubprocessZ fork_execsortedrrRrrr4 bytearrayr%rwaitpid_handle_exitstatusr`r,ChildProcessErrorrrrrbuiltinsr issubclassrstrerror)-r0rlrrrrrrrrrrrrrrrrrrr rrZ unix_shellZorig_executableZ errpipe_readZ errpipe_writeZlow_fds_to_closeZlow_fdZenv_listkrqZexecutable_listZ fds_to_keepZ errpipe_datapartrr,Zexception_nameZ hex_errnoerr_msgZchild_exception_typeZ errno_numZchild_exec_never_calledZ err_filenamer'rfr(rs                          cCs&||r || |_dS|||_dS):All callers to this function MUST hold self._waitpid_lock.N)r,)r0r,waitstatus_to_exitcodeZ _WIFSTOPPEDZ _WSTOPSIGr'r'r(rvKszPopen._handle_exitstatusc Cs|jdurl|jds dSzXz#|jdur|jWW|jS||j|\}}||jkr0||Wn"tyS}z|durA||_n|j|krId|_WYd}~nd}~wwW|j|jSW|j|jS|jw|jS)zCheck 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,racquirereleaserrvrr")r0r\Z_waitpidZ_WNOHANGZ_ECHILDrr,er'r'r(r^Ws4         cCs@zt|j|\}}W||fSty|j}d}Y||fSw)r~r)rrurrw)r0Z wait_flagsrr,r'r'r( _try_waitzs zPopen._try_waitcCsr|jdur|jS|duryt|}d} |jdr\z;|jdur)W|j|jS|tj\}}||jks<|dks)Fr+):r$r%r&r@rr1rUrrrrrArrBrrrr_r`rrrWrr#rrr)r/rr4rrr8r?rrVrKZ WAIT_OBJECT_0rLr^rrNr'rWrUrrbrr WIFSTOPPEDWSTOPSIGrvrurr"ZECHILDrrr'r'r'r(rs5  |    D H   2<'&   # )f  r)Lr@rxr"rrrr3r_rrr0rr&rr[r__all__rrVrModuleNotFoundErrorrrrrrrrrrrrrrrrrrrrr r!r"r Exceptionrr rr#rRrNrrrrXrZSelectSelectorr]rYrrr rmrrrr objectrr rrr rrlZ _USE_VFORKrr'r'r'r(s"     P  %     ;4% FI 2