AlkantarClanX12

Your IP : 18.221.27.56


Current Path : /lib64/python3.8/__pycache__/
Upload File :
Current File : //lib64/python3.8/__pycache__/subprocess.cpython-38.opt-2.pyc

U

e5d�1�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddlm
Zddddddd	d
ddd
dddgZzddl
Z
ddlZdZWn0ek
r�dZddlZddlZddlZYn�XddlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%e�&ddddddddddddd d!d"d#d$d%d&g�Gd'd�de'�Z(Gd(d�de(�Z)Gd)d�de(�Z*e�r�Gd*d�d�Z+Gd+d,�d,e,�Z-n&e.ed-d.�Z/e0ed/��r�ej1Z2nej3Z2e�r�dZ4d0d1�Z5ngZ4d2d1�Z5d3Z6d4Z7d5Z8d6d7�Z9d8d9�Z:dd:�d;d�Z;d<d�Z<dd:�d=d
�Z=Gd>d�de>�Z?ddddd?�d@d�Z@dAdB�ZAdCd�ZBdDd	�ZCdEdF�ZDeD�ZEGdGd�de>�ZFdS)H�N)�	monotonic�Popen�PIPE�STDOUT�call�
check_call�getstatusoutput�	getoutput�check_output�run�CalledProcessError�DEVNULL�SubprocessError�TimeoutExpired�CompletedProcessTF)�CREATE_NEW_CONSOLE�CREATE_NEW_PROCESS_GROUP�STD_INPUT_HANDLE�STD_OUTPUT_HANDLE�STD_ERROR_HANDLE�SW_HIDE�STARTF_USESTDHANDLES�STARTF_USESHOWWINDOW�ABOVE_NORMAL_PRIORITY_CLASS�BELOW_NORMAL_PRIORITY_CLASS�HIGH_PRIORITY_CLASS�IDLE_PRIORITY_CLASS�NORMAL_PRIORITY_CLASS�REALTIME_PRIORITY_CLASS�CREATE_NO_WINDOW�DETACHED_PROCESS�CREATE_DEFAULT_ERROR_MODE�CREATE_BREAKAWAY_FROM_JOBrrrrrrrr�STARTUPINFOrrrrrrrr r!r"c@seZdZdS)rN)�__name__�
__module__�__qualname__�r'r'�"/usr/lib64/python3.8/subprocess.pyr`sc@s8eZdZd	dd�Zdd�Zedd��Zejdd��ZdS)
rNcCs||_||_||_||_dS�N)�
returncode�cmd�output�stderr)�selfr*r+r,r-r'r'r(�__init__jszCalledProcessError.__init__cCsh|jrT|jdkrTzd|jt�|j�fWStk
rPd|j|jfYSXnd|j|jfSdS)NrzCommand '%s' died with %r.z)Command '%s' died with unknown signal %d.z.Command '%s' returned non-zero exit status %d.)r*r+�signalZSignals�
ValueError�r.r'r'r(�__str__ps���zCalledProcessError.__str__cCs|jSr)�r,r2r'r'r(�stdout|szCalledProcessError.stdoutcCs
||_dSr)r4�r.�valuer'r'r(r5�s)NN�r$r%r&r/r3�propertyr5�setterr'r'r'r(rcs

c@s8eZdZd	dd�Zdd�Zedd��Zejdd��ZdS)
rNcCs||_||_||_||_dSr))r+�timeoutr,r-)r.r+r;r,r-r'r'r(r/�szTimeoutExpired.__init__cCsd|j|jfS)Nz'Command '%s' timed out after %s seconds)r+r;r2r'r'r(r3�s
�zTimeoutExpired.__str__cCs|jSr)r4r2r'r'r(r5�szTimeoutExpired.stdoutcCs
||_dSr)r4r6r'r'r(r5�s)NNr8r'r'r'r(r�s

