Your IP : 18.222.119.143


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/subprocess.cpython-35.opt-2.pyc



���] ��@sddlZejdkZddlZddlZddlZddlZddlZddlZddl	Z	ddlm
ZGdd�de�Z
Gdd�de
�ZGdd	�d	e
�ZerddlZddlZddlZGd
d�d�Zn�ddlZddlZddlZyddlZWnek
rUddlZYnXeedd
�Zeed�r�ejZn	ejZddddddddddddd	dgZer7ddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'ej(dddddd d!d"g�Gd#d$�d$e)�Z*gZ+d%d&�Z,d:Z-d;Z.d<Z/d*d+�Z0d,dd-d�Z1d.d�Z2d,dd/d�Z3Gd0d�de4�Z5d1dd,dd2d3d4d�Z6d5d6�Z7d7d�Z8d8d�Z9e4�Z:Gd9d�de4�Z;dS)=�N�win32)�	monotonicc@seZdZdS)�SubprocessErrorN)�__name__�
__module__�__qualname__�rr�//opt/alt/python35/lib64/python3.5/subprocess.pyr9src@sUeZdZdddd�Zdd�Zedd��Zejdd��ZdS)	�CalledProcessErrorNcCs(||_||_||_||_dS)N)�
returncode�cmd�output�stderr)�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)N)r
)rrrr	�stdoutLszCalledProcessError.stdoutcCs
||_dS)N)r
)r�valuerrr	rQs)rrrrr�propertyr�setterrrrr	r
<sr
c@sUeZdZdddd�Zdd�Zedd��Zejdd��ZdS)	�TimeoutExpiredNcCs(||_||_||_||_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)rrrrrrrrrrrr	rXsrc@s.eZdZdZdZdZdZdZdS)�STARTUPINFOrN)rrr�dwFlags�	hStdInput�
hStdOutput�	hStdError�wShowWindowrrrr	rxs
r�PIPE_BUFi�PollSelector�Popen�PIPE�STDOUT�call�
check_call�getstatusoutput�	getoutput�check_output�run�DEVNULL�CompletedProcess)�CREATE_NEW_CONSOLE�CREATE_NEW_PROCESS_GROUP�STD_INPUT_HANDLE�STD_OUTPUT_HANDLE�STD_ERROR_HANDLE�SW_HIDE�STARTF_USESTDHANDLES�STARTF_USESHOWWINDOWr+r,r-r.r/r0r1r2c@sLeZdZdZejdd�Zdd�Zdd�ZeZ	eZ
dS)	�HandleFcCs |jsd|_||�dS)NT)�closed)r�CloseHandlerrr	�Close�s		zHandle.ClosecCs,|jsd|_t|�Std��dS)NTzalready closed)r4�int�
ValueError)rrrr	�Detach�s		
z
Handle.DetachcCsd|jjt|�fS)Nz%s(%d))�	__class__rr7)rrrr	�__repr__�szHandle.__repr__N)rrrr4�_winapir5r6r9r;�__del__rrrrr	r3�sr3cCsfx_tdd�D]M}|jdtj�}|dk	rytj|�Wqtk
r]YqXqWdS)N�
_deadstate)�_active�_internal_poll�sys�maxsize�remover8)�inst�resrrr	�_cleanup�s
rF���cCs�ddddddddd	d
ddd
dddddi	}g}xM|j�D]?\}}ttj|�}|dkrO|jd||�qOWx"tjD]}|jd|�q�W|S)N�debug�d�optimize�O�dont_write_bytecode�B�no_user_site�s�no_site�S�ignore_environment�E�verbose�v�
bytes_warning�b�quiet�qr�-z-W)�items�getattrrA�flags�append�warnoptions)�flag_opt_map�args�flag�optrWrrr	�_args_from_interpreter_flags�s"rfrcOsSt||��=}y|jd|�SWn|j�|j��YnXWdQRXdS)Nr)r �wait�kill)r�	popenargs�kwargs�prrr	r#�s

cOsMt||�}|rI|jd�}|dkr:|d}t||��dS)Nrcr)r#�getr
)rirj�retcoderrrr	r$s

