�
Ϫ�f�! � �8 � d Z ddlZddlZddlmZ ddlmZ ddlmZm Z ddl
mZ dd�Z G d � d
e
� Z G d� de j � Zdi dddfd
�Z G d� de j � Zdi ddfd�Z G d� de j � Zdi dddfd�Zd� Zd� Zd� Zg d�Zy)z
Utility methods.
� N��wraps)�BytesIO)�defer�protocol)�failure� c � � |�ddl m} t j � } | |g|��� }|j |||ft |� z ||� |S )Nr )�reactor)�twisted.internetr r �Deferred�spawnProcess�tuple) r �
executable�args�env�pathr � protoArgs�d�ps �8/usr/lib/python3/dist-packages/twisted/internet/utils.py�_callProtocolWithDeferredr sM � � ��,�
����A����Y��A�����J��
��d��(C�S�$�O��H� c � � e Zd ZdZd� Zy)�_UnexpectedErrorOutputay
Standard error data was received where it was not expected. This is a
subclass of L{IOError} to preserve backward compatibility with the previous
error behavior of L{getProcessOutput}.
@ivar processEnded: A L{Deferred} which will fire when the process which
produced the data on stderr has ended (exited and all file descriptors
closed).
c �D � t j | d|��� || _ y )Nzgot stderr: )�IOError�__init__�processEnded)�self�textr s r r z_UnexpectedErrorOutput.__init__* s! � ������d�X�6�7�(��r N)�__name__�
__module__�__qualname__�__doc__r r r r r r s � ��)r r c �0 � e Zd ZdZdd�Zd� Zd� Zd� Zd� Zy) �
_BackRelaya�
Trivial protocol for communicating with a process and turning its output
into the result of a L{Deferred}.
@ivar deferred: A L{Deferred} which will be called back with all of stdout
and, if C{errortoo} is true, all of stderr as well (mixed together in
one string). If C{errortoo} is false and any bytes are received over
stderr, this will fire with an L{_UnexpectedErrorOutput} instance and
the attribute will be set to L{None}.
@ivar onProcessEnded: If C{errortoo} is false and bytes are received over
stderr, this attribute will refer to a L{Deferred} which will be called
back when the process ends. This C{Deferred} is also associated with
the L{_UnexpectedErrorOutput} which C{deferred} fires with earlier in
this case so that users can determine when the process has actually
ended, in addition to knowing when bytes have been received via stderr.
c �z � || _ t � | _ |r| j | _ y | j
| _ y �N)�deferredr �s�errReceivedIsGood�errReceived�errReceivedIsBad)r r* �errortoos r r z_BackRelay.__init__B s1 � � ��
������#�5�5�D��#�4�4�D�r c � � | j �t j � | _ t || j � }| j j t
j |� � d | _ | j j � y y r) )
r* r r
�onProcessEndedr �errbackr �Failure� transport�loseConnection)r r! �errs r r. z_BackRelay.errReceivedIsBadJ sd � ��=�=�$�"'�.�.�"2�D��(��t�/B�/B�C�C��M�M�!�!�'�/�/�#�"6�7� �D�M��N�N�)�)�+� %r c �: � | j j |� y r) �r+ �write�r r! s r r, z_BackRelay.errReceivedIsGoodR � � ������T�r c �: � | j j |� y r) r8 r: s r �outReceivedz_BackRelay.outReceivedU r; r c �� � | j �4| j j | j j � � y | j �| j j |� y y r) )r* �callbackr+ �getvaluer1 r2 �r �reasons r r z_BackRelay.processEndedX sN � ��=�=�$��M�M�"�"�4�6�6�?�?�#4�5�
�
�
�
,����'�'��/� -r N)r ) r" |