o 0¦iµKã@spdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z ddl Z zddlZWn eyEdZYnwgd¢Zz ddlZddlZdZWneymdZddlZddlZddlZYn0wddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)e *gd¢¡Gd d „d e+ƒZ,Gd d „d e,ƒZ-Gd d„de,ƒZ.erÇGdd„dƒZ/Gdd„de0ƒZ1ne2eddƒZ3e4edƒrÖej5Z6nej7Z6erâdZ8dd„Z9ngZ8dd„Z9dZ:dZ;dZdd œd!d"„Z?d#d$„Z@dd œd%d&„ZAGd'd(„d(eBƒZCddddd)œd*d+„ZDd,d-„ZEd.d/„ZFd0d1„ZGd2d3„ZHeHƒZIdZJGd4d5„d5ƒZKdS)6a•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 (exitcode, output) tuple éN)Ú monotonic)ÚPopenÚPIPEÚSTDOUTÚcallÚ check_callÚgetstatusoutputÚ getoutputÚ check_outputÚrunÚCalledProcessErrorÚDEVNULLÚSubprocessErrorÚTimeoutExpiredÚCompletedProcessTF)ÚCREATE_NEW_CONSOLEÚCREATE_NEW_PROCESS_GROUPÚSTD_INPUT_HANDLEÚSTD_OUTPUT_HANDLEÚSTD_ERROR_HANDLEÚSW_HIDEÚSTARTF_USESTDHANDLESÚSTARTF_USESHOWWINDOWÚABOVE_NORMAL_PRIORITY_CLASSÚBELOW_NORMAL_PRIORITY_CLASSÚHIGH_PRIORITY_CLASSÚIDLE_PRIORITY_CLASSÚNORMAL_PRIORITY_CLASSÚREALTIME_PRIORITY_CLASSÚCREATE_NO_WINDOWÚDETACHED_PROCESSÚCREATE_DEFAULT_ERROR_MODEÚCREATE_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 dd„Zdd„Zedd„ƒZejd d„ƒZdS) r z£Raised when run() is called with check=True and the process returns a non-zero exit status. Attributes: cmd, returncode, stdout, stderr, output NcCó||_||_||_||_dS©N)Ú returncodeÚcmdÚoutputÚstderr)Ú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Ú ValueError©r0r'r'r(Ú__str__usÿ   ÿÿÿzCalledProcessError.__str__cCó|jS)z+Alias for output attribute, to match stderr©r.r5r'r'r(Ústdout�szCalledProcessError.stdoutcCó ||_dSr+r8©r0Úvaluer'r'r(r9†ó ©NN© r$r%r&Ú__doc__r1r6Úpropertyr9Úsetterr'r'r'r(r hs  r c@r)) rz›This 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(r1”r2zTimeoutExpired.__init__cCsd|j|jfS)Nz'Command '%s' timed out after %s seconds)r-rCr5r'r'r(r6šs ÿzTimeoutExpired.__str__cCr7r+r8r5r'r'r(r9žszTimeoutExpired.stdoutcCr:r+r8r;r'r'r(r9¢r=r>r?r'r'r'r(r�s  rc@s,eZdZdddddddœdd„Zdd„ZdS)r#rN©ÚdwFlagsÚ hStdInputÚ hStdOutputÚ hStdErrorÚ wShowWindowÚlpAttributeListcCs0||_||_||_||_||_|pdgi|_dS)NÚ handle_listrD)r0rErFrGrHrIrJr'r'r(r1«s zSTARTUPINFO.__init__cCs@|j ¡}d|vrt|dƒ|d<t|j|j|j|j|j|d�S)NrKrD) rJÚcopyÚlistr#rErFrGrHrI)r0Z attr_listr'r'r(rL´s ûzSTARTUPINFO.copy)r$r%r&r1rLr'r'r'r(r#ªs  ÿ r#c@s2eZdZdZejfdd„Zdd„Zdd„ZeZ dS) ÚHandleFcCs|js d|_||ƒdSdS)NT)Úclosed)r0Ú CloseHandler'r'r(ÚCloseÄs þz Handle.ClosecCs|js d|_t|ƒStdƒ‚)NTzalready closed)rOÚintr4r5r'r'r(ÚDetachÉsz 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(rNÁs rNZPIPE_BUFiÚ PollSelectorcCsdSr+r'r'r'r'r(Ú_cleanupíórYc CsZtdurdStdd…D]}|jtjd�}|dur*zt |¡Wq ty)Yq wq dS)N©Ú _deadstate)Ú_activeÚ_internal_pollÚsysÚmaxsizeÚremover4)ÚinstÚresr'r'r(rYös ýýþéÿÿÿÿéþÿÿÿéýÿÿÿcCs*g}tjj}|dkr| dd|¡|S)zgReturn a list of command-line arguments reproducing the current optimization settings in sys.flags.rú-ÚO)r_ÚflagsÚoptimizeÚappend)Ú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|  d¡n|rj|  d¡|rq|  d¡|D] }| d|¡qs|r„|  d¡dD]}||vr¤||} | dur—|} nd|| f} |  d| f¡q†|S)z}Return a list of command-line arguments reproducing the current settings in sys.flags, sys.warnoptions and sys._xoptions.ÚdÚBÚSÚvÚbÚq)ÚdebugÚdont_write_bytecodeÚno_siteÚverboseÚ bytes_warningÚquietrrgz-Iz-Ez-sNÚ _xoptionsÚdevézerror::BytesWarningzdefault::BytesWarningÚdefaultz-W)ú-Xr{)Z faulthandlerÚ tracemallocZ importtimeZ showrefcountÚutf8Tz%s=%sr~) rmÚitemsÚgetattrr_rirkÚisolatedÚignore_environmentÚ no_user_siteÚ warnoptionsrxraÚextend) Z flag_opt_maprlÚflagÚoptrqZwarnoptsrxZxoptionsÚdev_moder<Úargr'r'r(Ú_args_from_interpreter_flagssTø  €         €rŒ©rCcOsRt|i|¤Ž�}z|j|d�WWdƒS| ¡‚1s"wYdS)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"]) r�N)rÚwaitÚkill)rCÚ popenargsÚkwargsÚpr'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)rÚgetr )r�r‘Úretcoder-r'r'r(rbs   rcOsvd|vrtdƒ‚d|vr/|ddur/| d¡s&| d¡s&| d¡s&| d¡r)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.ÚinputNÚuniversal_newlinesÚtextÚencodingÚerrorsÚóT)r9rCÚcheck)r4r“r rr9)rCr�r‘Úemptyr'r'r(r us#ÿÿÿr c@s4eZdZdZd dd„Zdd„ZeejƒZ dd„Z 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(r1´r2zCompletedProcess.__init__cCshd |j¡d |j¡g}|jdur| d |j¡¡|jdur(| d |j¡¡d t|ƒjd |¡¡S)Nz args={!r}zreturncode={!r}z stdout={!r}z stderr={!r}z{}({})z, ) Úformatrlr,r9rkr/Útyper$Újoin)r0rlr'r'r(rUºs  ÿ  zCompletedProcess.__repr__cCs |jrt|j|j|j|jƒ‚dS)z6Raise CalledProcessError if the exit code is non-zero.N)r,r rlr9r/r5r'r'r(Úcheck_returncodeÆs ÿÿz!CompletedProcess.check_returncoder>) r$r%r&r@r1rUÚ classmethodÚtypesÚ GenericAliasÚ__class_getitem__r¡r'r'r'r(r©s   r)r•Úcapture_outputrCrœc Os$|dur| d¡durtdƒ‚t|d<|r/| d¡dus#| d¡dur'tdƒ‚t|d<t|d<t|i|¤Ž�L}z |j||d�\}}Wn'tyb} z| ¡trY| ¡\| _| _ ‚|  ¡‚d} ~ w| ¡‚|  ¡} |r{| r{t | |j ||d�‚Wdƒn1s…wYt|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. NÚstdinz/stdin and input arguments may not both be used.r9r/z@stdout and stderr arguments may not be used with capture_output.r�©r.r/)r“r4rrÚ communicaterr�Ú _mswindowsr9r/rŽÚpollr rlr) r•r¦rCrœr�r‘Zprocessr9r/Úexcr”r'r'r(r Ís>ÿ€ÿ€ér cCsèg}d}ttj|ƒD]d}g}|r| d¡d|vpd|vp| }|r'| d¡|D]1}|dkr5| |¡q)|dkrL| dt|ƒd¡g}| d¡q)|rU| |¡g}| |¡q)|rb| |¡|rn| |¡| d¡q 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š)ÚmapÚosÚfsdecoderkÚlenr‡r )ÚseqÚresultZ needquoter‹Zbs_bufÚcr'r'r(Ú list2cmdlines6         € r¹c Csnz t|ddtd�}d}Wnty$}z |j}|j}WYd}~nd}~ww|dd…dkr3|dd…}||fS)aöReturn (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)Úshellr—r/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 Cs´tsttdƒs dStjdvrdSz„Z.d?d/„Z"e/j0e/j1e/j2fd@dA„Z3de/j4e/j5e6j7fdBd1„Z'dCdD„Z8dEd3„Z(dFd7„Z*dGdH„Z9dId9„Z+dJd;„Z,dKdL„Z-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')ÚuserÚgroupÚ extra_groupsr˜r™r—ÚumaskÚpipesizec+Csœtƒt ¡|_d|_d|_|durd}t|tƒstdƒ‚|dur#d}t|tƒs,tdƒ‚t r7|dur6t dƒ‚n|rC|sCt   dt ¡d}| durKt d ƒ‚|d krSt d ƒ‚||_d|_d|_d|_d|_d|_||_||_||_|dur‚| dur‚t| ƒt|ƒkr‚td ƒ‚| |||¡\}}}}}}t rµ|dkr�t | ¡d ¡}|dkr©t | ¡d ¡}|dkrµt | ¡d ¡}|p¼|p¼|p¼| |_|jrÊ|durÊd |_}d|_d|_|jrÞ|dkrÜd} d}nd} d}!|du�r,t t!dƒsît dƒ‚t|t"ƒ�rzd dl#}"Wn t$�yt dƒ‚w|" %|¡j&}!nt|tƒ�r|}!n td 't(|ƒ¡ƒ‚|!d k�r,t d|!›�ƒ‚d}#|du�r™t t!dƒ�s=t dƒ‚t|t"ƒ�rGt dƒ‚g}#|D];}$t|$t"ƒ�rqzd dl#}"Wn t$�yet dƒ‚w|# )|" %|$¡j&¡�qKt|$tƒ�r~|# )|$¡�qKtd 't(|$ƒ¡ƒ‚|#D]}%|%d k�r—t d|%›�ƒ‚�q‰d}&|du�rãt t!dƒ�sªt dƒ‚t|t"ƒ�rÊzd dl*}'Wn t$�yÂt dƒ‚w|' +|¡j,}&n t|tƒ�rÓ|}&ntdƒ‚|&d k�rãt d|&›�ƒ‚zp|dk�rt- .|d|¡|_|j�rt-j/|jd| ||d �|_|dk�rt- .|d!|¡|_|j�rt-j/|j||d"�|_|dk�r7t- .|d!|¡|_|j�r7t-j/|j||d"�|_| 0|||||| | | || ||||||||!|#|&||¡WdSt1d|j|j|jfƒD]}(z|( 2¡W�qbt3�yvY�qbw|j�sÍg})|t4k�r‡|) )|¡|t4k�r‘|) )|¡|t4k�r›|) )|¡t |d#ƒ�r§|) )|j5¡|)D]#}*zt �rºt|*t6ƒ�rº|* 7¡nt! 2|*¡W�q©t3�yÌY�q©w‚)$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_throughÚline_bufferingr˜r™Úrb)r˜r™Ú_devnull)8rYÚ threadingZLockÚ _waitpid_lockÚ_inputÚ_communication_startedÚ isinstancerRÚ TypeErrorrªr4ÚwarningsÚwarnÚRuntimeWarningrlr§r9r/Úpidr,r˜r™rÑÚboolrÚ _get_handlesÚmsvcrtZopen_osfhandlerSÚ text_modeÚ_sigint_wait_secsÚ_closed_child_pipe_fdsrÃr³ÚstrÚgrpÚ ImportErrorZgetgrnamZgr_gidržrŸrkÚpwdÚgetpwnamZpw_uidÚioÚopenÚ TextIOWrapperÚ_execute_childÚfilterÚcloserÉrrÚrNrQ)+r0rlÚbufsizeÚ executabler§r9r/Ú preexec_fnÚ close_fdsrºÚcwdÚenvr–Ú startupinfoÚ creationflagsÚrestore_signalsÚstart_new_sessionÚpass_fdsrÍrÎrÏr˜r™r—rÐrÑÚp2creadÚp2cwriteÚc2preadÚc2pwriteÚerrreadÚerrwriterØÚgidrìÚgidsZ extra_groupZ gid_checkÚuidrîÚfZto_closeÚfdr'r'r(r1ösV   ÿ  þ     ÿ  ÿ      ÿ  þ ÿ    ÿ    þ ÿ ÿ  ø ÿ          €ÿzPopen.__init__cCs@d|jj›d|j›d|j›d�}t|ƒdkr|dd…d}|S)NúéPéLz...>)rTr$r,rlrµ)r0Zobj_reprr'r'r(rUñs ÿÿÿ zPopen.__repr__cCr7r+)rèr5r'r'r(r–üszPopen.universal_newlinescCst|ƒ|_dSr+)rårè)r0r–r'r'r(r–scCs | ||¡}| dd¡ dd¡S)Nz r»ú )ÚdecodeÚreplace)r0r¼r˜r™r'r'r(Ú_translate_newliness zPopen._translate_newlinescCs|Sr+r'r5r'r'r(Ú __enter__ rZzPopen.__enter__cCsÖ|jr|j ¡|jr|j ¡z0|jr|j ¡W|tkr;|jdkr6z |j|jd�Wn ty5Ynwd|_dS| ¡dS|tkrf|jdkr]z |j|jd�Wn ty\Ynwd|_YdS| ¡w)Nrr�) r9rõr/r§ÚKeyboardInterruptréÚ_waitrrŽ)r0Úexc_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,räÚResourceWarningr^r]rk)r0Z_maxsizeZ_warnr'r'r(rW)s  ÿ þz Popen.__del__cCs"t|dƒst tjtj¡|_|jS)NrÚ)rÃr³rñÚdevnullÚO_RDWRrÚr5r'r'r(Ú _get_devnull8s zPopen._get_devnullc Cs´|r-z|j |¡Wn"tyYnty,}z|jtjkr!n‚WYd}~nd}~wwz|j ¡WdSty?YdStyY}z|jtjkrMn‚WYd}~dSd}~wwr+)r§ÚwriteÚBrokenPipeErrorrÉÚerrnoZEINVALrõ)r0r•r¬r'r'r(Ú _stdin_write=s.   þ€û   þ€þzPopen._stdin_writec CsR|jr |r tdƒ‚|durM|jsM|j|j|jg d¡dkrMd}d}|jr*| |¡n|jr8|j ¡}|j ¡n |jrE|j ¡}|j ¡|  ¡||fS|durWt ƒ|}nd}z>z |  |||¡\}}Wn-t y’|durzt |j| |¡ƒ}n|j}d|_z|j|d�W‚ty‘Y‚wwWd|_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 communicationNr±rr�T)rÞr4r§r9r/Úcountr#ÚreadrõrŽÚ_timeÚ _communicaterÚminréÚ_remaining_timerr)r0r•rCr9r/ÚendtimeÚsigint_timeoutÚstsr'r'r(r©VsP      å  ÿ þþõÿzPopen.communicatecCs| ¡S)zSCheck if child process has terminated. Set and return returncode attribute.)r^r5r'r'r(r«šsz Popen.pollcCs|durdS|tƒS)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 |¡d�‚dd�‚dS)z2Convenience for checking if a timeout has expired.Nr›r¨)r&rrlr )r0r*Ú orig_timeoutZ stdout_seqZ stderr_seqÚskip_check_and_raiser'r'r(Ú_check_timeout¨s ýýÿzPopen._check_timeoutc Cs||dur tƒ|}z|j|d�WSty=|dur%t|j| |¡ƒ}n|j}d|_z|j|d�W‚ty<Y‚ww)z=Wait for child process to terminate; returns self.returncode.Nr�r)r&rrr(rér)r)r0rCr*r+r'r'r(rŽ´s&  ÿ þþóz Popen.waitc Cst|ddƒ}t ¡�m}tr,|dkr| |j¡|dkr!| |j¡|dkr+| |j¡n9|dkr?|dkr?||kr?| tj|¡|dkrR|dkrR||krR| tj|¡|dkre|dkre||kre| tj|¡|durp| tj|¡Wdƒn1szwYd|_dS)NrÚrdT) r‚Ú contextlibÚ ExitStackrªÚcallbackrQr³rõrê) r0rrrrrrZ devnull_fdÚstackr'r'r(Ú_close_pipe_fdsËs*     €€ï zPopen._close_pipe_fdsc Csp|dur|dur|durdSd\}}d\}}d\}} |dur:t tj¡}|dur9t dd¡\}} t|ƒ}t | ¡n4|tkrPt dd¡\}}t|ƒt|ƒ}}n|tkr\t  |  ¡¡}nt |t ƒrgt  |¡}nt  |  ¡¡}| |¡}|dur“t tj¡}|dur’t dd¡\} }t|ƒ}t | ¡n4|tkr©t dd¡\}}t|ƒt|ƒ}}n|tkrµt  |  ¡¡}nt |t ƒrÀt  |¡}nt  |  ¡¡}| |¡}|durìt tj¡} | durët dd¡\} } t| ƒ} t | ¡n?|tk�rt dd¡\}} t|ƒt| ƒ}} n(|tk�r |} n |tk�rt  |  ¡¡} nt |t ƒ�r$t  |¡} nt  |  ¡¡} | | ¡} |||||| fS)ú|Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite N)rdrdrdrdrdrd©rdrdr)rVZ GetStdHandlerZ CreatePiperNrPrr rçZ get_osfhandlerrßrRÚfilenoÚ_make_inheritablerrr) r0r§r9r/rrrrrrÚ_r'r'r(ræìsv  €     €     €      þzPopen._get_handlescCs&t t ¡|t ¡ddtj¡}t|ƒS)z2Return a duplicate of handle, which is inheritablerr|)rVZDuplicateHandleZGetCurrentProcessZDUPLICATE_SAME_ACCESSrN)r0ÚhandleÚhr'r'r(r84s  ýzPopen._make_inheritablecCstdd„|DƒƒS)z°Filter 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„|rJdƒ‚t|tƒr n't|tƒr| rtdƒ‚t|gƒ}nt|tjƒr/| r)tdƒ‚t|gƒ}nt|ƒ}|dur  €€ ý€þzPopen._posix_spawnc-sôt|ttfƒr |g}nt|tjƒr| rtdƒ‚|g}nt|ƒ}| r6ttdƒr(dnd}|dg|}ˆr6ˆ|d<ˆdur>|d‰t  dˆ|||¡t r•tj   ˆ¡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 |¡q³z¯z||duræg}| ¡D]\}}t |¡}d |vrØtd ƒ‚| |d t |¡¡qÇnd}t ˆ¡‰tj   ˆ¡r÷ˆf} nt‡fdd„t |¡Dƒƒ} t|ƒ}!|! |¡t || |tttt|!ƒƒƒ||| | | ||||||||||||¡|_d|_Wt |¡nt |¡w|  | | | |||¡t!ƒ}" t "|d¡}#|"|#7}"|#�rat#|"ƒdk�rbn�qMWt |¡nt |¡w|"�røzt $|jd¡\}$}%|$|jk�rŠ| %|%¡ntj&|_'Wn t(�y™Ynwz|" )dd ¡\}&}'}(|( *¡}(Wnt�y¾d}&d}'d +t|"ƒ¡}(Ynwt,t-|& *d¡t.ƒ})t/|)t0ƒ�rô|'�rôt|'dƒ}*|(dk}+|+�râd}(|},n|},|*dk�rît 1|*¡}(|)|*|(|,ƒ‚|)|(ƒ‚dS)zExecute program (POSIX version)r@Zgetandroidapilevelz/system/bin/shz/bin/shz-crNrArdr±r<ó=z!illegal environment variable namec3s$�|] }tj t |¡ˆ¡VqdSr+)r³rEr Úfsencode)r=Údir©r÷r'r(Ú ÿs €ÿ ÿz'Popen._execute_child..TiPÃó:sSubprocessErroró0z#Bad exception data from child: {!r}ÚasciiéZnoexecrš)2rßrërBr³rCràrMrÃr_rHÚ_USE_POSIX_SPAWNrEÚdirnamerbrZrkÚduprõr�rdr4rÇÚ get_exec_pathÚsetÚaddÚ_posixsubprocessZ fork_execÚsortedr²rRrärr4Ú bytearrayr%rµÚwaitpidÚ_handle_exitstatusr`r,ÚChildProcessErrorrÆrržr‚ÚbuiltinsrÚ issubclassrÉÚstrerror)-r0rlr÷rørùrrúrûrürýrºrrrrrrrþrrr rÐrÿZ unix_shellZorig_executableZ errpipe_readZ errpipe_writeZlow_fds_to_closeZlow_fdZenv_listÚkrqZexecutable_listZ fds_to_keepZ errpipe_dataÚparträr,Zexception_nameZ hex_errnoÚerr_msgZchild_exception_typeZ errno_numZchild_exec_never_calledZ err_filenamer'rfr(ró§s   ÿÿ  ÿÿþÿ ý   þ  ü   þ ÷ þ ü  €ÿ ÿ ÿý þ    Û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|j d¡s dSzXz#|jdur|jWW|j ¡S||j|ƒ\}}||jkr0| |¡Wn"tyS}z|durA||_n|j|krId|_WYd}~nd}~wwW|j ¡|jSW|j ¡|jS|j ¡w|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ÜÚacquireÚreleaserärvrÉr")r0r\Z_waitpidZ_WNOHANGZ_ECHILDrär,Úer'r'r(r^Ws4   ò  € €÷€ € ÿ ÿcCs@zt |j|¡\}}W||fSty|j}d}Y||fSw)r~r)r³rurärw)r0Z wait_flagsrär,r'r'r(Ú _try_waitzs úúzPopen._try_waitcCsr|jdur|jS|durytƒ|}d} |j d¡r\z;|jdur)W|j ¡|jS| tj¡\}}||jks<|dks)Fr+):r$r%r&r@rr1rUr¢r£r¤r¥rAr–rBrrrr_r`rárârWrr#r©r«r)r/rŽr4rªrær8r?rórVrKZ WAIT_OBJECT_0rLr^rrNr'rWrUr�rbr³rÚ WIFSTOPPEDÚWSTOPSIGrvrur„r"ZECHILDrƒrˆr'r'r'r(r¾sˆ5ú  ù|    D ÿ H   ý2<'& ý  ÿ# )f  r)Lr@rxr"rðr³r…r3r_rÛrár0rr&r£r[ríÚ__all__rçrVrªÚModuleNotFoundErrorrrrŽrŒrrrrrrrrrrrrrrrr r!r"r‡Ú Exceptionrr rr#rRrNr‚r�rÃrXrŠZSelectSelectorr]rYrrr rmrŒrrr Úobjectrr r¹rr rÌrlZ _USE_VFORKrr'r'r'r(Ús€"   ÿ  üP  %     ;4% ÿFI 2