c	Osxd|krtd��d|krV|ddkrV|jdd�rLdnd|d<t|dtd|d	d
|�jS)Nrz3stdout argument not allowed, it will be overridden.�input�universal_newlinesF��r�checkT)r8rlr(r!r)rrirjrrr	r's "c@s:eZdZdddd�Zdd�Zdd�ZdS)r*NcCs(||_||_||_||_dS)N)rcrrr)rrcrrrrrr	rJs			zCompletedProcess.__init__cCs�dj|j�dj|j�g}|jdk	rL|jdj|j��|jdk	rt|jdj|j��djt|�jdj|��S)Nz	args={!r}zreturncode={!r}zstdout={!r}zstderr={!r}z{}({})z, )	�formatrcrrr`r�typer�join)rrcrrr	r;PszCompletedProcess.__repr__cCs.|jr*t|j|j|j|j��dS)N)rr
rcrr)rrrr	�check_returncodeYs	z!CompletedProcess.check_returncode)rrrrr;rvrrrr	r*?s	rnrrFc	Os|dk	r.d|kr$td��t|d<t||���}y|j|d|�\}}Wnjtk
r�|j�|j�\}}t|j|d|d|��Yn|j�|j��YnX|j�}|r|rt	||jd|d|��WdQRXt
|j|||�S)N�stdinz/stdin and input arguments may not both be used.rr
r)r8r!r �communicaterrhrcrg�pollr
r*)	rnrrrrirj�processrrrmrrr	r(`s*





cCs8g}d}x|D]}g}|r2|jd�d|kpNd|kpN|}|rd|jd�x�|D]�}|dkr�|j|�qk|dkr�|jdt|�d�g}|jd�qk|r�|j|�g}|j|�qkW|r|j|�|r|j|�|jd�qWdj|�S)	NF� �	�"�\rHz\"rp)r`�len�extendru)�seq�result�	needquote�arg�bs_buf�crrr	�list2cmdline�s4






r�cCs�y(t|dddddt�}d}Wn7tk
ra}z|j}|j}WYdd}~XnX|dd�dkr�|dd	�}||fS)
N�shellTrorrrG�
���r�)r'r"r
r
r)r�data�status�exrrr	r%�s
	cCst|�dS)NrG)r%)rrrr	r&�s
c@s/eZdZdZd=dddddeddddddddfdd�Zdd	�Zd
d�Zdd
�Ze	j
dd�Zdd�Zdd�Z
dddd�Zdd�Zdd�Zdd�Zerhdd�Zdd�Zd d!�Zdejejejd"d#�Zddd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZeZ n�d.d�Zd/d!�Ze!j"e!j#e!j$e!j%e!j&e!j'd0d1�Z(de!j)e!j*e+j,d2d#�Zd3d4�Z-ddd5d%�Zd6d)�Zd7d8�Z.d9d+�Zd:d-�Zd;d<�Z dS)>r FrGNrTcCs@t�tj�|_d|_d|_|dkr:d}t|t�sUtd��t	r�|dk	rst
d��|dk	p�|dk	p�|dk	}|tkr�|r�d}q�d}q;|r;|r;t
d��ne|tkr�d}|r|rtj
dt�d}|
dk	r#t
d��|d	kr;t
d
��||_d|_d|_d|_d|_d|_||_|j|||�\}}}}}}t	r|dkr�tj|j�d	�}|dkr�tj|j�d	�}|dkrtj|j�d	�}|dkrdtj|d|�|_|rdtj|jddd
|dk�|_|dkr�tj|d|�|_|r�tj|j�|_|dkr�tj|d|�|_|r�tj|j�|_d|_yD|j||||||
||
||	||||||||�Wn
xLtd|j|j|jf�D])}y|j �WqWt!k
rYqWXqWW|js4g}|t"kr�|j#|�|t"kr�|j#|�|t"kr�|j#|�t$|d�r�|j#|j%�x4|D],}yt&j |�Wqt!k
r/YqXqW�YnXdS)NFrGzbufsize 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 platforms�wb�
write_through�line_buffering�rb�_devnullr�r�r�r�r�r�r�)'rF�	threading�Lock�
_waitpid_lock�_input�_communication_started�
isinstancer7�	TypeError�
_mswindowsr8�_PLATFORM_DEFAULT_CLOSE_FDS�warnings�warn�RuntimeWarningrcrwrr�pidrro�_get_handles�msvcrt�open_osfhandler9�io�open�
TextIOWrapper�_closed_child_pipe_fds�_execute_child�filter�close�OSErrorr!r`�hasattrr��os)rrc�bufsize�
executablerwrr�
preexec_fn�	close_fdsr��cwd�envro�startupinfo�
creationflags�restore_signals�start_new_session�pass_fds�
any_stdio_set�p2cread�p2cwrite�c2pread�c2pwrite�errread�errwrite�f�to_close�fdrrr	r3s�				
							'			(
		




	zPopen.__init__cCs+|j|�}|jdd�jdd�S)Nz
r��
)�decode�replace)rr��encodingrrr	�_translate_newlines�szPopen._translate_newlinescCs|S)Nr)rrrr	�	__enter__�szPopen.__enter__c
CsX|jr|jj�|jr,|jj�z|jrE|jj�Wd|j�XdS)N)rr�rrwrg)rrtr�	tracebackrrr	�__exit__�s	
	
	zPopen.__exit__cCsI|js
dS|jd|�|jdkrEtdk	rEtj|�dS)Nr>)�_child_createdr@rr?r`)r�_maxsizerrr	r=�s
	z