c@s,eZdZddddddd�dd�Zdd�ZdS)r#rN��dwFlags�	hStdInput�
hStdOutput�	hStdError�wShowWindow�lpAttributeListcCs0||_||_||_||_||_|p(dgi|_dS)N�handle_listr<)r.r=r>r?r@rArBr'r'r(r/�szSTARTUPINFO.__init__cCs@|j��}d|kr"t|d�|d<t|j|j|j|j|j|d�S)NrCr<)	rB�copy�listr#r=r>r?r@rA)r.Z	attr_listr'r'r(rD�s
�zSTARTUPINFO.copy)r$r%r&r/rDr'r'r'r(r#�s�	c@s2eZdZdZejfdd�Zdd�Zdd�ZeZ	dS)	�HandleFcCs|jsd|_||�dS)NT)�closed)r.�CloseHandler'r'r(�Close�szHandle.ClosecCs |jsd|_t|�Std��dS)NTzalready closed)rG�intr1r2r'r'r(�Detach�sz
Handle.DetachcCsd|jjt|�fS)Nz%s(%d))�	__class__r$rJr2r'r'r(�__repr__�szHandle.__repr__N)
r$r%r&rG�_winapirHrIrKrM�__del__r'r'r'r(rF�s
rFZPIPE_BUFi�PollSelectorcCsdSr)r'r'r'r'r(�_cleanup�srQc	Cs\tdkrdStdd�D]>}|jtjd�}|dk	rzt�|�Wqtk
rTYqXqdS)N��
_deadstate)�_active�_internal_poll�sys�maxsize�remover1)�inst�resr'r'r(rQ�s���������cCs*g}tjj}|dkr&|�dd|�|S)Nr�-�O)rV�flags�optimize�append)�argsr7r'r'r(�"_optim_args_from_interpreter_flagss
rdcCsVddddddd�}t�}|��D].\}}ttj|�}|dkr |�d	||�q tjjrd|�d
�n$tjjrv|�d�tjjr�|�d�tj	dd�}tjj
}ttd
i�}d|k}|dkr�|�d�n|r�|�d�|r�|�d�|D]}|�d|�q�|�r
|�d�dD]B}||k�r||}	|	dk�r4|}
nd||	f}
|�d|
f��q|S)N�d�B�S�v�b�q)�debug�dont_write_bytecode�no_site�verbose�
bytes_warning�quietrr^z-Iz-Ez-s�	_xoptions�dev�zerror::BytesWarningzdefault::BytesWarning�defaultz-W)�-Xrr)Zfaulthandler�tracemallocZ
importtimeZshowalloccountZshowrefcount�utf8Tz%s=%sru)
rd�items�getattrrVr`rb�isolated�ignore_environment�no_user_site�warnoptionsrorX�extend)Zflag_opt_maprc�flag�optrhZwarnoptsroZxoptions�dev_moder7�argr'r'r(�_args_from_interpreter_flagssP�






r��r;c
OsLt||��8}z|j|d�WW5QR�S|���YnXW5QRXdS)Nr�)r�wait�kill)r;�	popenargs�kwargs�pr'r'r(rLscOs6t||�}|r2|�d�}|dkr(|d}t||��dS)Nrcr)r�getr)r�r��retcoder+r'r'r(r]s



cOsbd|krtd��d|krJ|ddkrJ|�d�s8|�d�r>d}nd}||d<t|t|dd	�|��jS)
Nr5z3stdout argument not allowed, it will be overridden.�input�universal_newlines�text��T)r5r;�check)r1r�rrr5)r;r�r��emptyr'r'r(r
ps#�c@s&eZdZddd�Zdd�Zdd�ZdS)	rNcCs||_||_||_||_dSr))rcr*r5r-)r.rcr*r5r-r'r'r(r/�szCompletedProcess.__init__cCshd�|j�d�|j�g}|jdk	r4|�d�|j��|jdk	rP|�d�|j��d�t|�jd�|��S)Nz	args={!r}zreturncode={!r}zstdout={!r}zstderr={!r}z{}({})z, )	�formatrcr*r5rbr-�typer$�join)r.rcr'r'r(rM�s

�

zCompletedProcess.__repr__cCs |jrt|j|j|j|j��dSr))r*rrcr5r-r2r'r'r(�check_returncode�s�z!CompletedProcess.check_returncode)NN)r$r%r&r/rMr�r'r'r'r(r�s
	)r��capture_outputr;r�cOs |dk	r&|�d�dk	rtd��t|d<|r^|�d�dk	sF|�d�dk	rNtd��t|d<t|d<t||���}z|j||d�\}}Wn^tk
r�}	z,|��tr�|��\|	_|	_	n|�
��W5d}	~	XYn|���YnX|��}
|�r|
�rt|
|j
||d��W5QRXt|j
|
||�S)N�stdinz/stdin and input arguments may not both be used.r5r-z@stdout and stderr arguments may not be used with capture_output.r��r,r-)r�r1rr�communicaterr��
_mswindowsr5r-r��pollrrcr)r�r�r;r�r�r�Zprocessr5r-�excr�r'r'r(r�s8�cCs�g}d}ttj|�D]�}g}|r*|�d�d|kp>d|kp>|}|rN|�d�|D]b}|dkrj|�|�qR|dkr�|�dt|�d�g}|�d�qR|r�|�|�g}|�|�qR|r�|�|�|r|�|�|�d�qd�|�S)	NF� �	�"�\�z\"r�)�map�os�fsdecoderb�lenr~r�)�seq�resultZ	needquoter�Zbs_buf�cr'r'r(�list2cmdline	s4




r�c
Cslzt|ddtd�}d}Wn.tk
rF}z|j}|j}W5d}~XYnX|dd�dkrd|dd�}||fS)NT)�shellr�r-rr[�
)r
rrr,r*)r+�dataZexitcodeZexr'r'r(rRscCst|�dS�Nrs)r)r+r'r'r(r	qs
c
Cs�tsttd�sdStjdkr dSzjt�d�}|jdd�}t|�dkrHt�|d	}t	t
t|d�d
���}tjdkr�|dkr�|d
kr�WdSWnttt
fk
r�YnXdS)N�posix_spawnF�darwinT�CS_GNU_LIBC_VERSIONrs)�maxsplitr�r�.ZlinuxZglibc)r��)r��hasattrr�rV�platform�confstr�splitr�r1�tupler�rJ�AttributeError�OSError)Zver�partsZlibc�versionr'r'r(�_use_posix_spawn~s 



r�c@s�eZdZdZdJdddd�dd	�Zed
d��Zejdd��Zd
d�Zdd�Z	dd�Z
eje
jfdd�Zdd�Zdd�ZdKdd�Zdd�Zdd�ZdLdd �ZdMd!d"�Zd#d$�Ze�rd%d&�Zd'd(�Zd)d*�Zd+d,�Zdejejej fd-d.�Z!d/d0�Z"d1d2�Z#d3d4�Z$d5d6�Z%d7d8�Z&e&Z'n�d9d&�Zd:d;�Z(d<d,�Ze)j*e)j+e)j,e)j-e)j.e)j/fd=d>�Z0de)j1e)j2e3j4fd?d.�Z!d@dA�Z5dBd0�Z"dCd4�Z$dDdE�Z6dFd6�Z%dGd8�Z&dHdI�Z'dS)NrFr[NTrr')�encoding�errorsr�cCslt�t��|_d|_d|_|dkr(d}t|t�s:td��t	rP|dk	r�t
d��n8|rh|sht�dt
�d}|
dk	rxt
d��|dkr�t
d	��||_d|_d|_d|_d|_d|_||_||_|dk	r�|dk	r�t|�t|�kr�td
��|�|||�\}}}}}}t	�rN|dk�rt�|��d�}|dk�r4t�|��d�}|dk�rNt�|��d�}|�pb|�pb|�pb||_d|_d|_|j�r�|dk�r�d}d}nd}z�|dk�r�t� |d
|�|_|j�r�tj!|jd|||d�|_|dk�rt� |d|�|_|j�rtj!|j||d�|_|dk�r:t� |d|�|_|j�r:tj!|j||d�|_|�"||||||
||
||	||||||||�Wn�t#d|j|j|jf�D]*}z|�$�Wnt%k
�r�YnX�q�|j�s`g}|t&k�r�|�'|�|t&k�r�|�'|�|t&k�r�|�'|�t(|d��r|�'|j)�|D]H}z*t	�r8t|t*��r8|�+�n
t,�$|�Wnt%k
�rZYnX�q�YnXdS)NFr[zbufsize must be an integerz0preexec_fn is not supported on Windows platformszpass_fds overriding close_fds.Tz2startupinfo is only supported on Windows platformsrz4creationflags is only supported on Windows platformszlCannot disambiguate when both text and universal_newlines are supplied but different. Pass one or the other.g�?rs�wb)�
write_through�line_bufferingr�r��rb)r�r��_devnull)-rQ�	threadingZLock�
_waitpid_lock�_input�_communication_started�
isinstancerJ�	TypeErrorr�r1�warnings�warn�RuntimeWarningrcr�r5r-�pidr*r�r��boolr�_get_handles�msvcrtZopen_osfhandlerK�	text_mode�_sigint_wait_secs�_closed_child_pipe_fds�io�open�
TextIOWrapper�_execute_child�filter�closer�rrbr�r�rFrIr�)r.rc�bufsize�
executabler�r5r-�
preexec_fn�	close_fdsr��cwd�envr��startupinfo�
creationflags�restore_signals�start_new_session�pass_fdsr�r�r��p2cread�p2cwrite�c2pread�c2pwrite�errread�errwriter��fZto_close�fdr'r'r(r/�s�


��





�
�
��








zPopen.__init__cCs|jSr))r�r2r'r'r(r�~szPopen.universal_newlinescCst|�|_dSr))r�r�)r.r�r'r'r(r��scCs |�||�}|�dd��dd�S)Nz
r��
)�decode�replace)r.r�r�r�r'r'r(�_translate_newlines�szPopen._translate_newlinescCs|Sr)r'r2r'r'r(�	__enter__�szPopen.__enter__cCs�|jr|j��|jr |j��dz|jr4|j��W5|tkr�|jdkrrz|j|jd�Wntk
rpYnXd|_�dS|��XdS)Nrr�)	r5r�r-�KeyboardInterruptr��_waitrr�r�)r.�exc_typer7�	tracebackr'r'r(�__exit__�s 


zPopen.__exit__cCsT|js
dS|jdkr(|d|jt|d�|j|d�|jdkrPtdk	rPt�|�dS)Nzsubprocess %s is still running)�sourcerR)�_child_createdr*r��ResourceWarningrUrTrb)r.Z_maxsizeZ_warnr'r'r(rO�s

�z
Popen.__del__cCs"t|d�st�tjtj�|_|jS)Nr�)r�r�r��devnull�O_RDWRr�r2r'r'r(�_get_devnull�s
zPopen._get_devnullc
Cs�|rZz|j�|�WnDtk
r(Yn2tk
rX}z|jtjkrFn�W5d}~XYnXz|j��WnDtk
r|Yn2tk
r�}z|jtjkr�n�W5d}~XYnXdSr))r��write�BrokenPipeErrorr��errnoZEINVALr�)r.r�r�r'r'r(�_stdin_write�s"zPopen._stdin_writecCsT|jr|rtd��|dkr�|js�|j|j|jg�d�dkr�d}d}|jrT|�|�n6|jrp|j��}|j��n|jr�|j��}|j��|�	�n�|dk	r�t
�|}nd}z�z|�|||�\}}Wnhtk
�r,|dk	r�t
|j|�|��}n|j}d|_z|j|d�Wntk
�r$YnX�YnXW5d|_X|j	|�|�d�}||fS)Nz.Cannot send input after starting communicationr�Trr�)r�r1r�r5r-�countr�readr�r��_time�_communicater��minr��_remaining_timer�r)r.r�r;r5r-�endtime�sigint_timeout�stsr'r'r(r��sH
�



�zPopen.communicatecCs|��Sr))rUr2r'r'r(r�sz
Popen.pollcCs|dkrdS|t�SdSr))r)r.r	r'r'r(r"szPopen._remaining_timecCsL|dkrdS|st�|krHt|j||r0d�|�nd|r@d�|�ndd��dS)Nr�r�)rrrcr�)r.r	�orig_timeoutZ
stdout_seqZ
stderr_seq�skip_check_and_raiser'r'r(�_check_timeout*s�zPopen._check_timeoutcCs�|dk	rt�|}z|j|d�WStk
r�|dk	rLt|j|�|��}n|j}d|_z|j|d�Wntk
r|YnX�YnXdS)Nr�r)rr�r�rr�rr)r.r;r	r
r'r'r(r�6s 
�z
Popen.waitc		Cs�t|dd�}t����}trX|dkr.|�|j�|dkrB|�|j�|dkr�|�|j�nr|dkr~|dkr~||kr~|�tj|�|dkr�|dkr�||kr�|�tj|�|dkr�|dkr�||kr�|�tj|�|dk	r�|�tj|�W5QRXd|_dS)Nr�r[T)	ry�
contextlib�	ExitStackr��callbackrIr�r�r�)	r.r�r�r�r�r�r�Z
devnull_fd�stackr'r'r(�_close_pipe_fdsMs$
zPopen._close_pipe_fdscCs~|dkr|dkr|dkrdSd\}}d\}}d\}}	|dkrtt�tj�}|dkr�t�dd�\}}
t|�}t�|
�nh|tkr�t�dd�\}}t|�t|�}}n<|tkr�t�	|�
��}n$t|t�r�t�	|�}nt�	|�
��}|�|�}|dk�r*t�tj�}|dk�r�t�dd�\}
}t|�}t�|
�nn|tk�rXt�dd�\}}t|�t|�}}n@|tk�rrt�	|�
��}n&t|t��r�t�	|�}nt�	|�
��}|�|�}|dk�r�t�tj�}	|	dk�rdt�dd�\}
}	t|	�}	t�|
�n~|tk�rt�dd�\}}	t|�t|	�}}	nP|tk�r$|}	n@|tk�r>t�	|�
��}	n&t|t��rVt�	|�}	nt�	|�
��}	|�|	�}	||||||	fS)N)r[r[r[r[r[r[�r[r[r)rNZGetStdHandlerZ
CreatePiperFrHrr
r�Z
get_osfhandler�r�rJ�fileno�_make_inheritablerrr)r.r�r5r-r�r�r�r�r�r��_r'r'r(r�nst












�zPopen._get_handlescCs&t�t��|t��ddtj�}t|�S)Nrrs)rNZDuplicateHandleZGetCurrentProcessZDUPLICATE_SAME_ACCESSrF)r.�handle�hr'r'r(r�s�zPopen._make_inheritablecCstdd�|D��S)NcSs,h|]$}|d@dks$t�|�tjkr|�qS)�)rNZGetFileTypeZFILE_TYPE_CHAR)�.0rr'r'r(�	<setcomp>�s��z,Popen._filter_handle_list.<locals>.<setcomp>)rE)r.rCr'r'r(�_filter_handle_list�szPopen._filter_handle_listcCszt|t�rnNt|t�r.|
r"td��t|g�}n,t|tj�rR|
rFtd��t|g�}nt|�}|dk	rlt�|�}|dkr|t�}n|�	�}d|||fk}|r�|j
tjO_
||_
||_||_|j}t|o�d|ko�|d�}|s�|�r^|�r^|dkr�i}|_t|�dg��}|d<|�r0|t|�t|�t|�g7}|�|�|dd�<|�r^|�sZt�dt�d}|
�r�|j
tjO_
tj|_|�s�tj�d�}|�s�tj�dd	�}tj�|d
d�}tj�|��s�t d��tj�|��r�|}n|}d
�!||�}|dk	�rt�|�}t"�#d||||�z,t�%||ddt|�|	|||�	\}}}}W5|�$|||
|||�Xd|_&t'|�|_(||_)t�*|�dS)Nz$bytes args is not allowed on Windows�0path-like args is not allowed when shell is truer[rCz?startupinfo.lpAttributeList['handle_list'] overriding close_fdsFZComSpecZ
SystemRootr�ZSystem32zcmd.exez:shell not found: neither %ComSpec% nor %SystemRoot% is setz
{} /c "{}"�subprocess.PopenT)+r��str�bytesr�r�r��PathLiker�r#rDr=rNrr>r?r@rBr�rEr�rJrr�r�r�rrrA�environ�pathr��isabs�FileNotFoundErrorr�rV�auditrZ
CreateProcessr�rF�_handler�rH)r.rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Zunused_restore_signalsZunused_start_new_sessionZuse_std_handlesZattribute_listZhave_handle_listrCZcomspecZsystem_rootZhpZhtr��tidr'r'r(r��s�


��
�
�

��
zPopen._execute_childcCs,|jdkr&||jd�|kr&||j�|_|jS�Nr)r*r()r.rSZ_WaitForSingleObjectZ_WAIT_OBJECT_0Z_GetExitCodeProcessr'r'r(rUHs
zPopen._internal_pollcCs^|dkrtj}nt|d�}|jdkrXt�|j|�}|tjkrJt|j|��t�	|j�|_|jS)Ni�)
rNZINFINITErJr*�WaitForSingleObjectr(ZWAIT_TIMEOUTrrc�GetExitCodeProcess)r.r;Ztimeout_millisr�r'r'r(r�Ys
�
zPopen._waitcCs|�|���|��dSr))rbrr�)r.Zfh�bufferr'r'r(�
_readerthreadiszPopen._readerthreadcCs\|jrBt|d�sBg|_tj|j|j|jfd�|_d|j_|j��|j	r�t|d�s�g|_
tj|j|j	|j
fd�|_d|j_|j��|jr�|�
|�|jdk	r�|j�|�|��|j��r�t|j|��|j	dk	r�|j�|�|��|j��r�t|j|��d}d}|j�r|j}|j��|j	�r0|j
}|j	��|�r>|dnd}|�rP|dnd}||fS)N�_stdout_buff)�targetrcT�_stderr_buffr)r5r�r/r�ZThreadr.Z
stdout_threadZdaemon�startr-r1Z
stderr_threadr�rr�rZis_aliverrcr�)r.r�r	rr5r-r'r'r(rnsJ
��

��







zPopen._communicatecCsl|jdk	rdS|tjkr"|��nF|tjkr>t�|jtj�n*|tjkrZt�|jtj�nt	d�
|���dS)NzUnsupported signal: {})r*r0�SIGTERM�	terminateZCTRL_C_EVENTr�r�r�ZCTRL_BREAK_EVENTr1r��r.Zsigr'r'r(�send_signal�s




zPopen.send_signalcCsX|jdk	rdSzt�|jd�Wn2tk
rRt�|j�}|tjkrH�||_YnXdSr�)r*rNZTerminateProcessr(�PermissionErrorr,ZSTILL_ACTIVE)r.Zrcr'r'r(r4�s

zPopen.terminatec
Cs,d\}}d\}}d\}}	|dkr"n@|tkr8t��\}}n*|tkrJ|��}nt|t�rZ|}n|��}|dkrln@|tkr�t��\}}n*|tkr�|��}nt|t�r�|}n|��}|dkr�nf|tkr�t��\}}	nP|tkr�|dkr�|}	n
t	j
��}	n.|tk�r|��}	nt|t��r|}	n|��}	||||||	fS)Nrr[)rr��piper
r�r�rJrrrV�
__stdout__)
r.r�r5r-r�r�r�r�r�r�r'r'r(r��sP





�cCs�|dkrtj}i}|rJg}dD]"}
tt|
d�}|dk	r|�|�q||d<g}|||	fD]}|dkrX|�tj|f�qX|df|df|
dffD]"\}}|dkr�|�tj||f�q�|r�||d<tj|||f|�|_d|_	|�
|||||	|
�dS)	N)�SIGPIPEZSIGXFZ�SIGXFSZZ	setsigdefr[rrsr��file_actionsT)r�r#ryr0rb�POSIX_SPAWN_CLOSE�POSIX_SPAWN_DUP2r�r�r�r)r.rcr�r�r�r�r�r�r�r�r�r�ZsigsetZsignameZsignumr<r�Zfd2r'r'r(�_posix_spawn�s<��zPopen._posix_spawnc)s�t|ttf�r|g}n(t|tj�r6|
r.td��|g}nt|�}|
rlttd�rPdnd}|dg|}�rl�|d<�dkr||d�t�	d�|||�t
�rtj����r|dk�r|�s|�s|dk�r|dks�|d	k�r|dks�|d	k�r|dks�|d	k�r|�s|�
|�|||||
|||�
dS�}t��\}}g}|d
k�rT|�|�t�|�}�q2|D]}t�|��qX�zJz�|dk	�r�g}|��D]>\}}t�|�}d|k�r�td��|�|dt�|���q�nd}t����tj����r�f}nt�fd
d�t�|�D��}t|�}|�|�t�|||tttt|���|||||
||||||||�|_d|_W5t�|�X|� |||
|||�t!�}t�"|d�}||7}|�r�t#|�dk�r��q��q�W5t�|�X|�r�z6t�$|jd�\} }!| |jk�r�|�%|!�ntj&|_'Wnt(k
�rYnXz|�)dd	�\}"}#}$|$�*�}$Wn,tk
�rbd}"d}#d�+t|��}$YnXt,t-|"�*d�t.�}%t/|%t0��r�|#�r�t|#d�}&|$dk}'|'�r�d}$|}(n|}(|&dk�r�t�1|&�}$|%|&|$|(��|%|$��dS)NrZgetandroidapilevelz/system/bin/shz/bin/shz-crrr[r�r�=z!illegal environment variable namec3s"|]}tj�t�|���VqdSr))r�r$r��fsencode)r�dir�r�r'r(�	<genexpr>rs�z'Popen._execute_child.<locals>.<genexpr>TiP��:sSubprocessError�0z#Bad exception data from child: {!r}�ascii�Znoexecr�)2r�r r!r�r"r�rEr�rVr'�_USE_POSIX_SPAWNr$�dirnamer?r8rb�dupr�rxrAr1r��
get_exec_path�set�add�_posixsubprocessZ	fork_exec�sortedr�rJr�r�r�	bytearrayrr��waitpid�_handle_exitstatusrWr*�ChildProcessErrorr�r�r�ry�builtinsr�
issubclassr��strerror))r.rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Z
unix_shellZorig_executableZerrpipe_readZ
errpipe_writeZlow_fds_to_closeZlow_fdZenv_list�krhZexecutable_listZfds_to_keepZerrpipe_data�partr�rZexception_nameZ	hex_errno�err_msgZchild_exception_typeZ	errno_numZchild_exec_never_calledZerr_filenamer'rCr(r� s"	��
�����������	�
�





�
�
�
��
�


cCsL||�r||�|_n2||�r*||�|_n||�r@||�|_ntd��dS)NzUnknown child exit status!)r*r)r.rZ_WIFSIGNALEDZ	_WTERMSIGZ
_WIFEXITEDZ_WEXITSTATUSZ_WIFSTOPPEDZ	_WSTOPSIGr'r'r(rS�szPopen._handle_exitstatusc
Cs�|jdkr�|j�d�sdSz�z>|jdk	r4|jWW�pS||j|�\}}||jkrX|�|�WnBtk
r�}z$|dk	r|||_n|j|kr�d|_W5d}~XYnXW5|j��X|jS)NFr)r*r��acquire�releaser�rSr�r)r.rSZ_waitpidZ_WNOHANGZ_ECHILDr�r�er'r'r(rU�s 	



cCs>zt�|j|�\}}Wntk
r4|j}d}YnX||fSr*)r�rRr�rT)r.Z
wait_flagsr�rr'r'r(�	_try_wait�s
zPopen._try_waitc	Cs|jdk	r|jS|dk	r�t�|}d}|j�d�r~z>|jdk	rDW�0q�|�tj�\}}||jkrn|�	|�W�q�W5|j��X|�
|�}|dkr�t|j|��t
|d|d�}t�|�q&n\|jdk�r|j�B|jdk	r�W5QR��q|�d�\}}||jk�r
|�	|�W5QRXq�|jS)Ng����Mb@?Frr�g�������?)r*rr�r[r\r^r��WNOHANGr�rSrrrcr�time�sleep)r.r;r	Zdelayr�rZ	remainingr'r'r(r��s6







c
Cs"|jrX|jsXz|j��Wntk
r.YnX|sXz|j��Wntk
rVYnXd}d}|js�i|_|jr~g|j|j<|jr�g|j|j<|jr�|j|j}|jr�|j|j}|�|�|j	r�t
|j	�}t����}|jr�|r�|�|jt
j�|j�r|jj�s|�|jt
j�|j�r6|jj�s6|�|jt
j�|���r�|�|�}|dk	�rz|dk�rz|j||||dd�td��|�|�}	|�||||�|	D]�\}
}|
j|jk�r6||j|jt�}z|jt�|
j|�7_Wn,tk
�r
|�|
j�|
j��Yn*X|jt|j	�k�r�|�|
j�|
j��nP|
j|j|jfk�r�t�|
jd�}
|
�st|�|
j�|
j��|j|
j�|
��q��q6W5QRX|j |�|�d�|dk	�r�d�!|�}|dk	�r�d�!|�}|j"�r|dk	�r�|�#||jj$|jj%�}|dk	�r|�#||jj$|jj%�}||fS)NrT)r
zN_check_timeout(..., skip_check_and_raise=True) failed to raise TimeoutExpired.i�r�r�)&r�r��flushrr�Z_fileobj2outputr5r-�_save_inputr��
memoryview�_PopenSelector�register�	selectorsZEVENT_WRITErGZ
EVENT_READZget_maprr�RuntimeError�selectZfileobj�
_input_offset�	_PIPE_BUFr�r�r�Z
unregisterr�rrbr�r�r�r�r�r�)r.r�r	rr5r-Z
input_viewZselectorr;Zready�keyZevents�chunkr�r'r'r(r's�





��
�
$




�
�cCsF|jrB|jdkrBd|_||_|dk	rB|jrB|j�|jj|jj�|_dSr*)r�r�rjr��encoder�r�)r.r�r'r'r(rc�s�zPopen._save_inputcCs|jdkrt�|j|�dSr))r*r�r�r�r5r'r'r(r6�s
cCs|�tj�dSr))r6r0r3r2r'r'r(r4�scCs|�tj�dSr))r6r0�SIGKILLr2r'r'r(r��sz
Popen.kill)r[NNNNNTFNNNNrTFr')NN)F)N)7r$r%r&r�r/r9r�r:r�r�r�rVrWr�r�rOr�rr�r�rrr�rr�r�rrr�rNr+Z
WAIT_OBJECT_0r,rUr�r.rr6r4r�r?r��WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS�
WIFSTOPPED�WSTOPSIGrSrRr_rZECHILDr^rcr'r'r'r(r�s�.��


D	�

H	
|�
26'�
�
#
)f)GrUrr�r�r`r0rVr�r�rrr�__all__r�rNr��ModuleNotFoundErrorrOrirgrrrrrrrrrrrrrrrr r!r"r~�	Exceptionrrrr#rJrFryrkr�rPreZSelectSelectorrTrQrrr
rdr�rrr
�objectrrr�rr	r�rIrr'r'r'r(�<module>,s��P
�
%	


;3"�EI
/