Your IP : 18.117.254.177


Current Path : /opt/alt/python34/lib64/python3.4/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/asyncio/__pycache__/subprocess.cpython-34.pyc

�
j f�
@s ddgZddlZddlmZddlmZddlmZddlmZdd	lmZdd
l	m
Z
ejZejZej
Z
Gdd�dejej�ZGd
d�d�Zeddddejdd��Zedddddddddejdd��ZdS)�create_subprocess_exec�create_subprocess_shell�N�)�events)�	protocols)�streams)�tasks)�	coroutine)�loggercsdeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	�S)�SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.cs@t�jd|�||_d|_|_|_d|_dS)N�loop)�super�__init__�_limit�stdin�stdout�stderr�
_transport)�self�limitr)�	__class__��7/opt/alt/python34/lib64/python3.4/asyncio/subprocess.pyrs	z!SubprocessStreamProtocol.__init__cCs�|jjg}|jdk	r5|jd|j�n|jdk	r[|jd|j�n|jdk	r�|jd|j�nddj|�S)Nzstdin=%rz	stdout=%rz	stderr=%rz<%s>� )r�__name__r�appendrr�join)r�inforrr�__repr__sz!SubprocessStreamProtocol.__repr__cCs�||_|jd�}|dk	rXtjd|jd|j�|_|jj|�n|jd�}|dk	r�tjd|jd|j�|_|jj|�n|jd�}|dk	r�tj	|d|ddd|j�|_
ndS)Nrrr�r�protocol�reader)r�get_pipe_transportr�StreamReaderr�_looprZ
set_transportr�StreamWriterr)r�	transportZstdout_transportZstderr_transportZstdin_transportrrr�connection_made&s"	z(SubprocessStreamProtocol.connection_madecCsV|dkr|j}n|dkr0|j}nd}|dk	rR|j|�ndS)Nrr)rrZ	feed_data)r�fd�datar!rrr�pipe_data_received<sz+SubprocessStreamProtocol.pipe_data_receivedcCs�|dkr?|j}|dk	r.|j�n|j|�dS|dkrW|j}n|dkro|j}nd}|dkr�|dkr�|j�q�|j|�ndS)Nrrr)r�closeZconnection_lostrrZfeed_eofZ
set_exception)rr(�exc�piper!rrr�pipe_connection_lostFs	


z-SubprocessStreamProtocol.pipe_connection_lostcCs|jj�d|_dS)N)rr+)rrrr�process_exitedYs
z'SubprocessStreamProtocol.process_exited)
r�
__module__�__qualname__�__doc__rrr'r*r.r/rr)rrrs

rc@s�eZdZdd�Zdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zedd��Zedd��Z
edd��Zeddd��ZdS)�ProcesscCsR||_||_||_|j|_|j|_|j|_|j�|_dS)N)rZ	_protocolr$rrrZget_pid�pid)rr&r rrrrr_s			zProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr4)rrrrrhszProcess.__repr__cCs
|jj�S)N)rZget_returncode)rrrr�
returncodekszProcess.returncodeccs|jj�DdHS)zdWait until the process exit and return the process return code.

        This method is a coroutine.N)rZ_wait)rrrr�waitoszProcess.waitcCs|jj|�dS)N)r�send_signal)r�signalrrrr7vszProcess.send_signalcCs|jj�dS)N)r�	terminate)rrrrr9yszProcess.terminatecCs|jj�dS)N)r�kill)rrrrr:|szProcess.killccs�|jj�}|jj|�|rAtjd|t|��ny|jj�DdHWnGtt	fk
r�}z!|r�tjd||�nWYdd}~XnX|r�tjd|�n|jj
�dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r$�	get_debugr�writer
�debug�lenZdrain�BrokenPipeError�ConnectionResetErrorr+)r�inputr=r,rrr�_feed_stdins	)zProcess._feed_stdincCsdS)Nr)rrrr�_noop�sz
Process._noopccs�|jj|�}|dkr*|j}n|dks<t�|j}|jj�r�|dkrfdnd}tjd||�n|j	�DdH}|jj�r�|dkr�dnd}tjd||�n|j
�|S)Nrrrrz%r communicate: read %sz%r communicate: close %s)rr"r�AssertionErrorrr$r;r
r=�readr+)rr(r&�stream�name�outputrrr�_read_stream�s	
zProcess._read_streamNccs�|r|j|�}n|j�}|jdk	rE|jd�}n|j�}|jdk	rr|jd�}n|j�}tj|||d|j�DdH\}}}|j�DdH||fS)Nrrr)	rBrCrrIrrZgatherr$r6)rrArrrrrr�communicate�szProcess.communicate)rr0r1rr�propertyr5r	r6r7r9r:rBrCrIrJrrrrr3^s	r3c

+sr�dkrtj��n��fdd�}�j||d|d|d||�DdH\}}	t||	��S)Ncstd�d��S)Nrr)rr)rrrr�<lambda>�sz)create_subprocess_shell.<locals>.<lambda>rrr)r�get_event_loopZsubprocess_shellr3)
�cmdrrrrr�kwds�protocol_factoryr&r r)rrrr�srrrrrc/su�dkrtj��n��fdd�}�j||d|d|d|||�DdH\}	}
t|	|
��S)Ncstd�d��S)Nrr)rr)rrrrrL�sz(create_subprocess_exec.<locals>.<lambda>rrr)rrMZsubprocess_execr3)Zprogramrrrrr�argsrOrPr&r r)rrrr�s)�__all__�
subprocess�rrrrZ
coroutinesr	�logr
�PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolrr3Z_DEFAULT_LIMITrrrrrr�<module>s(			K]	

?>