Popen.__del__cCs1t|d�s*tjtjtj�|_|jS)Nr�)r�r�r��devnull�O_RDWRr�)rrrr	�_get_devnull�szPopen._get_devnullcCs�|rky|jj|�WnNtk
r.Yn=tk
rj}z|jtjkrUn�WYdd}~XnXy|jj�WnNtk
r�Yn=tk
r�}z|jtjkr�n�WYdd}~XnXdS)N)rw�write�BrokenPipeErrorr��errno�EINVALr�)rrn�excrrr	�_stdin_write�s"

zPopen._stdin_writecCsJ|jr|rtd��|dkr�|jr�|j|j|jgjd�dkr�d}d}|jr}|j|�nM|jr�|jj�}|jj�n%|jr�|jj�}|jj�|j	�ni|dk	r�t
�|}nd}z|j|||�\}}Wdd|_X|j	d|j|��}||fS)Nz.Cannot send input after starting communicationrHTr)
r�r8rwrr�countr��readr�rg�_time�_communicate�_remaining_time)rrnrrr�endtime�stsrrr	rx�s.'			


zPopen.communicatecCs
|j�S)N)r@)rrrr	ry,sz
Popen.pollcCs|dkrdS|t�SdS)N)r�)rr�rrr	r�2szPopen._remaining_timecCs5|dkrdSt�|kr1t|j|��dS)N)r�rrc)rr��orig_timeoutrrr	�_check_timeout:szPopen._check_timeoutcCs�|dkr(|dkr(|dkr(d	Sd\}}d\}}d\}}	|dkr�tjtj�}|dkrDtjdd�\}}
t|�}tj|
�n�|tkr�tjdd�\}}t|�t|�}}nZ|tkrtj	|j
��}n6t|t�r/tj	|�}ntj	|j
��}|j|�}|dkr�tjtj�}|dkrKtjdd�\}
}t|�}tj|
�n�|tkr�tjdd�\}}t|�t|�}}nZ|tkrtj	|j
��}n6t|t�r6tj	|�}ntj	|j
��}|j|�}|dkr�tjtj�}	|	dkrgtjdd�\}
}	t|	�}	tj|
�n�|tkr�tjdd�\}}	t|�t|	�}}	no|tkr
|}	nZ|tkr1tj	|j
��}	n6t|t�rRtj	|�}	ntj	|j
��}	|j|	�}	||||||	fS)NrGrr�r�r�r�r�r�)r�r�r�r�r�r�r�r�)r�r�r�r�)r�r�r�r�)r�r�)r<ZGetStdHandler-Z
CreatePiper3r5r!r)r�Z
get_osfhandler�r�r7�fileno�_make_inheritabler.r/r")rrwrrr�r�r�r�r�r��_rrr	r�Fsn$	zPopen._get_handlescCs7tjtj�|tj�ddtj�}t|�S)NrrG)r<ZDuplicateHandleZGetCurrentProcessZDUPLICATE_SAME_ACCESSr3)r�handle�hrrr	r��s
zPopen._make_inheritablecCs�t|t�st|�}|dkr0t�}d|||fkrr|jtjO_||_||_||_	|
r�|jtj
O_tj|_t
jjdd�}dj||�}z>tj||ddt|�|	|||�	\}}}}Wd|dkr|j�|d	kr*|j�|d
kr@|j�t|d�r_t
j|j�Xd|_t|�|_||_tj|�dS)NrGZCOMSPECzcmd.exez
{} /c "{}"r�Tr�r�r�r�)r��strr�rrr<r1rrrr2r0rr��environrlrsZ
CreateProcessr7r6r�r�r�r�r3�_handler�r5)rrcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Zunused_restore_signalsZunused_start_new_sessionZcomspecZhpZhtr��tidrrr	r��sD				



		zPopen._execute_childcCs@|jdkr9||jd�|kr9||j�|_|jS)Nr)rr�)rr>Z_WaitForSingleObjectZ_WAIT_OBJECT_0Z_GetExitCodeProcessrrr	r@�szPopen._internal_pollcCs�|dk	r|j|�}|dkr3tj}nt|d�}|jdkr�tj|j|�}|tjkr�t|j	|��tj
