AlkantarClanX12

Your IP : 3.133.151.90


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/subprocess.cpython-39.opt-2.pyc

a

R�flF�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddlm
ZddlZzddl
Z
Wney�dZ
Yn0zddlZWney�dZYn0gd�ZzddlZddlZdZWn.ey�dZddlZddlZddlZYn`0ddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)e�*gd��Gdd	�d	e+�Z,Gd
d�de,�Z-Gdd
�d
e,�Z.e�r�Gdd�d�Z/Gdd�de0�Z1n&e2edd�Z3e4ed��r�ej5Z6nej7Z6e�r�dZ8dd�Z9ngZ8dd�Z9dZ:dZ;dZ<dd�Z=dd�Z>dd�d d!�Z?d"d#�Z@dd�d$d%�ZAGd&d'�d'eB�ZCddddd(�d)d*�ZDd+d,�ZEd-d.�ZFd/d0�ZGd1d2�ZHeH�ZIGd3d4�d4eB�ZJdS)5�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_JOB)rrrrrrrr�STARTUPINFOrrrrrrrr r!r"c@seZdZdS)rN)�__name__�
__module__�__qualname__�r'r'�//opt/alt/python39/lib64/python3.9/subprocess.pyri�rc@s8eZdZd	dd�Zdd�Zedd��Zejdd��ZdS)
rNcCs||_||_||_||_dS�N)�
returncode�cmd�output�stderr)�selfr+r,r-r.r'r'r(�__init__sszCalledProcessError.__init__cCsf|jrR|jdkrRzd|jt�|j�fWStyNd|j|jfYS0nd|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__ys�
��zCalledProcessError.__str__cCs|jSr*�r-r3r'r'r(�stdout�szCalledProcessError.stdoutcCs
||_dSr*r5�r/�valuer'r'r(r6�s)NN�r$r%r&r0r4�propertyr6�setterr'r'r'r(rls

rc@s8eZdZd	dd�Zdd�Zedd��Zejdd��ZdS)
rNcCs||_||_||_||_dSr*)r,�timeoutr-r.)r/r,r<r-r.r'r'r(r0�szTimeoutExpired.__init__cCsd|j|jfS)Nz'Command '%s' timed out after %s seconds)r,r<r3r'r'r(r4�s
�zTimeoutExpired.__str__cCs|jSr*r5r3r'r'r(r6�szTimeoutExpired.stdoutcCs
||_dSr*r5r7r'r'r(r6�s)NNr9r'r'r'r(r�s

rc@s,eZdZddddddd�dd�Zdd�ZdS)r#rN��dwFlags�	hStdInput�
hStdOutput�	hStdError�wShowWindow�lpAttributeListcCs0||_||_||_||_||_|p(dgi|_dS)N�handle_listr=)r/r>r?r@rArBrCr'r'r(r0�szSTARTUPINFO.__init__cCs@|j��}d|vr"t|d�|d<t|j|j|j|j|j|d�S)NrDr=)	rC�copy�listr#r>r?r@rArB)r/Z	attr_listr'r'r(rE�s
�zSTARTUPINFO.copy)r$r%r&r0rEr'r'r'r(r#�s�	r#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)rH�intr2r3r'r'r(�Detach�sz
Handle.DetachcCsd|jjt|�fS)Nz%s(%d))�	__class__r$rKr3r'r'r(�__repr__�szHandle.__repr__N)
r$r%r&rH�_winapirIrJrLrN�__del__r'r'r'r(rG�s
rGZPIPE_BUFi�PollSelectorcCsdSr*r'r'r'r'r(�_cleanup�srRc	CsZtdurdStdd�D]<}|jtjd�}|durzt�|�WqtyRYq0qdS)N��
_deadstate)�_active�_internal_poll�sys�maxsize�remover2)�inst�resr'r'r(rR�s���������cCs*g}tjj}|dkr&|�dd|�|S)Nr�-�O)rW�flags�optimize�append)�argsr8r'r'r(�"_optim_args_from_interpreter_flagss
recCsVddddddd�}t�}|��D].\}}ttj|�}|dkr |�d	||�q tjjrd|�d
�n$tjjrv|�d�tjjr�|�d�tj	dd�}tjj
}ttd
i�}d|v}|dkr�|�d�n|r�|�d�|r�|�d�|D]}|�d|�q�|�r
|�d�dD]B}||v�r||}	|	du�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)�-Xrs)Zfaulthandler�tracemallocZ
importtimeZshowrefcount�utf8Z	oldparserTz%s=%srv)
re�items�getattrrWrarc�isolated�ignore_environment�no_user_site�warnoptionsrprY�extend)Zflag_opt_maprd�flag�optriZwarnoptsrpZxoptions�dev_moder8�argr'r'r(�_args_from_interpreter_flagssP�






r��r<cOsft|i|���D}z|j|d�WWd�S|���Yn0Wd�n1sX0YdS)Nr�)r�wait�kill)r<�	popenargs�kwargs�pr'r'r(rUsrcOs:t|i|��}|r6|�d�}|dur,|d}t||��dS)Nrdr)r�getr)r�r��retcoder,r'r'r(rfs


rcOsbd|vrtd��d|vrJ|ddurJ|�d�s8|�d�r>d}nd}||d<t|t|dd	�|��jS)
Nr6z3stdout argument not allowed, it will be overridden.�input�universal_newlines�text�r)T)r6r<�check)r2r�rrr6)r<r�r��emptyr'r'r(r
ys#�r
c@s0eZdZddd�Zdd�Zeej�Zdd�Z	dS)	rNcCs||_||_||_||_dSr*)rdr+r6r.)r/rdr+r6r.r'r'r(r0�szCompletedProcess.__init__cCshd�|j�d�|j�g}|jdur4|�d�|j��|jdurP|�d�|j��d�t|�jd�|��S)Nz	args={!r}zreturncode={!r}zstdout={!r}zstderr={!r}z{}({})z, )	�formatrdr+r6rcr.�typer$�join)r/rdr'r'r(rN�s

�

zCompletedProcess.__repr__cCs |jrt|j|j|j|j��dSr*)r+rrdr6r.r3r'r'r(�check_returncode�s�z!CompletedProcess.check_returncode)NN)
r$r%r&r0rN�classmethod�types�GenericAlias�__class_getitem__r�r'r'r'r(r�s
	
r)r��capture_outputr<r�cOs<|dur&|�d�durtd��t|d<|r^|�d�dusF|�d�durNtd��t|d<t|d<t|i|����}z|j||d�\}}Wn`ty�}	z4|��tr�|��\|	_|	_	n|�
��WYd}	~	nd}	~	0|���Yn0|��}
|�r|
�rt|
|j
||d��Wd�n1�s"0Yt|j
|
||�S)N�stdinz/stdin and input arguments may not both be used.r6r.z@stdout and stderr arguments may not be used with capture_output.r��r-r.)r�r2rr�communicaterr��
_mswindowsr6r.r��pollrrdr)r�r�r<r�r�r�Zprocessr6r.�excr�r'r'r(r�s6�&rcCs�g}d}ttj|�D]�}g}|r*|�d�d|vp>d|vp>|}|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�fsdecoderc�lenrr�)�seq�resultZ	needquoter�Zbs_buf�cr'r'r(�list2cmdlines4




r�c
Csnzt|ddtd�}d}Wn0tyH}z|j}|j}WYd}~n
d}~00|dd�dkrf|dd�}||fS)NT)�shellr�r.rr\�
)r
rrr-r+)r,�dataZexitcodeZexr'r'r(r^srcCst|�dS�Nrt)r)r,r'r'r(r	}s
r	c
Cs�tsttd�sdStjdkr dSzjt�d�}|jdd�}t|�dkrHt�|d	}t	t
t|d�d
���}tjdkr�|dkr�|d
kr�WdSWnttt
fy�Yn0dS)N�posix_spawnF�darwinT�CS_GNU_LIBC_VERSIONrt)�maxsplitr�r�.ZlinuxZglibc)r��)r��hasattrr�rW�platform�confstr�splitr�r2�tupler�rK�AttributeError�OSError)Zver�partsZlibc�versionr'r'r(�_use_posix_spawn�s 



r�c@s�eZdZdZdLdddddddd�dd	�Zd
d�Zeej�Z	e
dd
��Zejdd
��Zdd�Z
dd�Zdd�Zejejfdd�Zdd�Zdd�ZdMdd�Zdd�Zdd �ZdNd!d"�ZdOd#d$�Zd%d&�Ze�r0d'd(�Zd)d*�Zd+d,�Z d-d.�Z!de"j#e"j$e"j%fd/d0�Z&d1d2�Z'd3d4�Z(d5d6�Z)d7d8�Z*d9d:�Z+e+Z,n~d;d(�Zd<d=�Z-d>d.�Z!e.j/e.j0e.j1fd?d@�Z2de.j3e.j4e5j6fdAd0�Z&dBdC�Z7dDd2�Z'dEd6�Z)dFdG�Z8dHd8�Z*dId:�Z+dJdK�Z,dS)PrFr\NTrr')�user�group�extra_groups�encoding�errorsr��umaskc(CsFt�t��|_d|_d|_|dur(d}t|t�s:td��t	rP|dur�t
d��n8|rh|sht�dt
�d}|
durxt
d��|dkr�t
d	��||_d|_d|_d|_d|_d|_||_||_|dur�|dur�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}d} |du�rtt d
��s�t
d��nPt|t!��r�t"du�r�t
d��t"�#|�j$} n$t|t��r�|} ntd�%t&|����| dk�rt
d| ����d}!|du�r�tt d��sBt
d��nt|t!��rVt
d��g}!|D]b}"t|"t!��r�t"du�r�t
d��|!�'t"�#|"�j$�n*t|"t��r�|!�'|"�ntd�%t&|"�����q^|!D]}#|#dk�r�t
d|#�����q�d}$|du�rhtt d��s
t
d��nFt|t!��r6t(du�r(t
d��t(�)|�j*}$nt|t��rH|}$ntd��|$dk�rht
d|$����z�|dk�r�t+�,|d|�|_|j�r�t+j-|jd|||d�|_|dk�r�t+�,|d|�|_|j�r�t+j-|j||d�|_|dk�rt+�,|d|�|_|j�rt+j-|j||d�|_|�.||||||
||
||	|||||||| |!|$||�Wn�t/d|j|j|jf�D](}%z|%�0�Wnt1�y�Yn0�qd|j�s:g}&|t2k�r�|&�'|�|t2k�r�|&�'|�|t2k�r�|&�'|�t|d ��r�|&�'|j3�|&D]F}'z*t	�rt|'t4��r|'�5�n
t �0|'�Wnt1�y4Yn0�q�Yn0dS)!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�?rt�setregidz>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_through�line_bufferingr�r��rb)r�r��_devnull)6rR�	threadingZLock�
_waitpid_lock�_input�_communication_started�
isinstancerK�	TypeErrorr�r2�warnings�warn�RuntimeWarningrdr�r6r.�pidr+r�r��boolr�_get_handles�msvcrtZopen_osfhandlerL�	text_mode�_sigint_wait_secs�_closed_child_pipe_fdsr�r��str�grpZgetgrnamZgr_gidr�r�rc�pwd�getpwnamZpw_uid�io�open�
TextIOWrapper�_execute_child�filter�closer�rr�rGrJ)(r/rd�bufsize�
executabler�r6r.�
preexec_fn�	close_fdsr��cwd�envr��startupinfo�
creationflags�restore_signals�start_new_session�pass_fdsr�r�r�r�r�r�r��p2cread�p2cwrite�c2pread�c2pwrite�errread�errwriter��gid�gidsZextra_groupZ	gid_check�uid�fZto_close�fdr'r'r(r0�s.	


��






�



�







�
�
��	








zPopen.__init__cCs@d|jj�d|j�d|j�d�}t|�dkr<|dd�d}|S)N�<z: returncode: z args: �>�P�Lz...>)rMr$r+rdr�)r/Zobj_reprr'r'r(rN�s���zPopen.__repr__cCs|jSr*)r�r3r'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'r3r'r'r(�	__enter__�szPopen.__enter__cCs�|jr|j��|jr |j��z^|jr2|j��W|tkrv|jdkrlz|j|jd�WntyjYn0d|_dS|��nT|tkr�|jdkr�z|j|jd�Wnty�Yn0d|_YdS|��0dS)Nrr�)	r6r�r.r��KeyboardInterruptr��_waitrr�)r/�exc_typer8�	tracebackr'r'r(�__exit__�s2



�
zPopen.__exit__cCsT|js
dS|jdur(|d|jt|d�|j|d�|jdurPtdurPt�|�dS)Nzsubprocess %s is still running)�sourcerS)�_child_createdr+r��ResourceWarningrVrUrc)r/Z_maxsizeZ_warnr'r'r(rPs

�z
Popen.__del__cCs"t|d�st�tjtj�|_|jS)Nr�)r�r�r��devnull�O_RDWRr�r3r'r'r(�_get_devnull$s
zPopen._get_devnullc
Cs�|rZz|j�|�WnDty&Yn4tyX}z|jtjkrBn�WYd}~n
d}~00z|j��WnDtyzYn4ty�}z|jtjkr�n�WYd}~n
d}~00dSr*)r��write�BrokenPipeErrorr��errnoZEINVALr�)r/r�r�r'r'r(�_stdin_write)s"zPopen._stdin_writecCsV|jr|rtd��|dur�|js�|j|j|jg�d�dkr�d}d}|jrT|�|�n6|jrp|j��}|j��n|jr�|j��}|j��|�	�n�|dur�t
�|}nd}z�z|�|||�\}}Wndt�y(|dur�t
|j|�|��}n|j}d|_z|j|d�Wnt�y Yn0�Yn0Wd|_nd|_0|j	|�|�d�}||fS)Nz.Cannot send input after starting communicationr�rr�T)r�r2r�r6r.�countr�readr�r��_time�_communicater
�minr��_remaining_timerr)r/r�r<r6r.�endtime�sigint_timeout�stsr'r'r(r�BsH
�



�
zPopen.communicatecCs|��Sr*)rVr3r'r'r(r��sz
Popen.pollcCs|durdS|t�SdSr*)r)r/rr'r'r(r�szPopen._remaining_timecCsL|durdS|st�|krHt|j||r0d�|�nd|r@d�|�ndd��dS)Nr)r�)rrrdr�)r/r�orig_timeoutZ
stdout_seqZ
stderr_seq�skip_check_and_raiser'r'r(�_check_timeout�s�zPopen._check_timeoutcCs�|durt�|}z|j|d�WSty�|durJt|j|�|��}n|j}d|_z|j|d�WntyxYn0�Yn0dS)Nr�r)rrr
rr�rr)r/r<rr r'r'r(r��s 
�z
Popen.waitc	Cst|dd�}t����}trX|dkr.|�|j�|dkrB|�|j�|dkr�|�|j�nr|dkr~|dkr~||kr~|�tj|�|dkr�|dkr�||kr�|�tj|�|dkr�|dkr�||kr�|�tj|�|dur�|�tj|�Wd�n1s�0Yd|_dS)Nr�r\T)	rz�
contextlib�	ExitStackr��callbackrJr�r�r�)	r/r�r�r�r�r�r�Z
devnull_fd�stackr'r'r(�_close_pipe_fds�s$
,zPopen._close_pipe_fdscCs~|dur|dur|durdSd\}}d\}}d\}}	|durtt�tj�}|dur�t�dd�\}}
t|�}t�|
�nh|tkr�t�dd�\}}t|�t|�}}n<|tkr�t�	|�
��}n$t|t�r�t�	|�}nt�	|�
��}|�|�}|du�r*t�tj�}|du�r�t�dd�\}
}t|�}t�|
�nn|tk�rXt�dd�\}}t|�t|�}}n@|tk�rrt�	|�
��}n&t|t��r�t�	|�}nt�	|�
��}|�|�}|du�r�t�tj�}	|	du�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)rOZGetStdHandlerZ
CreatePiperGrIrr
r�Z
get_osfhandlerr�rK�fileno�_make_inheritablerrr)r/r�r6r.r�r�r�r�r�r��_r'r'r(r��sp












�zPopen._get_handlescCs&t�t��|t��ddtj�}t|�S)Nrrt)rOZDuplicateHandleZGetCurrentProcessZDUPLICATE_SAME_ACCESSrG)r/�handle�hr'r'r(r, s
�zPopen._make_inheritablecCstdd�|D��S)NcSs,h|]$}|d@dks$t�|�tjkr|�qS)�)rOZGetFileTypeZFILE_TYPE_CHAR)�.0r.r'r'r(�	<setcomp>0s
��z,Popen._filter_handle_list.<locals>.<setcomp>)rF)r/rDr'r'r(�_filter_handle_list)szPopen._filter_handle_listc!Cs�t|t�rnNt|t�r.|
r"td��t|g�}n,t|tj�rR|
rFtd��t|g�}nt|�}|durlt�|�}|dur|t�}n|�	�}d|||fv}|r�|j
tjO_
||_
||_||_|j}t|o�d|vo�|d�}|s�|�r^|�r^|dur�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
�!||�}|du�rt�|�}t"�#d||||�z@t�$||ddt|�|	|||�	\}}}} W|�%|||
|||�n|�%|||
|||�0d|_&t'|�|_(||_)t�*|�dS)Nz$bytes args is not allowed on Windows�0path-like args is not allowed when shell is truer\rDz?startupinfo.lpAttributeList['handle_list'] overriding close_fdsFZComSpecZ
SystemRootr�ZSystem32zcmd.exez:shell not found: neither %ComSpec% nor %SystemRoot% is setz
{} /c "{}"�subprocess.PopenT)+r�r��bytesr�r�r��PathLiker�r#rEr>rOrr?r@rArCr�rFr�rKr3r�r�r�rrrB�environ�pathr��isabs�FileNotFoundErrorr�rW�auditZ
CreateProcessr)rrG�_handler�rI)!r/rdr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Zunused_restore_signalsZ
unused_gidZunused_gidsZ
unused_uidZunused_umaskZunused_start_new_sessionZuse_std_handlesZattribute_listZhave_handle_listrDZcomspecZsystem_rootZhpZhtr��tidr'r'r(r�6s�


��
�
�

���
zPopen._execute_childcCs,|jdur&||jd�|kr&||j�|_|jS�Nr)r+r=)r/rTZ_WaitForSingleObjectZ_WAIT_OBJECT_0Z_GetExitCodeProcessr'r'r(rV�s
zPopen._internal_pollcCs^|durtj}nt|d�}|jdurXt�|j|�}|tjkrJt|j|��t�	|j�|_|jS)Ni�)
rOZINFINITErKr+�WaitForSingleObjectr=ZWAIT_TIMEOUTrrd�GetExitCodeProcess)r/r<Ztimeout_millisr�r'r'r(r�s
�
zPopen._waitcCs|�|���|��dSr*)rcrr�)r/Zfh�bufferr'r'r(�
_readerthread�szPopen._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�|�
|�|jdur�|j�|�|��|j��r�t|j|��|j	dur�|j�|�|��|j��r�t|j|��d}d}|j�r|j}|j��|j	�r0|j
}|j	��|�r>|dnd}|�rP|dnd}||fS)N�_stdout_buff)�targetrdT�_stderr_buffr)r6r�rDr�ZThreadrCZ
stdout_threadZdaemon�startr.rFZ
stderr_threadr�rr�rZis_aliverrdr�)r/r�rr"r6r.r'r'r(r�sJ
��

��







zPopen._communicatecCsl|jdurdS|tjkr"|��nF|tjkr>t�|jtj�n*|tjkrZt�|jtj�nt	d�
|���dS)NzUnsupported signal: {})r+r1�SIGTERM�	terminateZCTRL_C_EVENTr�r�r�ZCTRL_BREAK_EVENTr2r��r/Zsigr'r'r(�send_signal
s




zPopen.send_signalcCsV|jdurdSzt�|jd�Wn0tyPt�|j�}|tjkrF�||_Yn0dSr�)r+rOZTerminateProcessr=�PermissionErrorrAZSTILL_ACTIVE)r/Zrcr'r'r(rIs

zPopen.terminatec
Cs,d\}}d\}}d\}}	|dur"n@|tkr8t��\}}n*|tkrJ|��}nt|t�rZ|}n|��}|durln@|tkr�t��\}}n*|tkr�|��}nt|t�r�|}n|��}|dur�nf|tkr�t��\}}	nP|tkr�|dkr�|}	n
t	j
��}	n.|tk�r|��}	nt|t��r|}	n|��}	||||||	fS)Nr*r\)rr��piper
rr�rKr+rrW�
__stdout__)
r/r�r6r.r�r�r�r�r�r�r'r'r(r�0sL





�cCs�|durtj}i}|rJg}dD]"}
tt|
d�}|dur|�|�q||d<g}|||	fD]}|dkrX|�tj|f�qX|df|df|
dffD]"\}}|dkr�|�tj||f�q�|r�||d<tj|||fi|��|_d|_	|�
|||||	|
�dS)	N)�SIGPIPEZSIGXFZ�SIGXFSZZ	setsigdefr\rrtr��file_actionsT)r�r8rzr1rc�POSIX_SPAWN_CLOSE�POSIX_SPAWN_DUP2r�r�rr))r/rdr�r�r�r�r�r�r�r�r�r�ZsigsetZsignameZsignumrQrZfd2r'r'r(�_posix_spawnfs8��zPopen._posix_spawnc-st|ttf�r|g}n(t|tj�r6|
r.td��|g}nt|�}|
rlttd�rPdnd}|dg|}�rl�|d<�dur||d�t�	d�|||�t
�rFtj����rF|du�rF|�sF|�sF|du�rF|dks�|d	k�rF|dks�|d	k�rF|dks�|d	k�rF|�sF|du�rF|du�rF|du�rF|dk�rF|�
|�|||||
|||�
dS�}t��\}}g}|d
k�r||�|�t�|�}�qZ|D]}t�|��q��zh�z|du�r�g}|��D]>\}}t�|�}d|v�r�td��|�|dt�|���q�nd}t����tj����r�f} nt�fd
d�t�|�D��} t|�}!|!�|�t�|| |tttt|!���|||||
||||||||||||�|_d|_Wt�|�nt�|�0|� |||
|||�t!�}"t�"|d�}#|"|#7}"|#�r�t#|"�dk�r��q�q�Wt�|�nt�|�0|"�rz6t�$|jd�\}$}%|$|jk�r<|�%|%�ntj&|_'Wnt(�yZYn0z|"�)dd	�\}&}'}(|(�*�}(Wn*t�y�d}&d}'d�+t|"��}(Yn0t,t-|&�*d�t.�})t/|)t0��r|'�rt|'d�}*|(dk}+|+�r�d}(|},n|},|*dk�rt�1|*�}(|)|*|(|,��|)|(��dS)Nr4Zgetandroidapilevelz/system/bin/shz/bin/shz-crr5r\r�r0�=z!illegal environment variable namec3s"|]}tj�t�|���VqdSr*)r�r9r��fsencode)r1�dir�r�r'r(�	<genexpr>�s�z'Popen._execute_child.<locals>.<genexpr>TiP��:sSubprocessError�0z#Bad exception data from child: {!r}�ascii�Znoexecr�)2r�r�r6r�r7r�rFr�rWr<�_USE_POSIX_SPAWNr9�dirnamerTrMrc�dupr�ryrVr2r��
get_exec_path�set�add�_posixsubprocessZ	fork_exec�sortedr�rKr�rr)�	bytearrayrr��waitpid�_handle_exitstatusrXr+�ChildProcessErrorr�rr�rz�builtinsr�
issubclassr��strerror)-r/rdr�r�r�r�r�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�kriZexecutable_listZfds_to_keepZerrpipe_data�partr�r!Zexception_nameZ	hex_errno�err_msgZchild_exception_typeZ	errno_numZchild_exec_never_calledZerr_filenamer'rXr(r��s��
�����������	�
���
��





