Viewing File: /opt/alt/python35/lib64/python3.5/__pycache__/subprocess.cpython-35.pyc



Yf @sdZddlZejdkZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZGddde
ZGdddeZGd	d
d
eZerddlZddlZddlZGdddZnddlZddlZddlZyddlZWnek
r[ddlZYnXeed
dZeedrejZn	ejZddddddddddddd
dgZ er=ddlm!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(e j)ddddd d!d"d#gGd$d%d%e*Z+gZ,d&d'Z-d;Z.d<Z/d=Z0d+d,Z1d-dd.dZ2d/dZ3d-dd0dZ4Gd1dde5Z6d2dd-dd3d4d5dZ7d6d7Z8d8dZ9d9dZ:e5Z;Gd:dde5Z<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 (status, output) tuple
Nwin32)	monotonicc@seZdZdS)SubprocessErrorN)__name__
__module____qualname__rr//opt/alt/python35/lib64/python3.5/subprocess.pyr9src@s[eZdZdZddddZddZeddZejd	dZdS)
CalledProcessErrorzRaised 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)
returncodecmdoutputstderr)selfrrr
rrrr	__init__Cs			zCalledProcessError.__init__cCsd|j|jfS)Nz-Command '%s' returned non-zero exit status %d)rr)rrrr	__str__IszCalledProcessError.__str__cCs|jS)z+Alias for output attribute, to match stderr)r
)rrrr	stdoutLszCalledProcessError.stdoutcCs
||_dS)N)r
)rvaluerrr	rQs)	rrr__doc__rrpropertyrsetterrrrr	r
<s
r
c@s[eZdZdZddddZddZeddZejd	dZdS)
TimeoutExpiredzThis exception is raised when the timeout expires while waiting for a
    child process.

    Attributes:
        cmd, output, stdout, stderr, timeout
    NcCs(||_||_||_||_dS)N)rtimeoutr
r)rrrr
rrrr	r_s			zTimeoutExpired.__init__cCsd|j|jfS)Nz'Command '%s' timed out after %s seconds)rr)rrrr	reszTimeoutExpired.__str__cCs|jS)N)r
)rrrr	riszTimeoutExpired.stdoutcCs
||_dS)N)r
)rrrrr	rms)	rrrrrrrrrrrrr	rXs
rc@s.eZdZdZdZdZdZdZdS)STARTUPINFOrN)rrrdwFlags	hStdInput
hStdOutput	hStdErrorwShowWindowrrrr	rxs
rZPIPE_BUFiPollSelectorPopenPIPESTDOUTcall
check_callgetstatusoutput	getoutputcheck_outputrunDEVNULLCompletedProcess)CREATE_NEW_CONSOLECREATE_NEW_PROCESS_GROUPSTD_INPUT_HANDLESTD_OUTPUT_HANDLESTD_ERROR_HANDLESW_HIDESTARTF_USESTDHANDLESSTARTF_USESHOWWINDOWr+r,r-r.r/r0r1r2c@sLeZdZdZejddZddZddZeZ	eZ
dS)	HandleFcCs |jsd|_||dS)NT)closed)rCloseHandlerrr	Closes		zHandle.ClosecCs,|jsd|_t|StddS)NTzalready closed)r4int
ValueError)rrrr	Detachs		
z
Handle.DetachcCsd|jjt|fS)Nz%s(%d))	__class__rr7)rrrr	__repr__szHandle.__repr__N)rrrr4_winapir5r6r9r;__del__rrrrr	r3sr3cCsfx_tddD]M}|jdtj}|dk	rytj|Wqtk
r]YqXqWdS)N
_deadstate)_active_internal_pollsysmaxsizeremover8)Zinstresrrr	_cleanups
rEcCsddddddddd	d
ddd
dddddi	}g}xM|jD]?\}}ttj|}|dkrO|jd||qOWx"tjD]}|jd|qW|S)znReturn a list of command-line arguments reproducing the current
    settings in sys.flags and sys.warnoptions.debugdoptimizeOdont_write_bytecodeBno_user_sitesno_siteSignore_environmentEverbosev
