%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/utils.cpython-312.pyc

�

Ϫ�f�!��8�dZddlZddlZddlmZddlmZddlmZm	Z	ddl
mZ	dd�ZGd	�d
e
�ZGd�de	j�Zdidddfd
�ZGd�de	j�Zdiddfd�ZGd�de	j�Zdidddfd�Zd�Zd�Zd�Zgd�Zy)z
Utility methods.
�N��wraps)�BytesIO)�defer�protocol)�failure�c��|�ddlm}tj�}||g|���}|j	|||ft|�z||�|S)Nr)�reactor)�twisted.internetrr�Deferred�spawnProcess�tuple)	r�
executable�args�env�pathr�	protoArgs�d�ps	         �8/usr/lib/python3/dist-packages/twisted/internet/utils.py�_callProtocolWithDeferredrsM����,�
����A����Y��A�����J��
��d��(C�S�$�O��H�c��eZdZdZd�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�tj|d|���||_y)Nzgot stderr: )�IOError�__init__�processEnded)�self�textrs   rrz_UnexpectedErrorOutput.__init__*s!�������d�X�6�7�(��rN)�__name__�
__module__�__qualname__�__doc__rr	rrrrs���)rrc�0�eZdZdZdd�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   rrz_BackRelay.__init__Bs1�� ��
������#�5�5�D��#�4�4�D�rc��|j�tj�|_t	||j�}|jjt
j|��d|_|jj�yyr))
r*rr
�onProcessEndedr�errbackr�Failure�	transport�loseConnection)r r!�errs   rr.z_BackRelay.errReceivedIsBadJsd���=�=�$�"'�.�.�"2�D��(��t�/B�/B�C�C��M�M�!�!�'�/�/�#�"6�7� �D�M��N�N�)�)�+�%rc�:�|jj|�yr)�r+�write�r r!s  rr,z_BackRelay.errReceivedIsGoodR��������T�rc�:�|jj|�yr)r8r:s  r�outReceivedz_BackRelay.outReceivedUr;rc���|j�4|jj|jj��y|j�|jj|�yyr))r*�callbackr+�getvaluer1r2�r �reasons  rrz_BackRelay.processEndedXsN���=�=�$��M�M�"�"�4�6�6�?�?�#4�5�
�
 �
 �
,����'�'��/�-rN)r)	r"r#r$r%rr.r,r=rr	rrr'r'/s ���$5�,���0rr'c�*��t�fd�|||||�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���t|���S)N)r/)r')rr/s �r�<lambda>z"getProcessOutput.<locals>.<lambda>ys���*�Q��2�r)r)rrrrrr/s     `r�getProcessOutputrF_s ���2%�2�J��c�4�QX��rc��eZdZd�Zd�Zy)�_ValueGetterc��||_yr))r*)r r*s  rrz_ValueGetter.__init__~s	�� ��
rc�b�|jj|jj�yr))r*r?�value�exitCoderAs  rrz_ValueGetter.processEnded�s���
�
���v�|�|�4�4�5rN)r"r#r$rrr	rrrHrH}s��!�6rrHc�*�tt|||||�S)z7Spawn a process and return its exit code as a Deferred.)rrH)rrrrrs     r�getProcessValuerN�s��$�\�:�t�S�$�PW�X�Xrc� �eZdZdd�Zd�Zd�Zy)�_EverythingGetterNc���||_t�|_t�|_|jj|_|jj|_||_yr))r*r�outBuf�errBufr9r=r-�
stdinBytes)r r*rTs   rrz_EverythingGetter.__init__�sF�� ��
��i����i����;�;�,�,����;�;�,�,���$��rc��|j�A|jjd|j�|jj�yy)Nr)rTr4�writeToChild�
closeStdin)r s r�connectionMadez _EverythingGetter.connectionMade�s;���?�?�&��N�N�'�'��4�?�?�;�
�N�N�%�%�'�	'rc�B�|jj�}|jj�}|j}|j}|j
r)|jj|||j
f�y|jj|||f�yr))	rRr@rSrKrL�signalr*r2r?)r rB�outr6�e�codes      rrz_EverythingGetter.processEnded�su���k�k�"�"�$���k�k�"�"�$���L�L���z�z���8�8��M�M�!�!�3��Q�X�X�"6�7��M�M�"�"�C��d�#3�4rr))r"r#r$rrXrr	rrrPrP�s��%�(�5rrPc	�0�tt||||||f��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)
    )r)rrP)rrrrrrTs      r�getProcessOutputAndValuer_�s(��%��������-��rc�r�|D]"}	tjj|��$|S#t$rY�2wxYwr))�warnings�filters�remove�
ValueError)�passthrough�addedFilters�fs   r�_resetWarningFiltersrh�sF��
���	����#�#�A�&��
����	��	�s�*�	6�6c��|D]\}}tj|i|���tjdt|�}	||i|��}t	|t
j�r|jt|�|Std|�|S#t$r8tj�}td|�|dj|d��wxYw)a}
    Run the function I{f}, but with some warnings suppressed.

    This calls L{warnings.filterwarnings} to add warning filters before
    invoking I{f}. If I{f} returns a L{Deferred} then the added filters are
    removed once the deferred fires. Otherwise they are removed immediately.

    Note that the list of warning filters is a process-wide resource, so
    calling this function will affect all threads.

    @param suppressedWarnings:
        A list of arguments to pass to L{warnings.filterwarnings}, a sequence
        of (args, kwargs) 2-tuples.

    @param f: A callable, which may return a L{Deferred}.

    @param a: Positional arguments passed to I{f}

    @param kw: Keyword arguments passed to I{f}

    @return: The result of C{f(*a, **kw)}

    @seealso: L{twisted.python.util.runWithWarningsSuppressed}
        functions similarly, but doesn't handled L{Deferred}s.
    N��)
ra�filterwarningsrb�len�
isinstancerr
�addBothrh�
BaseException�sys�exc_info�with_traceback)	�suppressedWarningsrg�a�kwr�kwargsrf�resultrrs	         r�runWithWarningsSuppressedry�s���4+�1���f�����0��0�1��#�#�$=�c�*<�&=�>�L���A������f�e�n�n�-��N�N�/��>��
�
!��|�4��
���6��<�<�>���T�<�0��q�k�(�(��!��5�5�6�s�B�ACc�2���t����fd��}|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.
    c�$��t��g|��i|��Sr))ry)rurvrgrts  ��r�warningSuppressingWrapperz3suppressWarnings.<locals>.warningSuppressingWrapper�s���(�);�Q�I��I�b�I�Irr)rgrtr|s`` r�suppressWarningsr}�s%����1�X�J��J�%�$r)ryr}rFrNr_)Nr	)r%rqra�	functoolsr�iorrrr�twisted.pythonrrrr�ProcessProtocolr'rFrHrNrPr_rhryr}�__all__r	rr�<module>r�s���
�
����,�"�DF�	
�
)�W�
)� -0��)�)�-0�`')�b�t�T�TU��<6�8�+�+�6�&(�R�d�D�Y�
5��0�0�5�8�R�d�D�T��&�(�V%��r

Zerion Mini Shell 1.0