|j�|_|jS)Ni�)r�r<ZINFINITEr7r�WaitForSingleObjectr�ZWAIT_TIMEOUTrrc�GetExitCodeProcess)rrr�Ztimeout_millisr�rrr	rg�s	z
Popen.waitcCs!|j|j��|j�dS)N)r`r�r�)rZfh�bufferrrr	�
_readerthread�szPopen._readerthreadcCs�|jret|d�reg|_tjd|jd|j|jf�|_d|j_|jj�|j	r�t|d�r�g|_
tjd|jd|j	|j
f�|_d|j_|jj�|jr�|j
|�|jdk	r)|jj|j|��|jj�r)t|j|��|j	dk	rr|jj|j|��|jj�rrt|j|��d}d}|jr�|j}|jj�|j	r�|j
}|j	j�|dk	r�|d}|dk	r�|d}||fS)N�_stdout_buff�targetrcT�_stderr_buffr)rr�r�r��Threadr�Z
stdout_thread�daemon�startrr�Z
stderr_threadrwr�rur��is_aliverrcr�)rrnr�r�rrrrr	r��sF	
	
	
		
		


zPopen._communicatecCs�|jdk	rdS|tjkr/|j�ne|tjkrWtj|jtj�n=|tjkrtj|jtj�nt	dj
|���dS)NzUnsupported signal: {})r�signal�SIGTERM�	terminateZCTRL_C_EVENTr�rhr�ZCTRL_BREAK_EVENTr8rs)r�sigrrr	�send_signal0s
zPopen.send_signalcCsp|jdk	rdSytj|jd�Wn?tk
rktj|j�}|tjkr^�||_YnXdS)NrG)rr<ZTerminateProcessr��PermissionErrorr�ZSTILL_ACTIVE)r�rcrrr	r�>s
zPopen.terminatec
Cs�d\}}d\}}d
\}}	|dkr3n`|tkrTtj�\}}n?|tkro|j�}n$t|t�r�|}n|j�}|dkr�n`|tkr�tj�\}}n?|tkr�|j�}n$t|t�r�|}n|j�}|dkrn�|tkr2tj�\}}	nr|tkre|dkrS|}	q�t	j
j�}	n?|tkr�|j�}	n$t|t�r�|}	n|j�}	||||||	fS)NrGr�r�)r�r�r�r�)r�r�r�r�)r�r�r�)r!r��piper)r�r�r7r�r"rA�
__stdout__)
rrwrrr�r�r�r�r�r�rrr	r�SsJ				c&"s�t|ttf�r!|g}nt|�}|
rSddg|}�rS�|d<�dkri|d��}tj�\}}g}x,|dkr�|j|�tj|�}q�Wx|D]}tj|�q�WzqzO|dk	rQg}xh|j	�D]Q\}}tj
|�}d|kr,td��|j|dtj
|��q�Wnd}tj
���tjj
��r��f}n(t�fdd�tj|�D��}t|�}|j|�tj|||tttt|���|||||
||||||||�|_d	|_Wdtj|�Xt|d
d�}|dkrz|dkrz||krztj|�|dkr�|
dkr�||kr�tj|�|dkr�|dkr�||kr�tj|�|dk	r�tj|�d	|_t�}x:tj|d�}||7}|s?t|�dkr
Pq
WWdtj|�X|r�ytj|jd�Wntk
r�YnXy|j d
d�\} }!}"Wn.tk
r�d} d}!dt!|�}"YnXtt"| j#d�t$�}#|"j#dd�}"t%|#t&�r�|!r�t|!d�}$|"dk}%|%rAd}"|$dkr�tj'|$�}"|$t(j)kr�|%r�|"dt!|�7}"n|"dt!|�7}"|#|$|"��|#|"��dS)Nz/bin/shz-crrI�=z!illegal environment variable namec3s-|]#}tjjtj|���VqdS)N)r��pathru�fsencode)�.0�dir)r�rr	�	<genexpr>�sz'Popen._execute_child.<locals>.<genexpr>Tr�rGiP��:rHsSubprocessError�0sBad exception data from child: �ascii�errors�
surrogatepass��noexecrpz: r�r�r�r�r�r�)*r�r��bytes�listr�r�r`�dupr�r]r�r8r��dirname�tuple�
get_exec_path�set�add�_posixsubprocess�	fork_exec�sorted�mapr7r�r�r^r��	bytearrayr�r�waitpid�ChildProcessError�split�repr�builtinsr�r�
issubclassr��strerrorr��ENOENT)&rrcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��orig_executable�errpipe_read�
errpipe_write�low_fds_to_close�low_fd�env_list�krW�executable_list�fds_to_keep�
devnull_fd�errpipe_data�part�exception_name�	hex_errno�err_msg�child_exception_type�	errno_num�child_exec_never_calledr)r�r	r��s�	