bytes_warningbquietqr-z-W)itemsgetattrrAflagsappendwarnoptions)Zflag_opt_mapargsZflagZoptrVrrr	_args_from_interpreter_flagss"rbrcOsSt||=}y|jd|SWn|j|jYnXWdQRXdS)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)r waitkill)r	popenargskwargsprrr	r#s

cOsMt||}|rI|jd}|dkr:|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"])
    raNr)r#getr
)rerfretcoderrrr	r$s

c	Osxd|krtdd|krV|ddkrV|jddrLdnd|d<t|dtd	|d
d|jS)a(Run 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'

    If universal_newlines=True is passed, the "input" argument must be a
    string and the return value will be a string rather than bytes.
    rz3stdout argument not allowed, it will be overridden.inputNuniversal_newlinesFrcheckT)r8rhr(r!r)rrerfrrr	r's "c@s@eZdZdZddddZddZddZdS)	r*aEA 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(||_||_||_||_dS)N)rarrr)rrarrrrrr	rJs			zCompletedProcess.__init__cCsdj|jdj|jg}|jdk	rL|jdj|j|jdk	rt|jdj|jdjt|jdj|S)Nz	args={!r}zreturncode={!r}zstdout={!r}zstderr={!r}z{}({})z, )	formatrarrr_rtyperjoin)rrarrr	r;PszCompletedProcess.__repr__cCs.|jr*t|j|j|j|jdS)z6Raise CalledProcessError if the exit code is non-zero.N)rr
rarr)rrrr	check_returncodeYs	z!CompletedProcess.check_returncode)rrrrrr;rrrrrr	r*?s
	rjrnFc	Os|dk	r.d|kr$tdt|d<t||}y|j|d|\}}Wnjtk
r|j|j\}}t|j|d|d|Yn|j|jYnX|j}|r|rt	||jd|d|WdQRXt
|j|||S)afRun 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 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.

    The other arguments are the same as for the Popen constructor.

    If universal_newlines=True is passed, the "input" argument must be a
    string and stdout/stderr in the returned object will be strings rather than
    bytes.
    Nstdinz/stdin and input arguments may not both be used.rr