�
�
�

��

�


cCs$||�r||�|_n
||�|_dSr*)r+)r/r!�waitstatus_to_exitcodeZ_WIFSTOPPEDZ	_WSTOPSIGr'r'r(rh1szPopen._handle_exitstatusc
Cs�|jdur�|j�d�sdSz�zF|jdur<|jWW|j��S||j|�\}}||jkr`|�|�WnDty�}z,|dur�||_n|j|kr�d|_WYd}~n
d}~00W|j��n|j��0|jS)NFr)r+r��acquire�releaser�rhr�r)r/rTZ_waitpidZ_WNOHANGZ_ECHILDr�r!�er'r'r(rV=s$	


�

cCs<zt�|j|�\}}Wnty2|j}d}Yn0||fSr?)r�rgr�ri)r/Z
wait_flagsr�r!r'r'r(�	_try_wait`s
zPopen._try_waitcCsP|jdur|jS|dur�t�|}d}|j�d�r�zX|jdurLW|j��q�|�tj�\}}||jkr~|�	|�W|j��q�W|j��n|j��0|�
|�}|dkr�t|j|��t
|d|d�}t�|�q&nv|jdu�rJ|j�P|jdu�rWd��qJ|�d�\}}||jk�r(|�	|�Wd�q�1�s>0Yq�|jS)Ng����Mb@?Frr�g�������?)r+rr�rqrrrtr��WNOHANGr�rhrrrdr�time�sleep)r/r<rZdelayr�r!Z	remainingr'r'r(rms>



�


�
,c
Cs2|jrT|jsTz|j��Wnty,Yn0|sTz|j��WntyRYn0d}d}|js�i|_|jrzg|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�r2|jj�s2|�|jt
j�|���r�|�|�}|du�rv|dk�rv|j||||dd�td��|�|�}	|�||||�|	D]�\}
}|
j|ju�r0||j|jt�}z|jt�|
j|�7_Wn*t�y|�|
j�|
j��Yn*0|jt|j	�k�r�|�|
j�|
j��nP|
j|j|jfv�r�t�|
jd�}
|
�sn|�|
j�|
j��|j|
j�|
��q��q2Wd�n1�s�0Y|j |�|�d�|du�r�d�!|�}|du�r�d�!|�}|j"�r*|du�r
|�#||jj$|jj%�}|du�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_fileobj2outputr6r.�_save_inputr��
memoryview�_PopenSelector�register�	selectorsZEVENT_WRITErHZ
EVENT_READZget_maprr$�RuntimeError�selectZfileobj�
_input_offset�	_PIPE_BUFr�rrZ
unregisterr�rrcr�r�r�rr�r�)r/r�rr"r6r.Z
input_viewZselectorr<Zready�keyZevents�chunkr�r'r'r(r�s�





��
�
:




�
�cCsF|jrB|jdurBd|_||_|durB|jrB|j�|jj|jj�|_dSr?)r�r�r�r��encoder�r�)r/r�r'r'r(ry�s�zPopen._save_inputcCs@|��|jdurdSzt�|j|�Wnty:Yn0dSr*)r�r+r�r�r��ProcessLookupErrorrJr'r'r(rKs
cCs|�tj�dSr*)rKr1rHr3r'r'r(rI(scCs|�tj�dSr*)rKr1�SIGKILLr3r'r'r(r�-sz
Popen.kill)r\NNNNNTFNNNNrTFr')NN)F)N)9r$r%r&rr0rNr�r�r�r�r:r�r;rr	rrWrXr�r�rPrrr�r�rr$r�r)r�r�r,r3r�rOr@Z
WAIT_OBJECT_0rArVrrCrrKrIr�rTr�rp�
WIFSTOPPED�WSTOPSIGrhrgrurZECHILDrtryr'r'r'r(r�s�6��j	



D	�

H	
�
26'&�
�
#
)f r)Krjrr�r�rvr1rWr�r�r%rrr�r��ImportErrorr��__all__r�rOr��ModuleNotFoundErrorrdrr}rrrrrrrrrrrrrrrr r!r"r�	Exceptionrrrr#rKrGrzr�r�rQr{ZSelectSelectorrUrRrrr
rer�rrr
�objectrrr�rr	r�r^rr'r'r'r(�<module>,s~

P

%	


;3%�EI
/