grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a XC?hlFã@s˜dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z ddl Z z ddlZWneyŠdZYn0z ddlZWney®dZYn0gd¢ZzddlZddlZdZWn.eyþdZddlZddlZddlZYn`0ddlmZmZmZmZmZmZmZm Z m!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/e�r´Gdd„dƒZ0Gdd„de1ƒZ2n&e3eddƒZ4e5edƒ�rÔej6Z7nej8Z7e�rîdZ9dd„Z:n gZ9dd„Z:dZ;dZdd„Z?dd œd!d"„Z@d#d$„ZAdd œd%d&„ZBGd'd(„d(eCƒZDddddd)œd*d+„ZEd,d-„ZFd.d/„ZGd0d1„ZHd2d3„ZIeIƒZJGd4d5„d5eCƒ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'ú//opt/alt/python39/lib64/python3.9/subprocess.pyriórc@s<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 NcCs||_||_||_||_dS©N)Ú returncodeÚcmdÚoutputÚstderr)Úselfr+r,r-r.r'r'r(Ú__init__sszCalledProcessError.__init__cCsf|jrR|jdkrRzd|jt |j ¡fWStyNd|j|j fYS0nd|j|jfSdS)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©r/r'r'r(Ú__str__ysÿ  ÿÿzCalledProcessError.__str__cCs|jS)z+Alias for output attribute, to match stderr©r-r3r'r'r(Ústdout…szCalledProcessError.stdoutcCs ||_dSr*r5©r/Úvaluer'r'r(r6Šs)NN© r$r%r&Ú__doc__r0r4Úpropertyr6Úsetterr'r'r'r(r ls   r c@s<eZdZdZd dd„Zdd„Zedd„ƒZejd d„ƒZdS) rz›This exception is raised when the timeout expires while waiting for a child process. Attributes: cmd, output, stdout, stderr, timeout NcCs||_||_||_||_dSr*)r,Útimeoutr-r.)r/r,r=r-r.r'r'r(r0˜szTimeoutExpired.__init__cCsd|j|jfS)Nz'Command '%s' timed out after %s seconds)r,r=r3r'r'r(r4žs ÿzTimeoutExpired.__str__cCs|jSr*r5r3r'r'r(r6¢szTimeoutExpired.stdoutcCs ||_dSr*r5r7r'r'r(r6¦s)NNr9r'r'r'r(r‘s  rc@s,eZdZdddddddœdd„Zdd„ZdS)r#rN©ÚdwFlagsÚ hStdInputÚ hStdOutputÚ hStdErrorÚ wShowWindowÚlpAttributeListcCs0||_||_||_||_||_|p(dgi|_dS)NÚ handle_listr>)r/r?r@rArBrCrDr'r'r(r0¯s zSTARTUPINFO.__init__cCs@|j ¡}d|vr"t|dƒ|d<t|j|j|j|j|j|d�S)NrEr>) rDÚcopyÚlistr#r?r@rArBrC)r/Z attr_listr'r'r(rF¸s ûzSTARTUPINFO.copy)r$r%r&r0rFr'r'r'r(r#®sÿ r#c@s2eZdZdZejfdd„Zdd„Zdd„ZeZ dS) ÚHandleFcCs|jsd|_||ƒdS)NT)Úclosed)r/Ú CloseHandler'r'r(ÚCloseÈsz Handle.ClosecCs |jsd|_t|ƒStdƒ‚dS)NTzalready closed)rIÚintr2r3r'r'r(ÚDetachÍsz Handle.DetachcCsd|jjt|ƒfS)Nz%s(%d))Ú __class__r$rLr3r'r'r(Ú__repr__ÓszHandle.__repr__N) r$r%r&rIÚ_winapirJrKrMrOÚ__del__r'r'r'r(rHÅs rHZPIPE_BUFiÚ PollSelectorcCsdSr*r'r'r'r'r(Ú_cleanupñsrSc CsZtdur dStdd…D]<}|jtjd�}|durzt |¡WqtyRYq0qdS)N©Ú _deadstate)Ú_activeÚ_internal_pollÚsysÚmaxsizeÚremover2)ÚinstÚresr'r'r(rSús éÿÿÿÿéþÿÿÿéýÿÿÿcCs*g}tjj}|dkr&| dd|¡|S)zgReturn a list of command-line arguments reproducing the current optimization settings in sys.flags.rú-ÚO)rXÚflagsÚoptimizeÚappend)Úargsr8r'r'r(Ú"_optim_args_from_interpreter_flagss rfc CsVdddddddœ}tƒ}| ¡D].\}}ttj|ƒ}|dkr | d ||¡q tjjrd| d ¡n$tjjrv| d ¡tjjrˆ| d ¡tj d d …}tjj }ttdiƒ}d|v}|dkrÆ|  d¡n|rÔ|  d¡|râ|  d¡|D]}| d|¡qæ|�r |  d¡dD]B}||v�r||} | du�r4|} n d|| 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Úquietrr`z-Iz-Ez-sNÚ _xoptionsÚdevézerror::BytesWarningzdefault::BytesWarningÚdefaultz-W)ú-Xrt)Z faulthandlerÚ tracemallocZ importtimeZ showrefcountÚutf8Z oldparserTz%s=%srw) rfÚitemsÚgetattrrXrbrdÚisolatedÚignore_environmentÚ no_user_siteÚ warnoptionsrqrZÚextend) Z flag_opt_mapreÚflagÚoptrjZwarnoptsrqZxoptionsÚdev_moder8Úargr'r'r(Ú_args_from_interpreter_flagssPø             r…©r=cOsft|i|¤Ž�D}z|j|d�WWdƒS| ¡‚Yn0Wdƒn1sX0YdS)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)r=Ú popenargsÚkwargsÚpr'r'r(rUs rcOs:t|i|¤Ž}|r6| 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"]) reNr)rÚgetr )r‰rŠÚretcoder,r'r'r(rfs   rcOsbd|vrtdƒ‚d|vrJ|ddurJ| d¡s8| 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. r6z3stdout argument not allowed, it will be overridden.ÚinputNÚuniversal_newlinesÚtextÚr)T)r6r=Úcheck)r2rŒr rr6)r=r‰rŠÚemptyr'r'r(r ys#ÿ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). NcCs||_||_||_||_dSr*)rer+r6r.)r/rer+r6r.r'r'r(r0·szCompletedProcess.__init__cCshd |j¡d |j¡g}|jdur4| d |j¡¡|jdurP| d |j¡¡d t|ƒjd |¡¡S)Nz args={!r}zreturncode={!r}z stdout={!r}z stderr={!r}z{}({})z, ) Úformatrer+r6rdr.Útyper$Újoin)r/rer'r'r(rO½s  ÿ  zCompletedProcess.__repr__cCs |jrt|j|j|j|jƒ‚dS)z6Raise CalledProcessError if the exit code is non-zero.N)r+r rer6r.r3r'r'r(Úcheck_returncodeÉsÿz!CompletedProcess.check_returncode)NN) r$r%r&r:r0rOÚ classmethodÚtypesÚ GenericAliasÚ__class_getitem__r—r'r'r'r(r¬s   r)rŽÚcapture_outputr=r’c Os<|dur&| d¡durtdƒ‚t|d<|r^| d¡dusF| d¡durNtdƒ‚t|d<t|d<t|i|¤Ž�®}z|j||d�\}}Wn`tyÐ} z4| ¡tr²| ¡\| _| _ n|  ¡‚WYd} ~ nd} ~ 0| ¡‚Yn0|  ¡} |�r | �r t | |j ||d�‚Wdƒn1�s"0Yt|j | ||ƒS) aKRun 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. 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.r6r.z@stdout and stderr arguments may not be used with capture_output.r†©r-r.)rŒr2rrÚ communicaterrˆÚ _mswindowsr6r.r‡Úpollr rer) rŽrœr=r’r‰rŠZprocessr6r.Úexcr�r'r'r(r Ðs6 ÿ&r cCsèg}d}ttj|ƒD]È}g}|r*| d¡d|vp>d|vp>| }|rN| d¡|D]b}|dkrj| |¡qR|dkr˜| dt|ƒd¡g}| d¡qR|rª| |¡g}| |¡qR|rÄ| |¡|r| |¡| d¡qd |¡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ÚfsdecoderdÚlenr€r–)ÚseqÚresultZ needquoter„Zbs_bufÚcr'r'r(Ú list2cmdlines4         r¯c Csnzt|ddtd�}d}Wn0tyH}z|j}|j}WYd}~n d}~00|dd…dkrf|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.rNr]Ú )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' ru)r)r,r'r'r(r }s r c Cs¨tsttdƒsdStjdkr dSzjt d¡}|jdd�}t|ƒdkrHt‚|d }t t t |d d ¡ƒƒ}tjd krˆ|d krˆ|d krˆWdSWnt tt fy¢Yn0dS)a„Check if posix_spawn() can be used for subprocess. subprocess requires a posix_spawn() implementation that properly reports errors to the parent process, & sets errno on the following failures: * Process attribute actions failed. * File actions failed. * exec() failed. Prefer an implementation which can use vfork() in some cases for best performance. Ú posix_spawnFÚdarwinTÚCS_GNU_LIBC_VERSIONru)Úmaxsplitr§rÚ.ZlinuxZglibc)r§é)r Úhasattrr©rXÚplatformÚconfstrÚsplitr«r2Útupler¨rLÚAttributeErrorÚOSError)ZverÚpartsZlibcÚversionr'r'r(Ú_use_posix_spawnŠs      rÂc@s¶eZdZdZdZdMddddddddœd d „Zd d „Zeej ƒZ e d d„ƒZ e j dd„ƒZ dd„Zdd„Zdd„Zejejfdd„Zdd„Zdd„ZdNdd„Zdd„Zd d!„ZdOd"d#„ZdPd$d%„Zd&d'„Ze�r4d(d)„Zd*d+„Z d,d-„Z!d.d/„Z"de#j$e#j%e#j&fd0d1„Z'd2d3„Z(d4d5„Z)d6d7„Z*d8d9„Z+d:d;„Z,e,Z-n~d„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 Fr]NTrr')ÚuserÚgroupÚ extra_groupsÚencodingÚerrorsr�Úumaskc(CsFtƒt ¡|_d|_d|_|dur(d}t|tƒs:tdƒ‚t rP|durˆt dƒ‚n8|rh|sht   dt ¡d}| durxt dƒ‚|d krˆt d ƒ‚||_d|_d|_d|_d|_d|_||_||_|durà| duràt| ƒt|ƒkràtd ƒ‚| |||¡\}}}}}}t �rN|dk�rt | ¡d ¡}|dk�r4t | ¡d ¡}|dk�rNt | ¡d ¡}|�pb|�pb|�pb| |_d |_d|_|j�r’|d k�rŽd}d}nd}d} |du�rtt dƒ�s¶t dƒ‚nPt|t!ƒ�rât"du�rÔt dƒ‚t" #|¡j$} n$t|tƒ�rô|} ntd %t&|ƒ¡ƒ‚| d k�rt d| ›�ƒ‚d}!|du�rætt dƒ�sBt dƒ‚nt|t!ƒ�rVt dƒ‚g}!|D]b}"t|"t!ƒ�r”t"du�r€t dƒ‚|! 't" #|"¡j$¡n*t|"tƒ�r¬|! '|"¡ntd %t&|"ƒ¡ƒ‚�q^|!D]}#|#d k�rÆt d|#›�ƒ‚�qÆd}$|du�rhtt dƒ�s t dƒ‚nFt|t!ƒ�r6t(du�r(t dƒ‚t( )|¡j*}$nt|tƒ�rH|}$ntdƒ‚|$d k�rht d|$›�ƒ‚zÞ|dk�r¤t+ ,|d|¡|_|j�r¤t+j-|jd|||d�|_|dk�rÚt+ ,|d|¡|_|j�rÚt+j-|j||d �|_|dk�rt+ ,|d|¡|_|j�rt+j-|j||d �|_| .|||||| | | || |||||||| |!|$||¡Wnút/d|j|j|jfƒD](}%z |% 0¡Wnt1�yˆYn0�qd|j�s:g}&|t2k�r®|& '|¡|t2k�rÂ|& '|¡|t2k�rÖ|& '|¡t|d!ƒ�rî|& '|j3¡|&D]F}'z*t �rt|'t4ƒ�r|' 5¡n t  0|'¡Wnt1�y4Yn0�qò‚Yn0dS)"zCreate new Popen instance.NFr]zbufsize 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.gÐ?ruÚ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)6rSÚ threadingZLockÚ _waitpid_lockÚ_inputÚ_communication_startedÚ isinstancerLÚ TypeErrorr r2ÚwarningsÚwarnÚRuntimeWarningrer�r6r.Úpidr+rÆrÇÚboolrÚ _get_handlesÚmsvcrtZopen_osfhandlerMÚ text_modeÚ_sigint_wait_secsÚ_closed_child_pipe_fdsr¹r©ÚstrÚgrpZgetgrnamZgr_gidr”r•rdÚpwdÚgetpwnamZpw_uidÚioÚopenÚ TextIOWrapperÚ_execute_childÚfilterÚcloser¿rrÐrHrK)(r/reÚbufsizeÚ executabler�r6r.Ú preexec_fnÚ close_fdsr°ÚcwdÚenvr�Ú startupinfoÚ creationflagsÚrestore_signalsÚstart_new_sessionÚpass_fdsrÃrÄrÅrÆrÇr�rÈÚp2creadÚp2cwriteÚc2preadÚc2pwriteÚerrreadÚerrwriterÎÚgidÚgidsZ extra_groupZ gid_checkÚuidÚfZto_closeÚfdr'r'r(r0ôs.     ÿ þ          ÿ         þ           þ ÿ ÿ ø             zPopen.__init__cCs@d|jj›d|j›d|j›d�}t|ƒdkr<|dd…d}|S)NúéPéLz...>)rNr$r+rer«)r/Zobj_reprr'r'r(rOÝs ÿÿÿ zPopen.__repr__cCs|jSr*)rÞr3r'r'r(r�èszPopen.universal_newlinescCst|ƒ|_dSr*)rÛrÞ)r/r�r'r'r(r�îscCs | ||¡}| dd¡ dd¡S)Nz r±ú )ÚdecodeÚreplace)r/r²rÆrÇr'r'r(Ú_translate_newlinesòs zPopen._translate_newlinescCs|Sr*r'r3r'r'r(Ú __enter__öszPopen.__enter__cCsØ|jr|j ¡|jr |j ¡z^|jr2|j ¡W|tkrv|jdkrlz|j|jd�WntyjYn0d|_dS| ¡nT|tkrÊ|jdkr¸z|j|jd�Wnty¶Yn0d|_YdS| ¡0dS)Nrr†) r6rêr.r�ÚKeyboardInterruptrßÚ_waitrr‡)r/Úexc_typer8Ú tracebackr'r'r(Ú__exit__ùs2      ï   zPopen.__exit__cCsT|js dS|jdur(|d|jt|d�|j|d�|jdurPtdurPt |¡dS)Nzsubprocess %s is still running)ÚsourcerT)Ú_child_createdr+rÚÚResourceWarningrWrVrd)r/Z_maxsizeZ_warnr'r'r(rQs  ÿ z Popen.__del__cCs"t|dƒst tjtj¡|_|jS)NrÐ)r¹r©ræÚdevnullÚO_RDWRrÐr3r'r'r(Ú _get_devnull$s zPopen._get_devnullc Cs²|rZz|j |¡WnDty&Yn4tyX}z|jtjkrBn‚WYd}~n d}~00z|j ¡WnDtyzYn4ty¬}z|jtjkr–n‚WYd}~n d}~00dSr*)r�ÚwriteÚBrokenPipeErrorr¿ÚerrnoZEINVALrê)r/rŽr¢r'r'r(Ú _stdin_write)s"    zPopen._stdin_writec CsV|jr|rtdƒ‚|dur”|js”|j|j|jg d¡dkr”d}d}|jrT| |¡n6|jrp|j ¡}|j ¡n|jrŠ|j ¡}|j ¡|  ¡nº|dur¨t ƒ|}nd}z†z|  |||¡\}}Wndt �y(|durðt |j| |¡ƒ}n|j}d|_z|j|d�Wnt�y Yn0‚Yn0Wd|_nd|_0|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Ôr2r�r6r.ÚcountrÚreadrêr‡Ú_timeÚ _communicater ÚminrßÚ_remaining_timer r)r/rŽr=r6r.ÚendtimeÚsigint_timeoutÚstsr'r'r(rŸBsH ÿ       ÿ zPopen.communicatecCs| ¡S)zSCheck if child process has terminated. Set and return returncode attribute.)rWr3r'r'r(r¡†sz Popen.pollcCs|dur dS|tƒSdS)z5Convenience for _communicate when computing timeouts.N)r)r/rr'r'r(rŒszPopen._remaining_timecCsL|dur dS|stƒ|krHt|j||r0d |¡nd|r@d |¡ndd�‚dS)z2Convenience for checking if a timeout has expired.Nr)rž)rrrer–)r/rÚ orig_timeoutZ stdout_seqZ stderr_seqÚskip_check_and_raiser'r'r(Ú_check_timeout”sýzPopen._check_timeoutc Cs†|durtƒ|}z|j|d�WSty€|durJt|j| |¡ƒ}n|j}d|_z|j|d�WntyxYn0‚Yn0dS)z=Wait for child process to terminate; returns self.returncode.Nr†r)rr r rrßrr)r/r=rr r'r'r(r‡ s   ÿ z Popen.waitc Cst|ddƒ}t ¡�Ú}trX|dkr.| |j¡|dkrB| |j¡|dkrÊ| |j¡nr|dkr~|dkr~||kr~| tj|¡|dkr¤|dkr¤||kr¤| tj|¡|dkrÊ|dkrÊ||krÊ| tj|¡|durà| tj|¡Wdƒn1sô0Yd|_dS)NrÐr]T) r{Ú contextlibÚ ExitStackr ÚcallbackrKr©rêrà) r/rör÷rørùrúrûZ devnull_fdÚstackr'r'r(Ú_close_pipe_fds·s$    ,zPopen._close_pipe_fdsc Cs~|dur|dur|durdSd\}}d\}}d\}} |durtt tj¡}|durÜt dd¡\}} t|ƒ}t | ¡nh|tkr t dd¡\}}t|ƒt|ƒ}}n<|tkr¸t  |  ¡¡}n$t |t ƒrÎt  |¡}nt  |  ¡¡}| |¡}|du�r*t tj¡}|du�r˜t dd¡\} }t|ƒ}t | ¡nn|tk�rXt dd¡\}}t|ƒt|ƒ}}n@|tk�rrt  |  ¡¡}n&t |t ƒ�rŠt  |¡}nt  |  ¡¡}| |¡}|du�ræt tj¡} | du�rdt dd¡\} } t| ƒ} t | ¡n~|tk�rt dd¡\}} t|ƒt| ƒ}} nP|tk�r$|} n@|tk�r>t  |  ¡¡} n&t |t ƒ�rVt  |¡} nt  |  ¡¡} | | ¡} |||||| fS)ú|Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite N)r]r]r]r]r]r]©r]r]r)rPZ GetStdHandlerZ CreatePiperHrJrr rÝZ get_osfhandlerrÕrLÚfilenoÚ_make_inheritablerrr) r/r�r6r.rör÷rørùrúrûÚ_r'r'r(rÜØsp                        þzPopen._get_handlescCs&t t ¡|t ¡ddtj¡}t|ƒS)z2Return a duplicate of handle, which is inheritablerru)rPZDuplicateHandleZGetCurrentProcessZDUPLICATE_SAME_ACCESSrH)r/ÚhandleÚhr'r'r(r- s  ý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@dks$t |¡tjkr|’qS)é)rPZ GetFileTypeZFILE_TYPE_CHAR)Ú.0r/r'r'r(Ú 0s  ÿþz,Popen._filter_handle_list..)rG)r/rEr'r'r(Ú_filter_handle_list)szPopen._filter_handle_listc!CsŽt|tƒr nNt|tƒr.| r"tdƒ‚t|gƒ}n,t|tjƒrR| rFtdƒ‚t|gƒ}nt|ƒ}|durlt |¡}|dur|tƒ}n|  ¡}d| ||fv}|r¸|j t j O_ | |_ ||_||_|j}t|oÒd|voÒ|dƒ}|sæ|�r^|�r^|durøi}|_t| dg¡ƒ}|d<|�r0|t| ƒt|ƒt|ƒg7}| |¡|dd…<|�r^|�sZt dt¡d}| �rì|j t jO_ t j|_|�sÜtj d¡}|�sÈtj d d ¡}tj |d d ¡}tj |¡�sÈt d ƒ‚tj |¡�rà|}n|}d !||¡}|du�rt |¡}t" #d||||¡z@t  $||ddt| ƒ| |||¡ \}}}} W| %| | | |||¡n| %| | | |||¡0d|_&t'|ƒ|_(||_)t  *|¡dS)z$Execute program (MS Windows version)z$bytes args is not allowed on Windowsú0path-like args is not allowed when shell is trueNr]rEz?startupinfo.lpAttributeList['handle_list'] overriding close_fdsFZComSpecZ SystemRootr‘ZSystem32zcmd.exez:shell not found: neither %ComSpec% nor %SystemRoot% is setz {} /c "{}"úsubprocess.PopenT)+rÕráÚbytesrÖr¯r©ÚPathLikerªr#rFr?rPrr@rArBrDrÛrGrŒrLr4r×rØrÙrrrCÚenvironÚpathr–ÚisabsÚFileNotFoundErrorr”rXÚauditZ CreateProcessr)rrHÚ_handlerÚrJ)!r/rerìrírîrõrïrðrñròr°rör÷rørùrúrûZunused_restore_signalsZ unused_gidZ unused_gidsZ unused_uidZ unused_umaskZunused_start_new_sessionZuse_std_handlesZattribute_listZhave_handle_listrEZcomspecZ system_rootZhpZhtrÚÚtidr'r'r(rè6sž      ÿþ ÿ ÿ    ùþþ zPopen._execute_childcCs,|jdur&||jdƒ|kr&||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>)r/rUZ_WaitForSingleObjectZ_WAIT_OBJECT_0Z_GetExitCodeProcessr'r'r(rWµs  zPopen._internal_pollcCs^|durtj}n t|dƒ}|jdurXt |j|¡}|tjkrJt|j|ƒ‚t  |j¡|_|jS)z-Internal implementation of wait() on Windows.Niè) rPZINFINITErLr+ÚWaitForSingleObjectr>Z WAIT_TIMEOUTrreÚGetExitCodeProcess)r/r=Ztimeout_millisr­r'r'r(r Æs  ÿ  z Popen._waitcCs| | ¡¡| ¡dSr*)rdrrê)r/ZfhÚbufferr'r'r(Ú _readerthreadÖszPopen._readerthreadcCs\|jrBt|dƒsBg|_tj|j|j|jfd�|_d|j_|j ¡|j r„t|dƒs„g|_ tj|j|j |j fd�|_ d|j _|j  ¡|j r”|  |¡|jdurÆ|j | |¡¡|j ¡rÆt|j|ƒ‚|j durø|j  | |¡¡|j  ¡røt|j|ƒ‚d}d}|j�r|j}|j ¡|j �r0|j }|j  ¡|�r>|dnd}|�rP|dnd}||fS)NÚ _stdout_buff)ÚtargetreTÚ _stderr_buffr)r6r¹rDrÑZThreadrCZ stdout_threadZdaemonÚstartr.rFZ stderr_threadr�rr–rZis_aliverrerê)r/rŽrr"r6r.r'r'r(rÛsJ ÿÿ  ÿÿ          zPopen._communicatecCsl|jdurdS|tjkr"| ¡nF|tjkr>t |jtj¡n*|tjkrZt |jtj¡nt d  |¡ƒ‚dS)úSend a signal to the process.NzUnsupported signal: {}) r+r1ÚSIGTERMÚ terminateZ CTRL_C_EVENTr©rˆrÚZCTRL_BREAK_EVENTr2r”©r/Zsigr'r'r(Ú send_signal s     zPopen.send_signalcCsV|jdurdSzt |jd¡Wn0tyPt |j¡}|tjkrF‚||_Yn0dS)zTerminates the process.Nru)r+rPZTerminateProcessr>ÚPermissionErrorrAZ STILL_ACTIVE)r/Zrcr'r'r(rJs    zPopen.terminatec Cs,d\}}d\}}d\}} |dur"n@|tkr8t ¡\}}n*|tkrJ| ¡}nt|tƒrZ|}n| ¡}|durln@|tkr‚t ¡\}}n*|tkr”| ¡}nt|tƒr¤|}n| ¡}|dur¶nf|tkrÌt ¡\}} nP|tkrî|dkrâ|} n t j  ¡} n.|tk�r| ¡} nt|tƒ�r|} n| ¡} |||||| fS)r*r+Nr]) rr©Úpiper rrÕrLr,rrXÚ __stdout__) r/r�r6r.rör÷rørùrúrûr'r'r(rÜ0sL        þc Csò|durtj}i} |rJg} dD]"} tt| dƒ}|dur|  |¡q| | d<g}||| fD]}|dkrX| tj|f¡qX|df|df| dffD]"\}}|dkrŒ| tj||f¡qŒ|r¼|| d<tj|||fi| ¤Ž|_d |_ |  ||||| | ¡dS) z'Execute program using os.posix_spawn().N)ÚSIGPIPEZSIGXFZÚSIGXFSZZ setsigdefr]rrur§Ú file_actionsT) r©r9r{r1rdÚPOSIX_SPAWN_CLOSEÚPOSIX_SPAWN_DUP2r³rÚrr))r/rerìrðrórör÷rørùrúrûrŠZsigsetZsignameZsignumrRrZfd2r'r'r(Ú _posix_spawnfs8  ý þzPopen._posix_spawnc-st|ttfƒr|g}n(t|tjƒr6| r.tdƒ‚|g}nt|ƒ}| rlttdƒrPdnd}|dg|}ˆrlˆ|d<ˆdur||d‰t  dˆ|||¡t �rFtj   ˆ¡�rF|du�rF|�sF|�sF|du�rF| d ksÔ| d k�rF|d ksæ|d k�rF|d ksø|d k�rF|�sF|du�rF|du�rF|du�rF|dk�rF|  |ˆ||| | | |||¡ dSˆ}t ¡\}}g}|d k�r|| |¡t |¡}�qZ|D]}t |¡�q€�zh�z|du�ròg}| ¡D]>\}}t |¡}d |v�rÔtd ƒ‚| |d t |¡¡�q°nd}t ˆ¡‰tj   ˆ¡�rˆf} nt‡fdd„t |¡Dƒƒ} t|ƒ}!|! |¡t || |tttt|!ƒƒƒ||| | | ||||||||||||¡|_d|_Wt |¡n t |¡0|  | | | |||¡t!ƒ}"t "|d¡}#|"|#7}"|#�rðt#|"ƒdk�rÀ�qð�qÀWt |¡n t |¡0|"�rz6t $|jd¡\}$}%|$|jk�r<| %|%¡ntj&|_'Wnt(�yZYn0z|" )dd ¡\}&}'}(|( *¡}(Wn*t�y¤d}&d}'d +t|"ƒ¡}(Yn0t,t-|& *d¡t.ƒ})t/|)t0ƒ�r|'�rt|'dƒ}*|(dk}+|+�rìd}(|},n|},|*dk�rt 1|*¡}(|)|*|(|,ƒ‚|)|(ƒ‚dS)zExecute program (POSIX version)r5Zgetandroidapilevelz/system/bin/shz/bin/shz-crNr6r]r§r1ó=z!illegal environment variable namec3s"|]}tj t |¡ˆ¡VqdSr*)r©r:r–Úfsencode)r2Údir©rìr'r(Ú åsÿz'Popen._execute_child..TiPÃó:sSubprocessErroró0z#Bad exception data from child: {!r}ÚasciiéZnoexecr‘)2rÕrár7r©r8rÖrGr¹rXr=Ú_USE_POSIX_SPAWNr:ÚdirnamerUrNrdÚduprêrzrWr2r½Ú get_exec_pathÚsetÚaddÚ_posixsubprocessZ fork_execÚsortedr¨rLrÚrr)Ú bytearrayrr«ÚwaitpidÚ_handle_exitstatusrYr+ÚChildProcessErrorr¼rr”r{ÚbuiltinsrÚ issubclassr¿Ústrerror)-r/rerìrírîrõrïrðrñròr°rör÷rørùrúrûrórürýrþrÈrôZ unix_shellZorig_executableZ errpipe_readZ errpipe_writeZlow_fds_to_closeZlow_fdZenv_listÚkrjZexecutable_listZ fds_to_keepZ errpipe_dataÚpartrÚr!Zexception_nameZ hex_errnoÚerr_msgZchild_exception_typeZ errno_numZchild_exec_never_calledZ err_filenamer'rYr(rè�s  ÿÿ  ÿþýüûúúùùøø ÷ ö õ ô ó ý        þ ÷ þ      ÿ ÿ  þ    cCs$||ƒr||ƒ |_n ||ƒ|_dS)ú:All callers to this function MUST hold self._waitpid_lock.N)r+)r/r!Úwaitstatus_to_exitcodeZ _WIFSTOPPEDZ _WSTOPSIGr'r'r(ri1szPopen._handle_exitstatusc CsÈ|jdurÂ|j d¡sdSzšzF|jdur<|jWW|j ¡S||j|ƒ\}}||jkr`| |¡WnDty¦}z,|dur‚||_n|j|kr’d|_WYd}~n d}~00W|j ¡n |j ¡0|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Úrir¿r)r/rUZ_waitpidZ_WNOHANGZ_ECHILDrÚr!Úer'r'r(rW=s$    ñ  cCs<zt |j|¡\}}Wnty2|j}d}Yn0||fS)rqr)r©rhrÚrj)r/Z wait_flagsrÚr!r'r'r(Ú _try_wait`s   zPopen._try_waitcCsP|jdur|jS|durÔtƒ|}d}|j d¡r˜zX|jdurLW|j ¡qÒ| tj¡\}}||jkr~|  |¡W|j ¡qÒW|j ¡n |j ¡0|  |¡}|dkr¶t |j |ƒ‚t |d|dƒ}t |¡q&nv|jdu�rJ|j�P|jdu�rWdƒ�qJ| d¡\}}||jk�r(|  |¡WdƒqÔ1�s>0YqÔ|jS)z+Internal implementation of wait() on POSIX.Ngü©ñÒMb@?Frr§gš™™™™™©?)r+rrÒrsrtrvr©ÚWNOHANGrÚrirrrerÚtimeÚsleep)r/r=rZdelayrÚr!Z remainingr'r'r(r ms>     ù   þ     ,c Cs2|jrT|jsTz|j ¡Wnty,Yn0|sTz|j ¡WntyRYn0d}d}|jsŒi|_|jrzg|j|j<|jrŒg|j|j<|jrž|j|j}|jr°|j|j}| |¡|j rÊt |j ƒ}t ƒ��Ä}|jrî|rî|  |jt j¡|j�r|jj�s|  |jt j¡|j�r2|jj�s2|  |jt j¡| ¡�rˆ| |¡}|du�rv|dk�rv|j||||dd�tdƒ‚| |¡} | ||||¡| D]î\} } | j|ju�r0||j|jt…} z|jt | j| ¡7_Wn*t�y| | j¡| j ¡Yn*0|jt|j ƒk�r€| | j¡| j ¡nP| j|j|jfv�r”t | jd¡} | �sn| | j¡| j ¡|j| j | ¡�q”�q2Wdƒn1�sž0Y|j | |¡d�|du�rÎd !|¡}|du�râd !|¡}|j"�r*|du�r | #||jj$|jj%¡}|du�r*| #||jj$|jj%¡}||fS)NrT)r#zN_check_timeout(..., skip_check_and_raise=True) failed to raise TimeoutExpired.i€r†r))&r�rÔÚflushrrêZ_fileobj2outputr6r.Ú _save_inputrÓÚ memoryviewÚ_PopenSelectorÚregisterÚ selectorsZ EVENT_WRITErIZ EVENT_READZget_maprr$Ú RuntimeErrorÚselectZfileobjÚ _input_offsetÚ _PIPE_BUFr©rrZ unregisterr«rrdr‡r–rÞrrÆrÇ)r/rŽrr"r6r.Z input_viewZselectorr=ZreadyÚkeyZeventsÚchunkr²r'r'r(r–s              þÿ  ÿ     :     þ þcCsF|jrB|jdurBd|_||_|durB|jrB|j |jj|jj¡|_dS)Nr)r�rÓr‚rÞÚencoderÆrÇ)r/rŽr'r'r(r{üs ÿzPopen._save_inputcCs@| ¡|jdurdSzt |j|¡Wnty:Yn0dS)rHN)r¡r+r©rˆrÚÚProcessLookupErrorrKr'r'r(rLs  cCs| tj¡dS)z/Terminate the process with SIGTERM N)rLr1rIr3r'r'r(rJ(scCs| tj¡dS)z*Kill the process with SIGKILL N)rLr1ÚSIGKILLr3r'r'r(rˆ-sz Popen.kill)r]NNNNNTFNNNNrTFr')NN)F)N):r$r%r&r:rr0rOr˜r™ršr›r;r�r<rr rrXrYr×rØrQrrrŸr¡rr$r‡r)r rÜr-r4rèrPr@Z WAIT_OBJECT_0rArWr rCrrLrJrˆrUr©rrÚ WIFSTOPPEDÚWSTOPSIGrirhrwrZECHILDrvr{r'r'r'r(r¼s†5úù j    D ÿ H  ý 26'&ý ÿ # )f  r)Lr:rkrrår©rxr1rXrÑr×r%rrr™rãÚ ImportErrorrâÚ__all__rÝrPr ÚModuleNotFoundErrorrer�rrrrrrrrrrrrrrrrr r!r"r€Ú Exceptionrr rr#rLrHr{rƒr¹rRr}ZSelectSelectorrVrSrrr rfr…rrr Úobjectrr r¯rr rÂr_rr'r'r'r(Ú s€"        P  %      ;3%ÿ EI /