\dnYdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddlm Z ddlZ ddlZn #e$rdZYnwxYwgdZ ddlZdZn #e$rdZYnwxYwejdvZerDddlZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)e*gd n@er*dd l+m,Z-ej.Z/ej0Z1ej2Z3ej4Z5ej6Z7n dZ-dZ/dZ1dZ3dZ5dZ7ddl8Z8ddl9Z9Gd d e:Z;Gd de;Z<Gdde;Z=erGddZ>Gdde?Z@n(eAe8ddZBeCe9dre9jDZEne9jFZEerdZGdZHngZGdZHdZIdZJdZKdZLdZMdZNdd d!ZOd"ZPdd d#ZQGd$d%eRZSddddd&d'ZTd(ZUddd)d*ZVddd)d+ZWd,ZXeXZYdZZGd-d.Z[dS)/aSubprocesses 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>wasi emscripten)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 STARTUPINFOrrrrr r!r"r#r$r%) fork_execceZdZdS)rN)__name__ __module__ __qualname__..\python\lib\subprocess.pyrr{sr-rcVeZdZdZddZdZedZejdZdS)r zRaised when run() is called with check=True and the process returns a non-zero exit status. Attributes: cmd, returncode, stdout, stderr, output Nc>||_||_||_||_dSN) returncodecmdoutputstderr)selfr2r3r4r5s r.__init__zCalledProcessError.__init__s"$  r-c|jrS|jdkrHd|jdtj|j dS#t$rd|j|j fzcYSwxYwd|j|jfzS)Nr Command 'z ' died with .z)Command '%s' died with unknown signal %d.z.Command '%s' returned non-zero exit status %d.)r2r3signalSignals ValueErrorr6s r.__str__zCalledProcessError.__str__s ? /t22 4&.$/1A"B"B"B"BDD 4 4 4B4?"2F44444 4DHdoG// /s%9AAc|jS)z+Alias for output attribute, to match stderrr4r>s r.stdoutzCalledProcessError.stdouts {r-c||_dSr1rAr6values r.rBzCalledProcessError.stdout r-NN r)r*r+__doc__r7r?propertyrBsetterr,r-r.r r ~sy  / / /X ]]r-r cVeZdZdZddZdZedZejdZdS)rzThis exception is raised when the timeout expires while waiting for a child process. Attributes: cmd, output, stdout, stderr, timeout Nc>||_||_||_||_dSr1)r3timeoutr4r5)r6r3rNr4r5s r.r7zTimeoutExpired.__init__s"   r-c(d|jd|jdS)Nr9z' timed out after z seconds)r3rNr>s r.r?zTimeoutExpired.__str__s4<<<) *r-c|jSr1rAr>s r.rBzTimeoutExpired.stdouts {r-c||_dSr1rArDs r.rBzTimeoutExpired.stdoutrFr-rGrHr,r-r.rrsy  ***X ]]r-rc*eZdZddddddddZdZdS)r&rNdwFlags hStdInput hStdOutput hStdError wShowWindowlpAttributeListcb||_||_||_||_||_|pdgi|_dS)N handle_listrS)r6rTrUrVrWrXrYs r.r7zSTARTUPINFO.__init__s>"DL&DN(DO&DN*D #2#I}b6ID r-c|j}d|vrt|d|d<t|j|j|j|j|j|S)Nr[rS) rYcopylistr&rTrUrVrWrX)r6 attr_lists r.r]zSTARTUPINFO.copysk,1133I ))+/ -0H+I+I -(t|)-*./)-+/+;/8 ::: :r-)r)r*r+r7r]r,r-r.r&r&sO&'4D#D J J J J J : : : : :r-r&c6eZdZdZejfdZdZdZeZ dS)HandleFc<|jsd|_||dSdS)NT)closed)r6 CloseHandles r.Closez Handle.Closes3; ""  D!!!!! " "r-cZ|jsd|_t|Std)NTzalready closed)rcintr=r>s r.Detachz Handle.Detachs.; !" 4yy -.. .r-c>d|jjt|fzS)Nz%s(%d)) __class__r)rgr>s r.__repr__zHandle.__repr__st~6D BB Br-N) r)r*r+rc_winapirdrerhrk__del__r,r-r.rarasU$+$7 " " " "  / / /  C C Cr-raPIPE_BUFi PollSelectorcdSr1r,r,r-r._cleanuprqs r-ctdStddD]P}|tj}|, t|@#t $rYLwxYwQdS)N _deadstate)_active_internal_pollsysmaxsizeremover=)instress r.rqrq s ? FAAAJ  D%%%==CNN4((((!D  sA A&%A&cng}tjj}|dkr|dd|zz|S)zgReturn a list of command-line arguments reproducing the current optimization settings in sys.flags.r-O)rwflagsoptimizeappend)argsrEs r."_optim_args_from_interpreter_flagsr"s< D I E qyy C#+%&&& Kr-cddddddd}t}|D]@\}}ttj|}|dkr|d ||zzAtjjr|d nrtjjr|d tjjr|d tjj r|d tj dd}ttdi}tjj }tjj }|dkr| dn|r| d|r| d|D]}|d|z|r|ddD]3}||vr-||} | dur|} n|d| } |d| f4|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_warningquietrrz-Iz-Ez-sz-PN _xoptionszerror::BytesWarningzdefault::BytesWarningdefaultz-W)-Xdev) faulthandler tracemalloc importtime showrefcountutf8T=r)ritemsgetattrrwrrisolatedignore_environment no_user_site safe_path warnoptionsrdev_moderyextend) flag_opt_maprflagoptrwarnoptsxoptionsrrrEargs r._args_from_interpreter_flagsr,s4 #  L . / /D!''))'' c CIt $ $ q55 KKcAg & & & y D 9 '  KK    9 !  KK    9   KK   qqq!HsK,,HI+My!Hq-.... 1/000# """   D3J# M"""(%% (??SME}}!$ee, KKs $ $ $ Kr-c8tjjrdtj}|jj}d}|jx}r|jj|krn|dz }|jx}tjdt|tjj rdStj S)Nrz"'encoding' argument not specified.zutf-8) rwrwarn_default_encoding _getframef_code co_filenamef_backwarningswarnEncodingWarning utf8_modelocale getencoding)ffilename stacklevels r._text_encodingris y& 3 MOO8' 8ma x#x// !OJ8ma   :%z 3 3 3 y$w!###r-rNct|i|5} ||cdddS#|xYw#1swxYwYdS)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)rN popenargskwargsps r.rr}s  $V $ $ 66'6**  FFHHH  s A 1AA  AAct|i|}|r/|d}||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"]) rNr)rgetr )rrretcoder3s r.rrsRI(((G/jj   ;A,C #... 1r-c@dD]}||vrt|dd|vrf|d^|ds?|ds*|ds|drd }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. )rBcheckz- argument not allowed, it will be overridden.inputNuniversal_newlinestextencodingerrorsr-T)rBrNr)r=rr rrB)rNrrkwemptys r.r r sF"SS <<QQQRR R &VG_4 ::* + + vzz&/A/A VZZPZE[E[ ::h'' EEEw  $t     r-cFeZdZdZddZdZeejZ dZ 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). Nc>||_||_||_||_dSr1)rr2rBr5)r6rr2rBr5s r.r7zCompletedProcess.__init__s" $  r-cd|jd|jg}|j-|d|j|j-|d|jdt |jd|S)Nz args={!r}zreturncode={!r}z stdout={!r}z stderr={!r}z{}({})z, ) formatrr2rBrr5typer)join)r6rs r.rkzCompletedProcess.__repr__s""49--!((99; ; " KK ,,T[99 : : : ; " KK ,,T[99 : : :tDzz2DIIdOODDDr-c`|jr&t|j|j|j|jdS)z6Raise CalledProcessError if the exit code is non-zero.N)r2r rrBr5r>s r.check_returncodez!CompletedProcess.check_returncodes9 ? 2$T_di%)[22 2 2 2r-rG) r)r*r+rIr7rk classmethodtypes GenericAlias__class_getitem__rr,r-r.rrsh   EEE$ E$67722222r-r)rcapture_outputrNrc|.|dtdt|d<|rM|d|dtdt|d<t|d<t|i|5} |||\}}ny#t $rW} |tr"|\| _| _ n| d} ~ w|xYw| } |r| rt| |j ||dddn #1swxYwYt|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.rBr5z@stdout and stderr arguments may not be used with capture_output.rr4r5)rr=rr communicaterr _mswindowsrBr5rpollr rr) rrrNrrrprocessrBr5excrs r.r r s<  ::g   *NOO Ow ::h   +vzz(/C/C/O455 5xx  $V $ $C $000HHNFFF    LLNNN  *1)<)<)>)>& CJJ    LLNNN ,,..  CW C$Wgl,26CCC C/CCCCCCCCCCCCCCC2 GL'66 B BBs7 EB)(E) D3ADD3EE"%E"cg}d}ttj|D]}g}|r|dd|vpd|vp| }|r|d|D]}|dkr|||dkr@|dt |zdzg}|dd|r||g}|||r|||r*|||dd|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  "\rz\"r)maposfsdecoderlenrr)seqresult needquoterbs_bufcs r. list2cmdliner@s~<FI2;$$!!   MM#   CZ>> 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)shellrr5rrrNr| )r rr r4r2)r3rrdataexitcodeexs r.r r s*!Ct$v%-f>>> !!!y=! BCCyDCRCy T>s A<Ac2t|||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' rr)r )r3rrs r.r r s 3& A A A! DDr-ctsttdsdStjdvrdS tjd}|d}t|dkrt|d }ttt|dd }tjd kr|d kr|d krdSn#tttf$rYnwxYwdS)aCheck 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)darwinsunos5TCS_GNU_LIBC_VERSIONr)maxsplitrrr:linuxglibc)r)rhasattrrrwplatformconfstrsplitrr=tuplerrgAttributeErrorOSError)verpartslibcversions r._use_posix_spawnrs]33u |+++t j.// 1 %% u::?? QxCq!4!45566 <7 " "tw7g;M;M4 J 0     5sB#CC0/C0c eZdZdZdZ d0dddddddddd d Zd Zeej Z e d Z e j d Z d ZdZdZejejfdZdZdZd1dZdZdZ d2dZd3dZdZejdZ e!r6dZ"dZ#dZ$dZ%de&j'e&j(e&j)fdZ*dZ+d Z,d!Z-d"Z.d#Z/e/Z0dSd$Z"d%Z1d&Z%e2e3e4fd'Z5de6e7e8j9fd(Z*d)Z:d*Z+d+Z-d,Z;d-Z.d.Z/d/Z0dS)4rar 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) process_group (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,) usergroup extra_groupsrrrumaskpipesize process_groupc ts'ttjtjdt tj|_ d|_ d|_ |d}t|tstd|d}t|tstdtr|t!dnF|r|st#jdt&d }| t!d |d krt!d ||_d|_d|_d|_d|_d|_||_||_||_|1| /t;| t;|krt=d |p|p|p| |_|jr|tAx|_}d|_!d|_"|jr |dkrd }d}nd}|d}d}|tGtHdst!dt|tJr> d dl&}n#tN$rt!dwxYw|(|j)}nGt|tr|}n/td*tW||d krt!d|d}|+tGtHdst!dt|tJrt!dg}|D]}t|tJrQ d dl&}n#tN$rt!dwxYw|,|(|j)ht|tr|,|td*tW||D]} | d krt!d| d}!|tGtHdst!dt|tJr> d dl-}"n#tN$rt!dwxYw|".|j/}!n't|tr|}!ntd|!d krt!d|!|0|||\}#}$}%}&}'}(tr|$dkr'tcj2|$3d }$|%dkr'tcj2|%3d }%|'dkr'tcj2|'3d }' |$dkrEtij5|$d||_|jr#tij6|jd ||| |_|%dkrCtij5|%d!||_|jr!tij6|j||"|_|'dkrCtij5|'d!||_|jr!tij6|j||"|_|7|||||| | | || |#|$|%|&|'|(||||!|||dS#tqd|j|j|jfD]'}) |)9#t$rY$wxYw|j"sg}*|ttkr|*,|#|ttkr|*,|&|ttkr|*,|(tG|d#r|*,|j;|*D]X}+ tr*t|+txr|+=ntIj9|+I#t$rYUwxYwxYw)$zCreate new Popen instance.z does not support processes.NFr|zbufsize 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.g?rsetregidz>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_bufferingrrrbr_devnull)>_can_fork_execrerrnoENOTSUPrwr rq threadingLock _waitpid_lock_input_communication_started isinstancerg TypeErrorrr=rrRuntimeWarningrrrBr5pidr2rrrboolr text_moder_sigint_wait_secs_closed_child_pipe_fdsr rstrgrp ImportErrorgetgrnamgr_gidrrrpwdgetpwnampw_uid _get_handlesmsvcrtopen_osfhandlerhioopen TextIOWrapper_execute_childfiltercloserr$rare),r6rbufsize executablerrBr5 preexec_fn close_fdsrcwdenvr startupinfo creationflagsrestore_signalsstart_new_sessionpass_fdsrrrrrrrrrr"gidr6gids extra_group gid_checkuidr:p2creadp2cwritec2preadc2pwriteerrreaderrwriterto_closefds, r.r7zPopen.__init__'s   #,LLL   '^-- &+# ?G'3'' :899 9  H(C(( ;9:: :  .% "-...&  !  ! >OOO & "-...!! "-...           !3!?'((DJJ66!#FGG G"IVItI7I > 8h.'5'7'7 7DMH "&&+# > '!||!%!&  M  2z** 6 "4555E3'' 6JJJJJ"JJJ$&IJJJJll5))0E3'' 6 N!'U !4!4666Qww !JS!J!JKKK  #2{++ H "EFFFL#.. H !FGGGD+ @ @ k3//@7" &777(*67777 KK [ 9 9 @AAAA S11@KK ,,,,#%9%+VD,=,=%>%>@@@ " V V q==$%T%T%TUUU!  2z** G "8999D#&& GJJJJJ"JJJ$&IJJJJll4((/D#&& G EFFFQww !IC!I!IJJJ&#//vvFF ( ( (  E2~~!01B1BAFF"}} /0@0@!DD"}} /0@0@!DD6 2~~WXtW== >>!#!1$*D+9%-f">">">DJ"}} ggtW== >>"$"24;%-f#>#>#>DK"}} ggtW== >>"$"24;%-f#>#>#>DK   j*i (#s +]E ' ' ' / #T3 1= B B B B B D4:t{DK"HII  GGIIIID. D==OOG,,,T>>OOH---T>>OOH---4,,3OODM222"B%)*R*@*@)HHJJJJHRLLL" s{HH2LL7P""P<DY&^ 7Z  ^  Z^ ZB^ 4A]:9^ : ^^ ^^ cd|jjd|jd|jd}t |dkr |dddz}|S)NPLz...>)rjr)r2rr)r6obj_reprs r.rkzPopen.__repr__(sr B' B B? B B379 B B B  x==2  }v-Hr-c|jSr1)r2r>s r.rzPopen.universal_newlines3s ~r-c.t||_dSr1)r1r2)r6rs r.rzPopen.universal_newlines9s011r-c|||}|ddddS)Nz r )decodereplace)r6rrrs r._translate_newlineszPopen._translate_newlines=s9{{8V,,||FD))11$===r-c|Sr1r,r>s r. __enter__zPopen.__enter__As r-cV|jr|j|jr|j |jr|j|tkrA|jdkr- ||jn#t$rYnwxYwd|_dS|dS#|tkrC|jdkr- ||jn#t$rYnwxYwd|_YdS|wxYw)Nrr) rBrEr5rKeyboardInterruptr3_waitrr)r6exc_typerE tracebacks r.__exit__zPopen.__exit__Ds_ ; K      ; K      z #   """,,,)A-- 4+A BBBB))*& IIKKKKK#,,,)A-- 4+A BBBB))*& IIKKKKsH C9B B"!B"D(C87D(8 DD(D D(D(c|jsdS|j|d|jzt||||j#t t |dSdSdS)Nzsubprocess %s is still running)sourcers)_child_createdr2r0ResourceWarningrvrur)r6_maxsize_warns r.rmz Popen.__del__`s"  F ? " E2TX=!$ 0 0 0 0 x000 ? "w': NN4  # "':':r-ct|ds.tjtjtj|_|jS)Nr$)r rrAdevnullO_RDWRr$r>s r. _get_devnullzPopen._get_devnullos3tZ(( ;GBJ ::DM}r-c^|rU |j|n9#t$rYn-t$r!}|jtjkrnYd}~nd}~wwxYw |jdS#t$rYdSt$r"}|jtjkrnYd}~dSd}~wwxYwr1)rwriteBrokenPipeErrorrr&EINVALrE)r6rrs r. _stdin_writezPopen._stdin_writets      ''''"      9 ,,DDDD    J           DD   yEL(( s7 A AAAA44 B, B, B''B,c|jr|rtd||js|j|j|jgddkrd}d}|jr||ns|jr3|j}|jn9|jr2|j}|j| n|t|z}nd} | |||\}}np#t$rc|)t|j||}n|j}d|_ ||n#t"$rYnwxYwwxYw d|_n #d|_wxYw| ||}||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)r,r=rrBr5countrreadrEr_time _communicaternminr3_remaining_timeror)r6rrNrBr5endtimesigint_timeoutstss r.rzPopen.communicates&$  & O5 OMNN N OD$?O Zdk 2 8 8 > >! C CFFz $!!%(((( $))++ !!#### $))++ !!### IIKKKK"''G+ 3!%!2!25'7!K!K$   &%()?)-)=)=g)F)F&H&HNN&*%;N)*&JJ~J6666%D "/3++d+2222))D$8$8$A$A)BBCsC D('F!(AF,FF F FFFF!! F*c*|S)zSCheck if child process has terminated. Set and return returncode attribute.)rvr>s r.rz Popen.polls""$$$r-c,|dS|tz S)z5Convenience for _communicate when computing timeouts.N)r)r6rs r.rzPopen._remaining_times ?4UWW$ $r-c|dS|st|krFt|j||rd|nd|rd|nddS)z2Convenience for checking if a timeout has expired.Nr-r)rrrr)r6r orig_timeout stdout_seq stderr_seqskip_check_and_raises r._check_timeoutzPopen._check_timeouts ? F  I577W#4#4 I|3=G388J///43=G388J///4III I$5#4r-c6|t|z} ||S#t$rc|)t|j||}n|j}d|_ ||n#t $rYnwxYwwxYw)z=Wait for child process to terminate; returns self.returncode.Nrr)rrornrr3rr)r6rNrrs r.rz Popen.waits  gg'G ::g:.. .     "!$T%;%)%9%9'%B%B"D"D"&!7%&D "  > 2222!      s.+AB/BB BBBBct|dd}tj5}tra|dkr||j|dkr||j|dkr||jn|dkr,|dkr&||kr |t j||dkr,|dkr&||kr |t j||dkr,|dkr&||kr |t j|| |t j|dddn #1swxYwYd|_dS)Nr$r|T) r contextlib ExitStackrcallbackrerrEr4) r6rVrWrXrYrZr[ devnull_fdstacks r._close_pipe_fdszPopen._close_pipe_fdss T:t44  ! # # 5u 7b==NN7=111r>>NN8>222r>>NN8>222b==X^^:8M8MNN28W555r>>gmmJ8N8NNN28X666r>>gmmJ8N8NNN28X666%rx444# 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5('+###sD!EEEc#2Kg} |VdS#t|dr||j|`|D]X} tr*t |t r|ntj|I#t$rYUwxYwxYw)zCHelper to ensure file descriptors opened in _get_handles are closedr$N) r rr$rr-rarerrEr)r6r\r]s r._on_error_fd_closerzPopen._on_error_fd_closers NNNNN tZ(( " ...M  !%jV&<&<%  D s- 2BABB BBBBc |||dSd\}}d\}}d\}} |5} |qtjtj}|Ptjdd\}} t |}| |tj| n|tkrNtjdd\}}t |t |}}| ||fn|tkr'tj | }nPt|trtj |}n&tj |}||}|qtjtj}|Ptjdd\} }t |}| |tj| n|tkrNtjdd\}}t |t |}}| ||fn|tkr'tj | }nPt|trtj |}n&tj |}||}|qtjtj} | Ptjdd\} } t | } | | tj| n|tkrNtjdd\}} t |t | } }| || fn|t(kr|} n|tkr'tj | } nPt|trtj |} n&tj |} || } dddn #1swxYwY|||||| fS)|Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite N)r|r|r|r|r|r|r|r|r)rrl GetStdHandler CreatePiperarrdrrrr> get_osfhandler|r-rgfileno_make_inheritablerrr) r6rrBr5rVrWrXrYrZr[ err_close_fds_s r.r=zPopen._get_handles7sd}FN// & GX & GX & GX))++= <}=%273KLLG%,%7a%@%@ "(//%,,W555+A...d]](/(:4(C(C%GX(.w9I9IXG!(('8)<====g%%$243D3D3F3FGGGGs++C$2599GG%25<<>>BBG0099>&3G4MNNH'&-&8q&A&A 8#)(#3#3%,,X666+A...t^^(/(:4(C(C%GX(.w9I9IXG!(('8)<====w&&%3D4E4E4G4GHHHH,,E%3F;;HH &3FMMOODDH11(;;>&3G4LMMH'&-&8q&A&A 8#)(#3#3%,,X666+A...t^^(/(:4(C(C%GX(.w9I9IXG!(('8)<====v%%'HHw&&%3D4E4E4G4GHHHH,,E%3F;;HH &3FMMOODDH11(;;{= <= <= <= <= <= <= <= <= <= <= <= <= <= <= <~XXX' 'sP8Q00Q47Q4ctjtj|tjddtj}t |S)z2Return a duplicate of handle, which is inheritablerr)rlDuplicateHandleGetCurrentProcessDUPLICATE_SAME_ACCESSra)r6handlehs r.rzPopen._make_inheritablesF')++V)++Q-//A!99 r-c4td|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.chh|]/}|dzdks"tj|tjk-|0S))rl GetFileTypeFILE_TYPE_CHAR).0rs r. z,Popen._filter_handle_list..sT444F"SLC//#/77#233 333r-)r^)r6r[s r._filter_handle_listzPopen._filter_handle_lists144k44455 5r-c N|r Jdt|trnt|tr"| rtdt |g}nKt|t jr"| rtdt |g}nt |}|t j|}|t}n| }d| ||fv}|r/|xj tj zc_ | |_ ||_||_|j}t#|o d|vo|d}|s|r|r| ix}|_t%|dgx}|d<|r/|t)| t)|t)|gz }|||dd<|r|st-jdt0d}| r|xj tjzc_ tj|_|st jd }|sot jd d }t j|d d }t j|stAdt j|r|}n|}d!||}|t j|}tEj#d|||| tj$||ddt)| | ||| \}}} }!|%| | | |||n#|%| | | |||wxYwd|_&tO||_(| |_)tj*|dS)z$Execute program (MS Windows version)z"pass_fds not supported on Windows.z$bytes args is not allowed on Windows0path-like args is not allowed when shell is trueNr|r[z?startupinfo.lpAttributeList['handle_list'] overriding close_fdsFComSpec SystemRootrSystem32zcmd.exez:shell not found: neither %ComSpec% nor %SystemRoot% is setz {} /c "{}"subprocess.PopenT)+r-r5bytesr.rrPathLikerr&r]rTrlrrUrVrWrYr1r^rrgrrrr/rrrXenvironpathrisabsFileNotFoundErrorrrwaudit CreateProcessrrura_handler0rd)"r6rrGrHrIrPrJrKrLrMrrVrWrXrYrZr[unused_restore_signals unused_gid unused_gids unused_uid unused_umaskunused_start_new_sessionunused_process_groupuse_std_handlesattribute_listhave_handle_listr[comspec system_roothphtr0tids" r.rCzPopen._execute_childs  E E!E E E E$$$ *D%(( *L#$JKKK#TF++D"+.. *5#%4555#TF++#D))%[44 ")mm *..00  (H(EEO 1##w'CC##(/ %)1 &(0 %(8N#N%B$1^$C%B$2=$A C C    &O &  &!)CEEN[%@++M2>>??@ n];#PCLL#h--X#OOK!%!9!9+!F!F AAA&$N '=>LNNN !&I ;##w'CC##*1/ '!) !jnnY77G"r&(jnn\2&F&F "$',,{J "R"R!w}}W55r"34p"q"qqw}}W---%, (G#**GT::k#&& I(*dC E E E 8#*#8T)-t),]););)6),),)4$6$6 BS$$Wh%,h%,h8888$$Wh%,h%,h8888 #'D !"::DLDH   # # # # #s /MM,cr|j*||jd|kr||j|_|jS)zCheck 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)r2r)r6rt_WaitForSingleObject_WAIT_OBJECT_0_GetExitCodeProcesss r.rvzPopen._internal_pollsB&'' a88NJJ&9&9$,&G&GDO? "r-c| tj}nt|dz}|j]tj|j|}|tjkrt|j|tj |j|_|jS)z-Internal implementation of wait() on Windows.Ni) rlINFINITErgr2WaitForSingleObjectr WAIT_TIMEOUTrrGetExitCodeProcess)r6rNtimeout_millisrs r.roz Popen._wait,s!(!1!$Wt^!4!4& 4T\5CEEW111(G<<<")"t^^(* %GX!(('8)<===}q((WUN-K-K( He.@$-PPPw&&#0022HH,,/%HH &}}H>t^^(* %GX!(('8)<===}q((WUN-K-K( He.@$-PPPv%%2~~#+#&>#8#8#:#:w&&#0022HH,,/%HH &}}Hc1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /fXXX' 'sJK  KKc | tj}i} |r9g} dD]/} tt| d}|| |0| | d<g}||| fD])}|dkr!|tj|f*|df|df| dffD]-\}}|dkr"|tj||f.|r|| d<tj|||fi| |_d |_ | ||||| | dS) z'Execute program using os.posix_spawn().N)SIGPIPESIGXFZSIGXFSZ setsigdefr|rrr file_actionsT) rrrr;rPOSIX_SPAWN_CLOSEPOSIX_SPAWN_DUP2rr0rur)r6rrGrKrNrVrWrXrYrZr[rsigsetsignamesignumrr]fd2s r. _posix_spawnzPopen._posix_spawnse {jF -?..G$VWd;;F) f---&,{#L'2 D D88 '')=r(BCCC! 1 1  H HC 88 '')t|tjr| rt d|g}nt |}| r'ttdrdnd}|dg|z}r|d<|dtj d|||trtj r`|^|s\|sZ|X| d ks| d krL|d ks|d kr@|d ks|d kr4|s2|d kr,|*|(|&|dkr | |||| | | ||| dS}tj\}}g}|d kr/||tj|}|d k/|D]}tj| |qg}|D]Y\}} tj|}d |vrt)d ||d ztj| zZnd}tjtj rf}!n-t+fdtj|D}!t/|}"|"|t3||!|t+t5t7t8|"||| | | |||||||||||||t:|_d|_tj|n#tj|wxYw| | | | |||tC}# tj"|d}$|#|$z }#|$rtG|#dkrn1 tj|n#tj|wxYw|#r] tj$|jd\}%}&|%|jkr|%|&ntj&|_'n#tP$rYnwxYw |#)dd \}'}(})|)*})n6#t($r)d}'d}(d+t|#})YnwxYwtYtZ|'*dt\}*t_|*t`rH|(rFt9|(d}+|)dk},|,rd})|}-n|}-|+dkrtj1|+})|*|+|)|-|*|)dS)zExecute program (POSIX version)rgetandroidapilevelz/system/bin/shz/bin/shz-crNrr|rr=z!illegal environment variable namec3|K|]6}tjtj|V7dSr1)rrrfsencode)rdirrGs r. z'Popen._execute_child..VsQ0>0> #GLLS)9)9:FF0>0>0>0>0>0>r-TiP:sSubprocessError0z#Bad exception data from child: {!r}asciinoexecr)2r-r5rrrr.r^r rwr_USE_POSIX_SPAWNrdirnamer rrduprErrr=r  get_exec_pathsetadd _fork_execsortedrrg _USE_VFORKr0rur bytearrayrrwaitpid_handle_exitstatusrxr2ChildProcessErrorr rhrrbuiltinsr issubclassrstrerror).r6rrGrHrIrPrJrKrLrMrrVrWrXrYrZr[rNrQrRrUrrOr unix_shellorig_executable errpipe_read errpipe_writelow_fds_to_closelow_fdenv_listkrexecutable_list fds_to_keep errpipe_datapartr0rexception_name hex_errnoerr_msgchild_exception_type errno_numchild_exec_never_called err_filenames. ` r.rCzPopen._execute_childs0$e -- "vD"+.. "5#%4555vDzz )"#';<<L..BK"D)D0)(DG!!!W I(*dC E E E   33 "*%+$+  B'A++!R8a<<!R8a<<-,8%++    !!$ C")8")8")8555(O +-')) 'L-! !## '' 666 "} 5 5  !##+ ! !    7 '&, #%$'IIKKGGDAq " AA#qyy&01T&U&U U$OOAHr{1~~,EFFFF G $(!#Z!8!8Jwz22>+5-+00>0>0>0>')'7'<'<0>0>0>+>+>#&h--KOOM222) /%uVC[4I4I-J-J'K'K#Xw#X(-+->)3c5&  4 4DH+/D'H]++++BH]++++$$Wh%,h%,h888 ){{ 7<77D D(L3|#4#4u#<#< &&&&&&&&% 4!z$(A66HCdh//4444*-+(D 7(..tQ777NIw &nn..GG!777%7N $ICJJ"' "5"577GGG7 (/ ."7"7"@"@'()()$2G<< Q Q #Ir 2 2I/6(/B+.7"$'* '6  A~~"$+i"8"8..y'<PPP**7333K% 4% 4sEE L;NL&&ANN/6AP PP.Q0Q98Q9cb||r|| |_dS|||_dS):All callers to this function MUST hold self._waitpid_lock.N)r2)r6r_waitstatus_to_exitcode _WIFSTOPPED _WSTOPSIGs r.r#zPopen._handle_exitstatussA{3 ?#,9S>>/"9"9#">">r-c|j|jdsdS |j |j|jS||j|\}}||jkr||n3#t $r&}|||_n|j|krd|_Yd}~nd}~wwxYw|jn#|jwxYw|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)r2r*acquirereleaser0r#rr&)r6rt_waitpid_WNOHANG_ECHILDr0res r.rvzPopen._internal_polls&)11%88  412#&..0000 (x(;;HCdh//444 , , ,!-*4G++ +, ,&..0000D&..0000? "s5 B 4BC B1 B,'C,B11CC)cz tj|j|\}}n#t$r |j}d}YnwxYw||fS)r<r)rr"r0r$)r6 wait_flagsr0rs r. _try_waitzPopen._try_waitsY Z*== cc$   h   : s  66c|j|jS|Vt|z}d} |jdr |j |jn}|t j\}}||jks|dksJ||jkr1| | |jn |jn#|jwxYw| |}|dkrt|j |t|dz|d}tj|B|jr|j5|j dddnV|d\}}||jkr| |dddn #1swxYwY|jr|jS)z+Internal implementation of wait() on POSIX.NgMb@?TFrrg?)r2rr*rArBrIrWNOHANGr0r#rrrrtimesleep)r6rNrdelayr0r remainings r.roz Popen._waitsS*&"''G+&)11%88 9 9#: %!.668888 *. )C)CJS##&$(??cQhhhh"dh $ 7 7 < < < % .668888 /!.668888D.668888 $ 4 4W = =I A~~,TY@@@ 9c::EJu%%%!&$o-+99?6!9999999&*^^A%6%6 c$(?? 33C888999999999999999o-? "s+C0$AC00D 6 G 8GGGc< |jr_|jsX |jn#t$rYnwxYw|s+ |jn#t$rYnwxYwd}d}|js3i|_|jrg|j|j<|jrg|j|j<|jr|j|j}|jr|j|j}|||j rt|j }t5}|jr'|r%| |jtj|jr1|jjs%| |jtj|jr1|jjs%| |jtj|r||}|/|dkr)|||||dt)d||} |||||| D]v\} } | j|jur||j|jt0z} |xjt3j| j| z c_|jt9|j kr3|| j| j#t$r6|| j| jYwxYw| j|j|jfvrtt3j| jd} | s3|| j| j|j| j| x|dddn #1swxYwY| |||d!|}|d!|}|j"rZ|+|#||jj$|jj%}|+|#||jj$|jj%}||fS)NrT)rzN_check_timeout(..., skip_check_and_raise=True) failed to raise TimeoutExpired.irr-)&rr,flushrrE_fileobj2outputrBr5 _save_inputr+ memoryview_PopenSelectorregister selectors EVENT_WRITErc EVENT_READget_maprr RuntimeErrorselectfileobj _input_offset _PIPE_BUFrr~r]r unregisterrrrrr2rjrr)r6rrrrBr5 input_viewselectorrNreadykeyeventschunkrs r.rzPopen._communicatesUz $"= J$$&&&&&D ((*****FF. ;')$;;8:D(5;;8:D(5{ ;-dk:{ ;-dk:   U # # #{ 5' 44 !!* KX:I%I%%dj)2GHHH;It{'9I%%dk93GHHH;It{'9I%%dk93GHHH&&(("K"227;;G*w{{++G\,2FAE,GGG+>???%OOG44E''vvNNN (-KK V;$*44$.t/A/3/AI/M0N%OE8 $ 2 2bhsvu6M6M M 2 2 $(#5T[9I9I#I#I$,$7$7 $D$D$D$'K$5$5$7$7$7 $3444 ( 3 3CK @ @ @ # 1 1 3 3 3 3 34![T[$+,FFF#%7365#9#9D#'4 ( 3 3CK @ @ @ # 1 1 3 3 3 0=DDTJJJE&&(("K* K* K* K* K* K* K* K* K* K* K* K* K* K* K* KX IId227;;I < < <!&))!&))~ J%!55f6:k6J6:k6HJJF%!55f6:k6J6:k6HJJFF# #sV* 77A A$#A$EO/(K(AO(=L(%O'L((B#OOOc|jrT|jOd|_||_|A|jr<|j|jj|jj|_dSdSdSdSdS)Nr)rr+r^r2encoderr)r6rs r.rSzPopen._save_inputmsz Hdk1%&"# $$"&+"4"4TZ5H59Z5F#H#HDKKK  H H11%$$$r-c||jdS tj|j|dS#t $rYdSwxYw)rN)rr2rrr0ProcessLookupErrorrs r.rzPopen.send_signalys_$ IIKKK*  #&&&&&%    s; A A cD|tjdS)z/Terminate the process with SIGTERM N)rr;rr>s r.rzPopen.terminate    V^ , , , , ,r-cD|tjdS)z*Kill the process with SIGKILL N)rr;SIGKILLr>s r.rz Popen.killrlr-)r|NNNNNTFNNNNrTFr,rG)Fr1)r?r#rCrDr&ECHILDrIrSr,r-r.rrs66nN4815,0EI129>  '+$Tt$b2#B$ E$677 X 222>>>8 #{(- ! ! ! ! 2A A A A H%%% %%%-2 I I I I.+++:&n -L 'L 'L '^    5 5 5} $} $} $~-1%,%@&4$+$> # # # #" # # #     0 $0 $0 $d G G G % % % = '= '= '@% 4% 4% 4Nb 4b 4b 4L8O+6)2 ? ? ? ?-18!5< # # # #F   & #& #& #Rc $c $c $L H H H   @ - - -  - - - - -r-r)\rIr%r&r@rrrLr;rwr(rrrrrrr7__all__r>rModuleNotFoundErrorr r%rlrrrrrrrrrrrrr r!r"r#r$r%r_posixsubprocessr'rr"rCwaitstatus_to_exitcoder= WIFSTOPPEDr>WSTOPSIGr?rKrDr\rW Exceptionrr rr&rgrarr_r rorUSelectSelectorrurqrrrrrrrrr objectrr rr r rrr rr,r-r.r{s  D ###### LLLL EEE D D DMMMJJJJJ %;; 'NNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO NN N N N O O O O<<<<<<:"$";m K : "&  MMM'&&&&i&&&""""""""J_862::::::::., C00I wy.))2"/"1G    G      :::z$$$(""   &&*2 2 2 2 2 j!2!2!2!2!2v!2!2!2J5$eCCCCCCCCCCLCCCR&*$@ $D E E E E E---d$#%%  t-t-t-t-t-t-t-t-t-t-s!?A A AA"!A"