r)r8r!r communicaterrdrarcpollr
r*)	rjrrnrerfZprocessrrrirrr	r(`s*





cCs8g}d}x|D]}g}|r2|jdd|kpNd|kpN|}|rd|jdx|D]}|dkr|j|qk|dkr|jdt|dg}|jdqk|r|j|g}|j|qkW|r|j||r|j||jdqWdj|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 	"\rGz\"rl)r_lenextendrq)seqresultZ	needquoteargZbs_bufcrrr	list2cmdlines4






rcCsy(t|dddddt}d}Wn7tk
ra}z|j}|j}WYdd}~XnX|d	ddkr|dd
}||fS)a    Return (status, output) of executing cmd in a shell.

    Execute the string 'cmd' in a shell with 'check_output' and
    return a 2-tuple (status, output). Universal newlines mode is used,
    meaning that the result with be decoded to a string.

    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')
    (256, 'cat: /bin/junk: No such file or directory')
    >>> subprocess.getstatusoutput('/bin/junk')
    (256, 'sh: /bin/junk: not found')
    shellTrkrrNrF
r)r'r"r
r
r)rdataZstatusZexrrr	r%s
	cCst|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'
    rF)r%)rrrr	r&s
c@s5eZdZdZdZd>dddddeddddddddfddZd	d
ZddZd
dZ	e
jddZddZ
ddZddddZddZddZddZernddZdd Zd!d"Zdejejejd#d$Zddd%d&Zd'd(Zd)d*Zd+d,Zd-d.Z e Z!nd/dZd0d"Ze"j#e"j$e"j%e"j&e"j'e"j(d1d2Z)de"j*e"j+e,j-d3d$Zd4d5Z.ddd6d&Zd7d*Zd8d9Z/d:d,Zd;d.Z d<d=Z!dS)?r a 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.

      universal_newlines: If true, use universal line endings for file
          objects stdin, stdout and stderr.

      startupinfo and creationflags (Windows only)

      restore_signals (POSIX only)

      start_new_session (POSIX only)

      pass_fds (POSIX only)

    Attributes:
        stdin, stdout, stderr, pid, returncode
    FrFNrTcCs@ttj|_d|_d|_|dkr:d}t|tsUtdt	r|dk	rst
d|dk	p|dk	p|dk	}|tkr|rd}qd}q;|r;|r;t
dne|tkrd}|r|rtj
dtd}|
dk	r#t
d	|d
kr;t
d||_d|_d|_d|_d|_d|_||_|j|||\}}}}}}t	r|dkrtj|jd
}|dkrtj|jd
}|dkrtj|jd
}|dkrdtj|d||_|rdtj|jd
dd|dk|_|dkrtj|d||_|rtj|j|_|dkrtj|d||_|rtj|j|_d|_yD|j||||||
||
||	||||||||Wn
xLtd|j|j|jfD])}y|j WqWt!k
rYqWXqWW|js4g}|t"kr|j#||t"kr|j#||t"kr|j#|t$|dr|j#|j%x4|D],}yt&j |Wqt!k
r/YqXqWYnXdS)zCreate new Popen instance.NFrFzbufsize must be an integerz0preexec_fn is not supported on Windows platformsTzSclose_fds is not supported on Windows platforms if you redirect stdin/stdout/stderrzpass_fds overriding close_fds.z2startupinfo is only supported on Windows platformsrz4creationflags is only supported on Windows platformswbZ
write_throughline_bufferingrb_devnullrrrrrrr)'rE	threadingZLock
_waitpid_lock_input_communication_started
isinstancer7	TypeError
_mswindowsr8_PLATFORM_DEFAULT_CLOSE_FDSwarningswarnRuntimeWarningrarsrrpidrrk_get_handlesmsvcrtZopen_osfhandler9ioopen
TextIOWrapper_closed_child_pipe_fds_execute_childfiltercloseOSErrorr!r_hasattrros)rrabufsize
executablersrr
preexec_fn	close_fdsrcwdenvrkstartupinfo
creationflagsrestore_signalsstart_new_sessionpass_fdsZ
any_stdio_setp2creadp2cwritec2preadc2pwriteerrreaderrwritefZto_closefdrrr	r3s				
							'			(
		




	zPopen.__init__cCs+|j|}|jddjddS)Nz
r
)decodereplace)rrencodingrrr	_translate_newlinesszPopen._translate_newlinescCs|S)Nr)rrrr		__enter__szPopen.__enter__c
CsX|jr|jj|jr,|jjz|jrE|jjWd|jXdS)N)rrrrsrc)rrpr	tracebackrrr	__exit__s	
	
	zPopen.__exit__cCsI|js
dS|jd||jdkrEtdk	rEtj|dS)Nr>)_child_createdr@rr?r_)rZ_maxsizerrr	r=s
	z
Popen.__del__cCs1t|ds*tjtjtj|_|jS)Nr)rrrdevnullO_RDWRr)rrrr	_get_devnullszPopen._get_devnullcCs|rky|jj|WnNtk
r.Yn=tk
rj}z|jtjkrUnWYdd}~XnXy|jjWnNtk
rYn=tk
r}z|jtjkrnWYdd}~XnXdS)N)rswriteBrokenPipeErrorrerrnoZEINVALr)rrjexcrrr	_stdin_writes"

zPopen._stdin_writecCsJ|jr|rtd|dkr|jr|j|j|jgjddkrd}d}|jr}|j|nM|jr|jj}|jjn%|jr|jj}|jj|j	ni|dk	rt
|}nd}z|j|||\}}Wdd|_X|j	d|j|}||fS)a4Interact with process: Send data to stdin.  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 (if self.universal_newlines is True, this should
        be a string; if it is False, "input" should be bytes), or
        None, if no data should be sent to the child.

        communicate() returns a tuple (stdout, stderr).  These will be
        bytes or, if self.universal_newlines was True, a string.
        z.Cannot send input after starting communicationNrGTr)
rr8rsrrcountrreadrrc_time_communicate_remaining_time)rrjrrrendtimestsrrr	rts.'			


zPopen.communicatecCs
|jS)zSCheck if child process has terminated. Set and return returncode
        attribute.)r@)rrrr	ru,sz
Popen.pollcCs|dkrdS|tSdS)z5Convenience for _communicate when computing timeouts.N)r)rrrrr	r2szPopen._remaining_timecCs5|dkrdSt|kr1t|j|dS)z2Convenience for checking if a timeout has expired.N)rrra)rrorig_timeoutrrr	_check_timeout:szPopen._check_timeoutcCs|dkr(|dkr(|dkr(d
Sd
\}}d\}}d\}}	|dkrtjtj}|dkrDtjdd\}}
t|}tj|
n|tkrtjdd\}}t|t|}}nZ|tkrtj	|j
}n6t|tr/tj	|}ntj	|j
}|j|}|dkrtjtj}|dkrKtjdd\}
}t|}tj|
n|tkrtjdd\}}t|t|}}nZ|tkrtj	|j
}n6t|tr6tj	|}ntj	|j
}|j|}|dkrtjtj}	|	dkrgtjdd\}
}	t|	}	tj|
n|tkrtjdd\}}	t|t|	}}	no|tkr
|}	nZ|tkr1tj	|j
}	n6t|trRtj	|}	ntj	|j
}	|j|	}	||||||	fS)z|Construct and return tuple with IO objects:
            p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
            NrFrrrrrrr)rrrrrrrr)rrrr)rrrr)rr)r<ZGetStdHandler-Z
CreatePiper3r5r!r)rZ
get_osfhandlerrr7fileno_make_inheritabler.r/r")rrsrrrrrrrr_rrr	rFsn$	zPopen._get_handlescCs7tjtj|tjddtj}t|S)z2Return a duplicate of handle, which is inheritablerrF)r<ZDuplicateHandleZGetCurrentProcessZDUPLICATE_SAME_ACCESSr3)rZhandlehrrr	rs
zPopen._make_inheritablecCs|stdt|ts.t|}|dkrCt}d	|||fkr|jtjO_||_||_	||_
|
r|jtjO_tj|_
tjjdd}dj||}z>tj||ddt||	|||	\}}}}Wd|d
kr'|j|dkr=|j|dkrS|jt|drrtj|jXd|_t||_||_tj|dS)
z$Execute program (MS Windows version)z"pass_fds not supported on Windows.NrFZCOMSPECzcmd.exez
{} /c "{}"rTrrrr)AssertionErrorrstrrrrr<r1rrrr2r0rrenvironrhroZ
CreateProcessr7r6rrrrr3_handlerr5)rrarrrrrrrrrrrrrrrZunused_restore_signalsZunused_start_new_sessionZcomspecZhpZhtrtidrrr	rsF					



		zPopen._execute_childcCs@|jdkr9||jd|kr9||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)rr)rr>Z_WaitForSingleObjectZ_WAIT_OBJECT_0Z_GetExitCodeProcessrrr	r@szPopen._internal_pollcCs|dk	r|j|}|dkr3tj}nt|d}|jdkrtj|j|}|tjkrt|j	|tj
|j|_|jS)zOWait for child process to terminate.  Returns returncode
            attribute.Ni)rr<ZINFINITEr7rWaitForSingleObjectrZWAIT_TIMEOUTrraGetExitCodeProcess)rrrZtimeout_millisr}rrr	rcs	z
Popen.waitcCs!|j|j|jdS)N)r_rr)rZfhbufferrrr	
_readerthreadszPopen._readerthreadcCs|jret|dreg|_tjd|jd|j|jf|_d|j_|jj|j	rt|drg|_
tjd|jd|j	|j
f|_d|j_|jj|jr|j
||jdk	r)|jj|j||jjr)t|j||j	dk	rr|jj|j||jjrrt|j|d}d}|jr|j}|jj|j	r|j
}|j	j|dk	r|d}|dk	r|d}||fS)N_stdout_bufftargetraT_stderr_buffr)rrrrZThreadrZ
stdout_threadZdaemonstartrrZ
stderr_threadrsrrqrZis_aliverrar)rrjrrrrrrr	rsF	
	
	
		
		


zPopen._communicatecCs|jdk	rdS|tjkr/|jne|tjkrWtj|jtjn=|tjkrtj|jtjnt	dj
|dS)zSend a signal to the process.NzUnsupported signal: {})rsignalSIGTERM	terminateZCTRL_C_EVENTrrdrZCTRL_BREAK_EVENTr8ro)rsigrrr	send_signal0s
zPopen.send_signalcCsp|jdk	rdSytj|jdWn?tk
rktj|j}|tjkr^||_YnXdS)zTerminates the process.NrF)rr<ZTerminateProcessrPermissionErrorrZSTILL_ACTIVE)rrcrrr	r>s
zPopen.terminatec
Csd\}}d\}}d\}}	|dkr3n`|tkrTtj\}}n?|tkro|j}n$t|tr|}n|j}|dkrn`|tkrtj\}}n?|tkr|j}n$t|tr|}n|j}|dkrn|tkr2tj\}}	nr|tkre|dkrS|}	qt	j
j}	n?|tkr|j}	n$t|tr|}	n|j}	||||||	fS)
z|Construct and return tuple with IO objects:
            p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
            rFNrr)rrrr)rrrr)rrr)r!rpiper)rrr7rr"rA
__stdout__)
rrsrrrrrrrrrrr	rSsJ				c&"st|ttfr!|g}nt|}|
rSddg|}rS|d<dkri|d}tj\}}g}x,|dkr|j|tj|}qWx|D]}tj|qWzqzO|dk	rQg}xh|j	D]Q\}}tj
|}d|kr,td|j|dtj
|qWnd}tj
tjj
rf}n(tfdd	tj|D}t|}|j|tj|||tttt||||||
|||||||||_d
|_Wdtj|Xt|dd}|dkrz|dkrz||krztj||dkr|
dkr||krtj||dkr|dkr||krtj||dk	rtj|d
|_t}x:tj|d
}||7}|s?t|d
kr
Pq
WWdtj|X|rytj|jdWntk
rYnXy|j dd\} }!}"Wn.tk
rd} d}!dt!|}"YnXtt"| j#dt$}#|"j#dd}"t%|#t&r|!rt|!d}$|"dk}%|%rAd}"|$dkrtj'|$}"|$t(j)kr|%r|"dt!|7}"n|"dt!|7}"|#|$|"|#|"dS) zExecute program (POSIX version)z/bin/shz-crNrH=z!illegal environment variable namec3s-|]#}tjjtj|VqdS)N)rpathrqfsencode).0dir)rrr		<genexpr>sz'Popen._execute_child.<locals>.<genexpr>TrrFiP:rGsSubprocessError0sBad exception data from child: asciierrors
surrogatepassZnoexecrlz: rrrrrr)*rrbyteslistrrr_duprr\rr8rdirnametuple
get_exec_pathsetadd_posixsubprocessZ	fork_execsortedmapr7rrr]r	bytearrayrrzwaitpidChildProcessErrorsplitreprbuiltinsrr
issubclassrstrerrorrENOENT)&rrarrrrrrrrrrrrrrrrrZorig_executableZerrpipe_readZ
errpipe_writeZlow_fds_to_closeZlow_fdZenv_listkrVZexecutable_listZfds_to_keepZ
devnull_fdZerrpipe_datapartZexception_nameZ	hex_errnoZerr_msgZchild_exception_typeZ	errno_numZchild_exec_never_calledr)rr	rs	



%

$
$
$

		
	

	cCsl||r|||_nI||r=|||_n+||r\|||_ntddS)z:All callers to this function MUST hold self._waitpid_lock.zUnknown child exit status!N)rr)rrZ_WIFSIGNALEDZ	_WTERMSIGZ
_WIFEXITEDZ_WEXITSTATUSZ_WIFSTOPPEDZ	_WSTOPSIGrrr	_handle_exitstatus
szPopen._handle_exitstatuscCs|jdkr|jjds%dSzyN|jdk	rA|jS||j|\}}||jkru|j|WnUtk
r}z5|dk	r||_n|j|krd|_WYdd}~XnXWd|jjX|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)rracquirerr
rrrelease)rr>Z_waitpidZ_WNOHANGZ_ECHILDrrerrr	r@s 	 cCsMytj|j|\}}Wn!tk
rB|j}d}YnX||fS)z:All callers to this function MUST hold self._waitpid_lock.r)rrrr)rZ
wait_flagsrrrrr		_try_waitBs
	zPopen._try_waitcCs|jdk	r|jS|dk	s.|dk	re|dkrJt|}n|dkre|j|}|dk	r^d}xL|jjdrzj|jdk	rP|jtj\}}||jks|dkst	||jkr|j
|PWd|jjX|j|}|dkr4t|j
|t|d|d}tj|qzWnhxe|jdkr|jF|jdk	rP|jd\}}||jkr|j
|WdQRXqaW|jS)zOWait for child process to terminate.  Returns returncode
            attribute.NgMb@?FrrGg?)rrrrrrrWNOHANGrrr
rrramintimeZsleep)rrrZdelayrrZ	remainingrrr	rcOsB!

c#Cs|jre|jrey|jjWntk
r8YnX|sey|jjWntk
rdYnXd}d}|jsi|_|jrg|j|j<|jrg|j|j<|jr|j|j}|jr|j|j}|j||j	rt
|j	}t}|jr=|r=|j|jt
j|jr\|j|jt
j|jr{|j|jt
jx|jr|j|}|dk	r|dkrt|j||j|}	|j||x6|	D].\}
}|
j|jkr||j|jt}y"|jtj|
j|7_Wn/tk
rt|j|
j|
jjYqX|jt|j	kr|j|
j|
jjq|
j|j|jfkrtj|
jd}
|
s|j|
j|
jj|j|
jj|
qWq~WWdQRX|j d|j||dk	rZdj!|}|dk	rudj!|}|j"r|dk	r|j#||jj$}|dk	r|j#||jj$}||fS)Nrirrm)%rsrflushrrZ_fileobj2outputrr_save_inputr
memoryview_PopenSelectorregister	selectorsZEVENT_WRITEZ
EVENT_READZget_maprrraselectrZfileobj
_input_offset	_PIPE_BUFrrrZ
unregisterrzrr_rcrqrkrr)rrjrrrrZ
input_viewZselectorrZreadykeyZeventschunkrrrr	rs

						
				"

&			cCs^|jrZ|jdkrZd|_||_|jrZ|dk	rZ|jj|jj|_dS)Nr)rsrrrkencoder)rrjrrr	rs
		zPopen._save_inputcCs&|jdkr"tj|j|dS)zSend a signal to the process.N)rrrdr)rrrrr	rscCs|jtjdS)z/Terminate the process with SIGTERM
            N)rrr)rrrr	rscCs|jtjdS)z*Kill the process with SIGKILL
            N)rrSIGKILL)rrrr	rdsz
Popen.killr)0rrrrrrrrrrrArBr=rrrtrurrrrrrr<rZ
WAIT_OBJECT_0rr@rcrrrrrdrWIFSIGNALEDWTERMSIG	WIFEXITEDWEXITSTATUS
WIFSTOPPEDWSTOPSIGr
rrrZECHILDrrrrrr	r s`(	
1H	=4	6	"
1_r)=rrAplatformrrrrrrrrrr	Exceptionrr
rrrr<rrrrImportErrorZdummy_threadingr]rrrrZSelectSelector__all__r+r,r-r.r/r0r1r2r{r7r3r?rEr!r"r)rbr#r$r'objectr*r(rr%r&rr rrrr	<module>*sn
	:
,!2I
	
Back to Directory File Manager