HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/internet/__pycache__/utils.cpython-38.pyc
U

��W[��@sdZddlmZmZddlZddlZddlmZddlm	Z	m
Z
ddlmZddl
mZddlmZd d	d
�ZGdd�de�ZGd
d�de	j�Zdidddfdd�ZGdd�de	j�Zdiddfdd�ZGdd�de	j�Zdiddfdd�Zdd�Zdd�Zdd�ZdddddgZdS)!z
Utility methods.
�)�division�absolute_importN��wraps)�protocol�defer)�failure)�reraise)�BytesIOcCsD|dkrddlm}t��}||�}|�|||ft|�||�|S)Nr)�reactor)�twisted.internetrr�DeferredZspawnProcess�tuple)r�
executable�args�env�pathr�d�p�r�8/usr/lib/python3/dist-packages/twisted/internet/utils.py�_callProtocolWithDeferredsrc@seZdZdZdd�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).
    cCst�|d|f�||_dS)Nzgot stderr: %r)�IOError�__init__�processEnded)�self�textrrrrr,sz_UnexpectedErrorOutput.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrr!s
rc@s:eZdZdZddd�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.
    rcCs(||_t�|_|r|j|_n|j|_dS�N)�deferredr
�s�errReceivedIsGood�errReceived�errReceivedIsBad)rr$�errortoorrrrEs

z_BackRelay.__init__cCsF|jdk	rBt��|_t||j�}|j�t�|��d|_|j�	�dSr#)
r$rr
�onProcessEndedr�errbackrZFailureZ	transportZloseConnection)rr�errrrrr(Ms

z_BackRelay.errReceivedIsBadcCs|j�|�dSr#�r%�write�rrrrrr&Usz_BackRelay.errReceivedIsGoodcCs|j�|�dSr#r-r/rrr�outReceivedXsz_BackRelay.outReceivedcCs8|jdk	r|j�|j���n|jdk	r4|j�|�dSr#)r$�callbackr%�getvaluer*r+�r�reasonrrrr

z_BackRelay.processEndedN)r)	rrr r!rr(r&r0rrrrrr"2s
r"rcst�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.
    cst|�d�S)N�r))r")rr5rr�<lambda>}sz"getProcessOutput.<locals>.<lambda>)r)rrrrrr)rr5r�getProcessOutputcs�r7c@seZdZdd�Zdd�ZdS)�_ValueGettercCs
||_dSr#)r$�rr$rrrr�sz_ValueGetter.__init__cCs|j�|jj�dSr#)r$r1�value�exitCoder3rrrr�sz_ValueGetter.processEndedN�rrr rrrrrrr8�sr8cCstt|||||�S)z7Spawn a process and return its exit code as a Deferred.)rr8�rrrrrrrr�getProcessValue�s�r>c@seZdZdd�Zdd�ZdS)�_EverythingGettercCs.||_t�|_t�|_|jj|_|jj|_dSr#)r$r
�outBuf�errBufr.r0r'r9rrrr�s

z_EverythingGetter.__init__cCsR|j��}|j��}|j}|j}|jr<|j�|||jf�n|j�|||f�dSr#)	r@r2rAr:r;�signalr$r+r1)rr4�outr,�e�coderrrr�s

z_EverythingGetter.processEndedNr<rrrrr?�sr?cCstt|||||�S)a.Spawn a process and returns a Deferred that will be called back with
    its output (from stdout and stderr) and it's exit code as (out, err, code)
    If a signal is raised, the Deferred will errback with the stdout and
    stderr up to that point, along with the signal, as (out, err, signalNum)
    )rr?r=rrr�getProcessOutputAndValue�s�rFc	Cs4|D]*}ztj�|�Wqtk
r,YqXq|Sr#)�warnings�filters�remove�
ValueError)Zpassthrough�addedFilters�frrr�_resetWarningFilters�srMc	Os�|D]\}}tj||�qtjdt|��}z|||�}Wn0t��}td|�t|d|d�Yn*Xt|t	j
�r�|�t|�n
td|�|SdS)a%Run the function C{f}, but with some warnings suppressed.

    @param suppressedWarnings: A list of arguments to pass to filterwarnings.
                               Must be a sequence of 2-tuples (args, kwargs).
    @param f: A callable, followed by its arguments and keyword arguments
    N��)rG�filterwarningsrH�len�sys�exc_inforMr	�
isinstancerr
ZaddBoth)	�suppressedWarningsrL�a�kwr�kwargsrK�resultrSrrr�runWithWarningsSuppressed�s

rZcst����fdd��}|S)z�
    Wrap C{f} in a callable which suppresses the indicated warnings before
    invoking C{f} and unsuppresses them afterwards.  If f returns a Deferred,
    warnings will remain suppressed until the Deferred fires.
    cst��f|�|�Sr#)rZ)rVrW�rLrUrr�warningSuppressingWrapper�sz3suppressWarnings.<locals>.warningSuppressingWrapperr)rLrUr\rr[r�suppressWarnings�sr])N)r!Z
__future__rrrRrG�	functoolsrrrrZtwisted.pythonrZtwisted.python.compatr	�ior
rrrZProcessProtocolr"r7r8r>r?rFrMrZr]�__all__rrrr�<module>s8
1�
 	�
	