%

$
$
$

		
	

	cCsl||�r||�|_nI||�r=||�|_n+||�r\||�|_ntd��dS)NzUnknown child exit status!)rr)rr��_WIFSIGNALED�	_WTERMSIG�
_WIFEXITED�_WEXITSTATUS�_WIFSTOPPED�	_WSTOPSIGrrr	�_handle_exitstatus
szPopen._handle_exitstatuscCs�|jdkr�|jjd�s%dSz�yN|jdk	rA|jS||j|�\}}||jkru|j|�WnUtk
r�}z5|dk	r�||_n|j|kr�d|_WYdd}~XnXWd|jj�X|jS)NFr)rr��acquirer�r5r�r��release)rr>�_waitpid�_WNOHANG�_ECHILDr�r��errr	r@s 	 cCsMytj|j|�\}}Wn!tk
rB|j}d}YnX||fS)Nr)r�rr�r)r�
wait_flagsr�r�rrr	�	_try_waitBs
	zPopen._try_waitcCs�|jdk	r|jS|dk	s.|dk	re|dkrJt�|}n|dkre|j|�}|dk	r=d}x+|jjd�r�zI|jdk	r�P|jtj�\}}||jkr�|j	|�PWd|jj
�X|j|�}|dkrt|j|��t
|d|d�}tj|�qzWnhxe|jdkr�|j�F|jdk	riP|jd�\}}||jkr�|j	|�WdQRXq@W|jS)Ng����Mb@?FrrHg�������?)rr�r�r�r6r=r��WNOHANGr�r5r7rrc�min�time�sleep)rrr��delayr�r��	remainingrrr	rgOs@

c#Cs�|jre|jrey|jj�Wntk
r8YnX|sey|jj�Wntk
rdYnXd}d}|js�i|_|jr�g|j|j<|jr�g|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
j�x�|j�r|j|�}|dk	r�|dkr�t|j|��|j|�}	|j||�x6|	D].\}
}|
j|jkr�||j|jt�}y"|jtj|
j|�7_Wn/tk
rt|j|
j�|
jj�YqX|jt|j	�kr|j|
j�|
jj�q�|
j|j|jfkr�tj|
jd�}
|
s|j|
j�|
jj�|j|
jj|
�q�Wq~WWdQRX|j d|j|��|dk	rZdj!|�}|dk	rudj!|�}|j"r�|dk	r�|j#||jj$�}|dk	r�|j#||jj$�}||fS)Nri�rrq)%rwr��flushr�r��_fileobj2outputrr�_save_inputr��
memoryview�_PopenSelector�register�	selectors�EVENT_WRITE�
EVENT_READ�get_mapr�rrc�selectr��fileobj�
_input_offset�	_PIPE_BUFr�r�r��
unregisterrr�r`rgruror�r�)rrnr�r�rr�
input_view�selectorr�ready�key�events�chunkr�rrr	r��s�

						
				"

&			cCs^|jrZ|jdkrZd|_||_|jrZ|dk	rZ|jj|jj�|_dS)Nr)rwr�rPro�encoder�)rrnrrr	rF�s
		zPopen._save_inputcCs&|jdkr"tj|j|�dS)N)rr�rhr�)rr�rrr	r��scCs|jtj�dS)N)r�r�r�)rrrr	r��scCs|jtj�dS)N)r�r��SIGKILL)rrrr	rh�sz
Popen.killr�)/rrrr�r�rr�r�r�rArBr=r�r�rxryr�r�r�r�r�r�r<r�Z
WAIT_OBJECT_0r�r@rgr�r�r�r�rhr��WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS�
WIFSTOPPED�WSTOPSIGr5rr>r��ECHILDr=rFrrrr	r s^)	�
1H	=4	6�	"
1_r�������)<rA�platformr�r�r�r@r�rr�r�rr��	Exceptionrr
rr�r�r<rrrNrJ�ImportError�dummy_threadingr^rQr�rrH�SelectSelector�__all__r+r,r-r.r/r0r1r2r�r7r3r?rFr!r"r)rfr#r$r'�objectr*r(r�r%r&r�r rrrr	�<module>,sl
	:
,!2I
	

?>