QfZdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddlm Z ddlZ ddlZgdZ ddlZdZej*dvZer@ddlZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ejUgd nYerCdd l+m,Z-ej\Z/ej`Z1ejdZ3ejhZ5ejlZ7n dZ-dZ/dZ1dZ3dZ5dZ7ddl8Z8ddl9Z9Gd d e:Z;Gd de;Z<Gdde;Z=erGddZ>Gdde?Z@n,eAe8ddZBeCe9dr e9jZEn e9jZEerdZGdZHngZGdZHdZIdZJdZKdZLdZMdZNdd d!ZOd"ZPdd d#ZQGd$d%eRZSddddd&d'ZTd(ZUddd)d*ZVddd)d+ZWd,ZXeXZYdZZGd-d.Z[y#e$rdZYwxYw#e$rdZYwxYw)/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_execc eZdZy)rN)__name__ __module__ __qualname__1/opt/alt/python312/lib64/python3.12/subprocess.pyrr{sr-rcReZdZdZddZdZedZejdZy)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<||_||_||_||_yN) returncodecmdoutputstderr)selfr2r3r4r5s r.__init__zCalledProcessError.__init__s$  r-c&|jr@|jdkr1d|jdtj|j dSd|j|jfzS#t$rd|j|j fzcYSwxYw)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 ??t2 4&..$//1A"BDD DHHdooG// /  4B4??"2F444 4s0A((%BBc|jS)z+Alias for output attribute, to match stderrr4r>s r.stdoutzCalledProcessError.stdouts{{r-c||_yr1rAr6values r.rBzCalledProcessError.stdout  r-NN r)r*r+__doc__r7r?propertyrBsetterr,r-r.r r ~s=  / ]]r-r cReZdZdZddZdZedZejdZy)rzThis exception is raised when the timeout expires while waiting for a child process. Attributes: cmd, output, stdout, stderr, timeout Nc<||_||_||_||_yr1)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||_yr1rArDs r.rBzTimeoutExpired.stdoutrFr-rGrHr,r-r.rrs=  * ]]r-rc(eZdZddddddddZdZy)r&rNdwFlags hStdInput hStdOutput hStdError wShowWindowlpAttributeListcd||_||_||_||_||_|xsdgi|_y)N handle_listrS)r6rTrUrVrWrXrYs r.r7zSTARTUPINFO.__init__s8"DL&DN(DO&DN*D #2#I}b6ID r-c|jj}d|vrt|d|d<t|j|j |j |j|j|S)Nr[rS) rYcopylistr&rTrUrVrWrX)r6 attr_lists r.r]zSTARTUPINFO.copysf,,113I )+/ -0H+I -(t||)-*.//)-+/+;+;/8 : :r-)r)r*r+r7r]r,r-r.r&r&s&'4D#D J :r-r&c>eZdZdZej fdZdZdZeZ y)HandleFc<|jsd|_||yy)NT)closed)r6 CloseHandles r.Closez Handle.Closes;;" D!r-cT|jsd|_t|Std)NTzalready closed)rcintr=r>s r.Detachz Handle.Detachs&;;" 4y -. .r-cJd|jjt|fzS)Nz%s(%d)) __class__r)rgr>s r.__repr__zHandle.__repr__s t~~66D BB Br-N) r)r*r+rc_winapirdrerhrk__del__r,r-r.raras'$+$7$7 "  /  Cr-raPIPE_BUFi PollSelectorcyr1r,r,r-r._cleanuprqs r-ctytddD];}|jtj}|& tj |=y#t $rYJwxYw)N _deadstate)_active_internal_pollsysmaxsizeremover=)instress r.rqrq s[ ? AJD%%%=CNN4(  "sA AAcvg}tjj}|dkDr|jdd|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"s9 D II  E qy C#+%& Kr-cddddddd}t}|jD]<\}}ttj|}|dkDs&|j d ||zz>tjj r|j d ntjjr|j d tjjr|j d tjjr|j d tjdd}ttdi}tjj}tjj}|dkDr|jdn|r|jd|r|jd|D]}|j d|z|r|jddD]-}||vs||} | dur|} n|d| } |jd| f/|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 importtimefrozen_modules showrefcountutf8T=r)ritemsgetattrrwrrisolatedignore_environment no_user_site safe_path warnoptionsrdev_moderyextend) flag_opt_maprflagoptrwarnoptsxoptionsrrrEargs r._args_from_interpreter_flagsr,s # L . /D!'') c CIIt $ q5 KKcAg &*  yy D 99 ' ' KK  99 ! ! KK  99   KK q!HsK,HII++Myy!!Hq-. /0 " D3J M": (?SME}!$e, KKs $: Kr-ctjjrtj}|jj }d}|j x}r.|jj |k7rn|dz }|j x}r.tjdt|tjjrytjS)Nrz"'encoding' argument not specified.zutf-8) rwrwarn_default_encoding _getframef_code co_filenamef_backwarningswarnEncodingWarning utf8_modelocale getencoding)ffilename stacklevels r._text_encodingris yy&& MMO88'' 88mamxx##x/ !OJ88mam  :%z 3 yy!!##r-rNct|i|5} |j|cdddS#|jxYw#1swYyxYw)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}sL  $V $ 66'6*  FFH  % $s?)<?Acft|i|}|r$|jd}||d}t||y)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"]) rr)rgetr )rrretcoder3s r.rrsBI((Gjj  ;A,C #.. r-cdD]}||vst|dd|vrS|dN|jds3|jds"|jds|jdrd}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.inputuniversal_newlinestextencodingerrorsr-T)rBrNr)r=rr rrB)rNrrkwemptys r.r r sF" <t#PQR R"&VG_4 ::* +vzz&/AVZZPZE[::h'EEw  $t   r-cHeZdZdZddZdZeejZ dZ y)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<||_||_||_||_yr1)rr2rBr5)r6rr2rBr5s r.r7zCompletedProcess.__init__s $  r-cdj|jdj|jg}|j*|j dj|j|j *|j dj|j djt |jdj|S)Nz args={!r}zreturncode={!r}z stdout={!r}z stderr={!r}z{}({})z, ) formatrr2rBrr5typer)join)r6rs r.rkzCompletedProcess.__repr__s""499-!((9; ;; " KK ,,T[[9 : ;; " KK ,,T[[9 :tDz22DIIdODDr-c|jr6t|j|j|j|jy)z6Raise CalledProcessError if the exit code is non-zero.N)r2r rrBr5r>s r.check_returncodez!CompletedProcess.check_returncodes4 ??$T__dii%)[[2 2 r-rG) r)r*r+rIr7rk classmethodtypes GenericAlias__class_getitem__rr,r-r.rrs*  E$E$6$672r-r)rcapture_outputrNrc|%|jd tdt|d<|r?|jd|jd tdt|d<t|d<t|i|5} |j ||\}}|j} |r| rt| |j||dddtj S#t $rJ} |j tr|j \| _| _ |jd} ~ w|j xYw#1swYxYw) 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 sJ<  ::g  *NO Ow ::h  +vzz(/C/O45 5xx  $V $ $000HNFF&,,. W$Wgll,26C C/ %2 GLL'66 BB-  LLN *1)<)<)>& CJ     LLN ) % $s14E6C -E D="AD''D==EE cBg}d}ttj|D]}g}|r|jdd|vxs d|vxs| }|r|jd|D]x}|dk(r|j||dk(r4|jdt |zdzg}|jdS|r|j |g}|j|z|r|j ||s|j ||jddj |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 sl*!Ct$v%-f> BCyDCRy T> !yy==!s* AAAc$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' rr)r )r3rrs r.r r s 3& A! DDr-ctsttdsytjdvry tj d}|j d}t|dk7rt|d }ttt|dj d }tjd k(r |d k(r|d k\ryy#tttf$rYywxYw)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]3 ||++ jj./ 1 % u:? QxCq!456 <<7 "tw7g;M  J 0     sBB66C  C c :eZdZdZdZ d-dddddddddd dZdZeejZ e dZ e jd Z d Zd Zd Zej$ej(fd ZdZdZd.dZdZdZ d/dZd0dZdZej>dZ e!rDdZ"dZ#dZ$dZ%de&jNe&jPe&jRfdZ*dZ+dZ,dZ-dZ.d Z/e/Z0yd!Z"d"Z1d#Z%e2e3e4fd$Z5de6e7e8jrfd%Z*d&Z:d'Z+d(Z-d)Z;d*Z.d+Z/d,Z0y)1rar 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|N) usergroup extra_groupsrrrumaskpipesize process_groupc  ts+ttjtj dt tj|_ d|_ d|_ |d}t|ts td|d}t|ts tdtr |Ht!d|r|st#j$dt&d }| t!d |d k7r t!d ||_d|_d|_d|_d|_d|_||_||_||_|$| "t;| t;|k7r t=d |xs |xs|xs| |_|j>r|tAx|_}d|_!d|_"|j>r |dk(rd }d}nd}|d}d}|tGtHds t!dt|tJr! d dl&}|jQ|jR}n6t|tr|}n#tdjUtW||d krt!d|d}|tGtHds t!dt|tJr t!dg}|D]}t|tJr0 d dl&}|jY|jQ|jRCt|tr|jY|etdjUtW||D]} | d ks t!d| d}!|}tGtHds t!dt|tJr! d dl-}"|"j]|j^}!nt|tr|}!n td|!d krt!d|!|ja|||\}#}$}%}&}'}(tr{|$dk7r$tcjd|$jgd }$|%dk7r$tcjd|%jgd }%|'dk7r$tcjd|'jgd }' |$dk7rQtijj|$d||_|j>r)tijl|j*d || |_|%dk7rOtijj|%d!||_|j>r'tijl|j,||"|_|'dk7rOtijj|'d!||_|j>r'tijl|j.||"|_|jo|||||| | | || |#|$|%|&|'|(||||!|||y#tN$r t!dwxYw#tN$r t!dwxYw#tN$r t!dwxYw#tqd|j*|j,|j.fD]"}) |)js#t$rY wxYw|jDsg}*|ttk(r|*jY|#|ttk(r|*jY|&|ttk(r|*jY|(tG|d#r|*jY|jv|*D]N}+ tr!t|+txr|+j{ntIjr|+A#t$rYLwxYwxYw)$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#gidr7gids extra_group gid_checkuidr;p2creadp2cwritec2preadc2pwriteerrreaderrwriterto_closefds, r.r7zPopen.__init__'s #,,/KL   '^^- &+# ?G'3'89 9  H(C(9: : % "-..  >O & "-..! "-..           !3!?'(DJ6!#FG G"IVItI7I >>h.'5'7 7DMH "&&+# >>!|!%!&  M  2z* "455E3'J ll5)00E3' N!'U !466Qw #DSE!JKK  #2{+ "EFFL#. !FGGD+ k3/7" KK [ 9 @ @A S1KK ,#%9%+VD,=%>@@ ,&" q=$'H %TUU"  2z* "899D#&Jll4(//D#& EFFQw #CC5!IJJ&#//vvF ( ( ( 2~!001BAF"} //0@!D"} //0@!D6 2~WWXtW= >>!#!1!1$**D+9%-f">DJ"} gggtW= >>"$"2"24;;%-f#>DK"} gggtW= >>"$"2"24;;%-f#>DK   j*i (#s +]E ' ' ' / #T3 1= Bo#J$&IJJJ8'7(*67778#J$&IJJJP D4::t{{DKK"HIGGIJ ..D=OOG,T>OOH-T>OOH-4,OODMM2"B%*R*@HHJHHRL" # sz"U/VV D%V7/VVV472["*W;:["; X["XB ["<[[" [["[["cd|jjd|jd|jd}t |dkDr|dddz}|S)NPLz...>)rjr)r2rr)r6obj_reprs r.rkzPopen.__repr__(s]''()??+7499-q B  x=2 }v-Hr-c|jSr1)r3r>s r.rzPopen.universal_newlines3s~~r-c$t||_yr1)r2r3)r6rs r.rzPopen.universal_newlines9s01r-cj|j||}|jddjddS)Nz r )decodereplace)r6rrrs r._translate_newlineszPopen._translate_newlines=s0{{8V,||FD)11$==r-c|Sr1r,r>s r. __enter__zPopen.__enter__As r-c|jr|jj|jr|jj |jr|jj|tk(r<|j dkDr% |j |j d|_yd|_y|jy#t$r Yd|_ywxYw#|tk(rF|j dkDr- |j |j n#t$rYnwxYwd|_Yy|jwxYw)Nrr) rBrFr5rKeyboardInterruptr4_waitrr)r6exc_typerE tracebacks r.__exit__zPopen.__exit__Ds ;; KK    ;; KK    zz   ",,))A- 4+A+A B*+&*+& IIK *)*&,,))A- 4+A+A B))*& IIKsH&C C CC E:DE D# E"D## E0Ec|jsy|j|d|jzt||j ||jt t j |yyy)Nzsubprocess %s is still running)sourcers)_child_createdr2r1ResourceWarningrvrur)r6_maxsize_warns r.rmz Popen.__del__`si""  ?? " 2TXX=!$ 0 x0 ?? "w': NN4 (; "r-ct|ds7tjtjtj|_|j S)Nr%)r rrBdevnullO_RDWRr%r>s r. _get_devnullzPopen._get_devnullos0tZ(GGBJJ :DM}}r-cr|r |jj| |jj y#t$rY't$r)}|jtj k(rnYd}~Sd}~wwxYw#t$rYyt$r)}|jtj k(rnYd}~yd}~wwxYwr1)rwriteBrokenPipeErrorrr'EINVALrF)r6rrs r. _stdin_writezPopen._stdin_writets     '  JJ   #  99 ,     yyELL( s8;A: A7A7A22A7: B6B6 B11B6c|jr |r td||js|j|j|jgj ddk\rd}d}|jr|j |n|jr5|jj}|jjn@|jr4|jj}|jj|j||fS|t|z}nd} |j|||\}} d|_|j|j|}||fS#t$r_|&t|j|j|}n |j}d|_ |j!|#t"$rYwxYwwxYw#d|_wxYw)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=rrBr5countrreadrFr_time _communicaterominr4_remaining_timerpr)r6rrNrBr5endtimesigint_timeoutstss r.rzPopen.communicates$  & &5MN N OD$?$? ZZdkk 2 8 8 >! CFFzz!!%())+ !!#))+ !!# IIK:7"'G+ 3!%!2!25'7!K"/3+))D$8$8$A)BC)% &%()?)?)-)=)=g)F&HN&*%;%;N)*&JJ~J6&  /3+s='E**AG/GG G G GGG Gc"|jS)zSCheck if child process has terminated. Set and return returncode attribute.)rvr>s r.rz Popen.polls""$$r-c"|y|tz S)z5Convenience for _communicate when computing timeouts.N)r)r6rs r.rzPopen._remaining_times ?UW$ $r-c|y|s t|kDrDt|j||rdj|nd|rdj|dy)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_timeoutsf ?  57W#4 II|3=388J/43=388J/I IDHI I$5r-c| t|z} |j|S#t$r_|&t|j|j }n |j}d|_ |j|#t $rYwxYwwxYw)z=Wait for child process to terminate; returns self.returncode.rr)rrprorr4rr)r6rNrrs r.rz Popen.waits  g'G ::g:. .   "!$T%;%;%)%9%9'%B"D"&!7!7%&D "  > 2 "    s.#AB (A;:B ; BB BB ct|dd}tj5}tra|dk7r|j |j |dk7r|j |j |dk7r|j |j n|dk7r*|dk7r%||k7r |j t j||dk7r*|dk7r%||k7r |j t j||dk7r*|dk7r%||k7r |j t j|| |j t j|dddd|_y#1swYd|_yxYw)Nr%r|T) r contextlib ExitStackrcallbackrerrFr5) r6rWrXrYrZr[r\ devnull_fdstacks r._close_pipe_fdszPopen._close_pipe_fdss T:t4  ! ! #ub=NN7==1r>NN8>>2r>NN8>>2b=X^:8MNN288W5r>gmJ8NNN288X6r>gmJ8NNN288X6%rxx4#$('+#)$('+#s DE  Ec#Kg} |y#t|dr|j|j|`|D]N} tr!t |t r|j ntj|A#t$rYLwxYwxYww)zCHelper to ensure file descriptors opened in _get_handles are closedr%N) r rr%rr.rarerrFr)r6r]r^s r._on_error_fd_closerzPopen._on_error_fd_closers N tZ( .M!jV&<    s<B  B 0B zPopen._get_handles7s}FN/ & GX & GX & GX))+}=%2273K3KLG%,%7%7a%@ "(/%,,W5++A.d](/(:(:4(C%GX(.w9IXG!(('8)<=g%$2243D3D3FGGs+$2259G%225<<>BG009>&33G4M4MNH'&-&8&8q&A 8#)(#3%,,X6++A.t^(/(:(:4(C%GX(.w9IXG!(('8)<=w&%33D4E4E4GHH,%33F;H &33FMMODH11(;>&33G4L4LMH'&-&8&8q&A 8#)(#3%,,X6++A.t^(/(:(:4(C%GX(.w9IXG!(('8)<=v%'Hw&%33D4E4E4GHH,%33F;H &33FMMODH11(;{,~XXX' ',+s OPPctjtj|tjddtj}t |S)z2Return a duplicate of handle, which is inheritablerr)rlDuplicateHandleGetCurrentProcessDUPLICATE_SAME_ACCESSra)r6handlehs r.rzPopen._make_inheritablesE''))+V))+Q--/A!9 r-ct|Dchc]2}|dzdk7s&tj|tjk7r|4c}Scc}w)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.)r^rl GetFileTypeFILE_TYPE_CHAR)r6r[rs r._filter_handle_listzPopen._filter_handle_listsVk4kF"SLC/#//7#223 k45 54s7Ac t|trnit|tr| r tdt |g}n?t|t j r| r tdt |g}n t |}|t j|}| t}n|j}d| ||fv}|r8|xjtjzc_ | |_ ||_||_|j }t#|xr d|vxr|d}|s|r|r| ix}|_t%|j'dgx}|d<|r#|t)| t)|t)|gz }|j+||dd|r|st-j.dt0d}| r|xjtj2zc_ tj4|_|st j8j'd}|skt j8j'd d }t j:j=|d d }t j:j?|s tAd t j:j?|r|}n|}djC||}|t j|}tEjFd|||| tjH||ddt)| | ||| \}}} }!|jK| | | |||d|_&tO||_(| |_)tjT|y#|jK| | | |||wxYw)z$Execute program (MS Windows version)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.r6bytesr/rrPathLikerr&r]rTrlrrUrVrWrYr2r^rrgrrrr0rrrXenvironpathrisabsFileNotFoundErrorrrwaudit CreateProcessrrvra_handler1rd)"r6rrHrIrJrQrKrLrMrNrrWrXrYrZr[r\unused_restore_signals unused_gid unused_gids unused_uid unused_umaskunused_start_new_sessionunused_process_groupuse_std_handlesattribute_listhave_handle_listr[comspec system_roothphtr1tids" r.rDzPopen._execute_childs1$$D%(#$JKK#TF+D"++.#%455#TF+#D)%[[4 ")m *..0  (H(EEO##w'C'CC#(/ %)1 &(0 %(88N#N%B$1^$C%B$2=$A C   O !)CEEN[%@++M2>?@ n];#CL#h-X#OOK!%!9!9+!F A$ '=>LN !&I##w'C'CC#*1// '! !jjnnY7G"&(jjnn\2&F "$'',,{J "R!ww}}W5"34p"qqww}}W-%, (G#**GT:kk#& II(*dC E 8#*#8#8T)-t),]);)6),),)4$6 BS$$Wh%,h%,h8 #'D !":DLDH    #$$Wh%,h%,h8s ,MMc|j-||jd|k(r||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. r)r2r)r6rt_WaitForSingleObject_WAIT_OBJECT_0_GetExitCodeProcesss r.rvzPopen._internal_polls;&' a8NJ&9$,,&GDO?? "r-c^|tj}n|dkrd}nt|dz}|jmtj|j |}|tj k(rt|j|tj|j |_|jS)z-Internal implementation of wait() on Windows.ri) rlINFINITErgr2WaitForSingleObjectr WAIT_TIMEOUTrrGetExitCodeProcess)r6rNtimeout_millisrs r.rpz Popen._wait,s!(!1!1A!"!$Wt^!4& 44T\\5CEW111(G<<")"<"s MM"'') $ HHJr-c|jrzt|dsng|_tj|j |j|jf|_d|j _|j j|jrzt|dsng|_ tj|j |j|jf|_ d|j_|jj|jr|j||jZ|j j|j||j j!rt#|j$||jZ|jj|j||jj!rt#|j$|d}d}|jr&|j}|jj'|jr&|j}|jj'|r|dnd}|r|dnd}||fS)N _stdout_buff)targetrT _stderr_buffr)rBr rr)Threadr stdout_threaddaemonstartr5r stderr_threadrrrris_aliverrrF)r6rrrrBr5s r.rzPopen._communicateCs{{74#@$&!!((0B0B/3{{DzPopen._get_handless;!' GX & GX & GX))+}=d](* %GX!(('8)<=}}q(WUN-K He.@.@$--Pg%"//1Gs+#G$llnG>t^(* %GX!(('8)<=}}q(WUN-K He.@.@$--Pw&#002H,%H &}}H>t^(* %GX!(('8)<=}}q(WUN-K He.@.@$--Pv%2~#+#&>>#8#8#:w&#002H,%H &}}Hc,fXXX' 'g,+s I7J''J0c |tj}i} |r3g} dD]'} tt| d}|| j |)| | d<g}||| fD])}|dk7s |j tj |f+|df|df| dffD]-\}}|dk7s |j tj ||f/|r|| d<tj|||fi| |_d |_ |j||||| | y) z'Execute program using os.posix_spawn().N)SIGPIPESIGXFZSIGXFSZ setsigdefr|rrr file_actionsT) rrrr;rPOSIX_SPAWN_CLOSEPOSIX_SPAWN_DUP2rr1rvr)r6rrHrLrOrWrXrYrZr[r\rsigsetsignamesignumrr^fd2s r. _posix_spawnzPopen._posix_spawns# {jjF?G$VWd;F) f- @'-{#L'28 '')=)=r(BC3! 1 1 C 8 '')<)z'Popen._execute_child..Xs10>'<GGLLS)9:F'')'7'7'<0>+>#&h-KOOM2) /%uVC[4I-J'K#Xw#X(-+->)3c5&  4DH+/D'HH]+$$Wh%,h%,h8 ){ 77<7D D(L3|#4u#< &!zz$((A6HCdhh//4*-++ 7(..tQ77NIw &nn.G (/ ."7"7"@'()$2G< #Ir 2I.0"$'*  H,"$'+ '6  A~"$++i"8#/29g|TT29gFF*733U%HH]+ &)"7%7N $ICJJ"' "57G7sE8D9P>1A#Q.AQ2&R>QQQ/2 Q>=Q>'R+*R+cL||r|| |_y|||_y):All callers to this function MUST hold self._waitpid_lock.N)r2)r6r_waitstatus_to_exitcode _WIFSTOPPED _WSTOPSIGs r.r"zPopen._handle_exitstatuss%3#,S>/"9#">r-c2|j|jjdsy |j&|j|jjS||j|\}}||jk(r|j ||jj|jS|jS#t $r*}|||_n|j|k(rd|_Yd}~`d}~wwxYw#|jjwxYw)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+acquirereleaser1r"rr')r6rt_waitpid_WNOHANG_ECHILDr1res r.rvzPopen._internal_polls&))11%8 12#&&..0 ((;HCdhh//4&&..0?? "4?? " ,!-*4G+ +, ,&&..0s/C6C C7 C2-C:2C77C::Dc tj|j|\}}||fS#t$r|j}d}Y||fSwxYw)r:r)rr!r1r#)r6 wait_flagsr1rs r. _try_waitzPopen._try_waitsV ZZ*= c:  % hh:   s#)AAc|j |jS|6t|z}d} |jjdr |j' |jj |jS|j t j\}}||jk(r8|j| |jj |jS |jj |j|}|dkrt|j|t|dz|d}tj|&|jw|j5|j ddd|jS|j d\}}||jk(r|j|ddd|jw|jS#|jj wxYw#1swYAxYw)z+Internal implementation of wait() on POSIX.NgMb@?Frrg?)r2rr+r?r@rGrWNOHANGr1r"rrrrtimesleep)r6rNrdelayr1r remainings r.rpz Popen._waits*&"'G+))11%8 9#: %!..668"?? "/*. )CJS#"dhh $ 7 7 < % ..668"?? "+ /!..668 $ 4 4W =I A~,TYY@@ 9c:EJJu%!$oo-++??6!9?? " &*^^A%6 c$((? 33C8,oo-?? "#!..668,+s% G!;AG!*H 4H!G=H c |jrD|js8 |jj|s |jj d}d}|jsQi|_|j rg|j |j <|jrg|j |j<|j r|j |j }|jr|j |j}|j||jrt|j}t5}|jr,|r*|j|jtj|j r@|j js*|j|j tj |jr@|jjs*|j|jtj |j#r|j%|}|&|dkr!|j'||||dt)d|j+|} |j'||||| D]o\} } | j,|jur|j.|j.t0z} |xj.t3j4| j6| z c_|j.t9|jk\s|j;| j,| j,j | j,|j |jfvst3j<| j6d} | s5|j;| j,| j,j |j | j,j?| r|j#rddd|jA|j%||djC|}|djC|}|jDrz|;|jG||j jH|j jJ}|;|jG||jjH|jjJ}||fS#t$rYwxYw#t$rYwxYw#t$r9|j;| j,| j,j YwxYw#1swY@xYw)NrT)rzN_check_timeout(..., skip_check_and_raise=True) failed to raise TimeoutExpired.irr-)&rr-flushrrF_fileobj2outputrBr5 _save_inputr, memoryview_PopenSelectorregister selectors EVENT_WRITErc EVENT_READget_maprr RuntimeErrorselectfileobj _input_offset _PIPE_BUFrrr^r unregisterrrrrr3rkrr)r6rrrrBr5 input_viewselectorrNreadykeyeventschunkrs r.rzPopen._communicates>zz$"="=JJ$$& ((*FF..')$;;8:D((5;;8:D((5{{--dkk:{{--dkk:   U #{{' 4 !X::%%%djj)2G2GH;;t{{'9'9%%dkk93G3GH;;t{{'9'9%%dkk93G3GH&&("227;G*w{++G\,2FAE,G+>??%OOG4E''vvN (- V;;$**4$.t/A/A/3/A/AI/M%OE8 $ 2 2bhhsvvu6M M 2 $(#5#5T[[9I#I$,$7$7 $D$'KK$5$5$7 [[T[[$++,FF#%773665#9D#' ( 3 3CKK @ # 1 1 3 00=DDTJ%(-!&&("X IId227;I <!&)!&)~~%!55f6:kk6J6J6:kk6H6HJF%!55f6:kk6J6J6:kk6H6HJFF# #{' +l$34 ( 3 3CKK @ # 1 1 34="!saSS(8FT=:3S8-"T=AT=+BT= S%$S%( S54S58>T:6T=9T::T==Uc|jru|jhd|_||_|W|jrJ|jj |jj |jj |_yyyyy)Nr)rr,r\r3encoderr)r6rs r.rQzPopen._save_inputtsnzzdkk1%&"# $"&++"4"4TZZ5H5H59ZZ5F5F#HDK*8$2zr-c|j|jy tj|j|y#t $rYywxYw)rN)rr2rrr1ProcessLookupErrorrs r.rzPopen.send_signalsC$ IIK*  #&%  s A A  A cB|jtjy)z/Terminate the process with SIGTERM N)rr;rr>s r.rzPopen.terminate   V^^ ,r-cB|jtjy)z*Kill the process with SIGKILL N)rr;SIGKILLr>s r.rz Popen.killrjr-)r|NNNNNTFNNNNrTFr,rG)Fr1)rrrDrlr WAIT_OBJECT_0rrvrprrrrrr r;r<r=r"rArBr'ECHILDrGrQr,r-r.rrs6nN4815,0EI129>  '+$Tt$b2#B$E$6$67  22>8 #{{(-- ! 2A H% %-2 I.+:&L '^  5} $~-1%,%@%@&44$+$>$> #" #$  0 $d G % = '@% 4Ng 4V8O+6)2 ?-18!5<< #F & #Rc $L H @ -  -r-r)\rIr$r'rArrrJr;rwr)rrrrrrr8__all__r?rModuleNotFoundErrorr r&rlrrrrrrrrrrrrr r!r"r#r$r%r_posixsubprocessr'rr!rAwaitstatus_to_exitcoder; WIFSTOPPEDr<WSTOPSIGr=rIrBrZrU Exceptionrr rr&rgrarr]r rorSSelectSelectorrurqrrrrrrrrr objectrr rr r rrrrr,r-r.rysQ D #   DJ%;; OOOOO NN N O<::"$";";mm KK :: "&  'i&""J_8::., C0I y.)"//"11G G    :z$("" &&*2 j!2v!2J5$eCCLCR&*$@ $D E-d$%  {-{-e EJs#F>G >G G  GG