/usr/lib/python3/dist-packages/twisted/internet/__pycache__
Edit: /usr/lib/python3/dist-packages/twisted/internet/__pycache__/utils.cpython-310.pyc (9327B)
o
b! @ s d Z ddlZddlZddlmZ ddlmZ ddlmZm Z ddl
mZ ddd ZG d
d de
ZG dd
d
e jZdi dddfddZG dd de jZdi ddfddZG dd de jZdi dddfddZdd Zdd Zdd Zg dZdS ) z
Utility methods.
Nwraps)BytesIO)deferprotocol)failure c C sL |d u r
ddl m} t }| |g|R }||||ft| || |S )Nr )reactor)twisted.internetr r DeferredspawnProcesstuple) r
executableargsenvpathr protoArgsdpr 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)selftextr 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 ZdZdddZdd 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| _d S | j| _d S N)deferredr serrReceivedIsGooderrReceivederrReceivedIsBad)r r# errortoor r r r B s
z_BackRelay.__init__c C sJ | j d ur#t | _t|| j}| j t| d | _ | j d S d S r" )
r# r r onProcessEndedr errbackr Failure transportloseConnection)r r errr r r r' J s
z_BackRelay.errReceivedIsBadc C | j | d S r" r$ writer r r r r r% R z_BackRelay.errReceivedIsGoodc C r/ r" r0 r2 r r r outReceivedU r3 z_BackRelay.outReceivedc C s> | j d ur| j | j d S | jd ur| j| d S d S r" )r# callbackr$ getvaluer) r* r reasonr r r r X s
z_BackRelay.processEndedN)r ) r r r r r r' r% r4 r r r r r r! / s
r! c s t fdd| ||||S )a
Spawn a process and return its output as a deferred returning a L{bytes}.
@param executable: The file name to run and get the output of - the
full path should be used.
@param args: the command line arguments to pass to the process; a
sequence of strings. The first string should B{NOT} be the
executable's name.
@param env: the environment variables to pass to the process; a
dictionary of strings.
@param path: the path to run the subprocess in - defaults to the
current directory.
@param reactor: the reactor to use - defaults to the default reactor
@param errortoo: If true, include stderr in the result. If false, if
stderr is received the returned L{Deferred} will errback with an
L{IOError} instance with a C{processEnded} attribute. The
C{processEnded} attribute refers to a L{Deferred} which fires when the
executed process ends.
c s t | dS )Nr( )r! )r r9 r r
y s z"getProcessOutput..)r )r r r r r r( r r9 r getProcessOutput_ s r; c @ s e Zd Zdd Zdd ZdS )_ValueGetterc C s
|| _ d S r" )r# )r r# r r r r ~ s
z_ValueGetter.__init__c C s | j |jj d S r" )r# r5 valueexitCoder7 r r r r s z_ValueGetter.processEndedN)r r r r r r r r r r<