File: //lib/python3/dist-packages/twisted/internet/__pycache__/utils.cpython-38.pyc
U
�b�! � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZm Z ddl
mZ ddd �ZG d
d� de
�ZG dd
� d
e j�Zdi dddfdd�ZG dd� de j�Zdi ddfdd�ZG dd� de j�Zdi dddfdd�Zdd� Zdd� Zdd� ZdddddgZdS )z
Utility methods.
� N��wraps)�BytesIO)�defer�protocol)�failure� c C sJ |d krddl m} t�� }| |f|�� }|�|||ft|� ||� |S )Nr )�reactor)�twisted.internetr r �Deferred�spawnProcess�tuple) r �
executable�args�env�pathr � protoArgs�d�pr r �8/usr/lib/python3/dist-packages/twisted/internet/utils.py�_callProtocolWithDeferred s r c @ s e Zd ZdZdd� ZdS )�_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 C s t �| d|��� || _d S )Nzgot stderr: )�IOError�__init__�processEnded)�self�textr r r r r * s z_UnexpectedErrorOutput.__init__N)�__name__�
__module__�__qualname__�__doc__r r r r r r s
r c @ s: e Zd ZdZddd�Zdd� Zdd� Zd d
� Zdd� Zd
S )�
_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.
r c C s( || _ t� | _|r| j| _n| j| _d S �N)�deferredr �s�errReceivedIsGood�errReceived�errReceivedIsBad)r r# �errortoor r r r B s
z_BackRelay.__init__c C sF | j d k rBt�� | _t|| j�}| j �t�|�� d | _ | j� � d S r"