+
    Dfj!                     @   R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHtH	t	 ^ RI
Ht RR lt ! R R]4      t ! R	 R
]	P                  4      tR/ RR^ 3R lt ! R R]	P                  4      tR/ RR3R lt ! R R]	P                  4      tR/ RRR3R ltR tR tR t. ROtR# )z
Utility methods.
Nwraps)BytesIO)deferprotocol)failurec                     Vf   ^ RI Hp \        P                  ! 4       pV ! V.VO5!  pVP	                  WV3\        V4      ,           W44       V# )N)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      sI     ,AYAd(CSOH    c                   *   a  ] tR t^t o RtR tRtV tR# )_UnexpectedErrorOutputa]  
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                F    \         P                  V R V: 24       W n        R# )zgot stderr: N)IOError__init__processEnded)selftextr   s   &&&r   r   _UnexpectedErrorOutput.__init__*   s    dX67(r   )r   N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     ) )r   r   c                   F   a  ] tR t^/t o RtR	R ltR tR tR tR t	Rt
V tR# )

_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                    Wn         \        4       V n        V'       d   V P                  V n        R # V P
                  V n        R # N)deferredr   serrReceivedIsGooderrReceivederrReceivedIsBad)r   r.   errortoos   &&&r   r   _BackRelay.__init__B   s/     #55D#44Dr   c                $   V P                   e   \        P                  ! 4       V n        \	        WP                  4      pV P                   P                  \        P                  ! V4      4       R V n         V P                  P                  4        R # R # r-   )
r.   r   r   onProcessEndedr   errbackr   Failure	transportloseConnection)r   r   errs   && r   r2   _BackRelay.errReceivedIsBadJ   sb    ==$"'.."2D(/B/BCCMM!!'//#"67 DMNN))+ %r   c                <    V P                   P                  V4       R # r-   r/   writer   r   s   &&r   r0   _BackRelay.errReceivedIsGoodR       Tr   c                <    V P                   P                  V4       R # r-   r>   r@   s   &&r   outReceived_BackRelay.outReceivedU   rB   r   c                    V P                   e6   V P                   P                  V P                  P                  4       4       R # V P                  e   V P                  P                  V4       R # R # r-   )r.   callbackr/   getvaluer6   r7   r   reasons   &&r   r   _BackRelay.processEndedX   sN    ==$MM""466??#45  ,''/ -r   )r.   r1   r6   r/   N)    )r!   r"   r#   r$   r%   r   r2   r0   rD   r   r&   r'   r(   s   @r   r+   r+   /   s(     $5,0 0r   r+   c                (   a \        V3R lWW#V4      # )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                    < \        V SR 7      # ))r3   )r+   )r   r3   s   &r   <lambda>"getProcessOutput.<locals>.<lambda>y   s    *Q2r   )r   )r   r   r   r   r	   r3   s   &&&&&fr   getProcessOutputrQ   _   s    2 %2JcQX r   c                   ,   a  ] tR t^}t o R tR tRtV tR# )_ValueGetterc                    Wn         R # r-   r.   )r   r.   s   &&r   r   _ValueGetter.__init__~   s     r   c                d    V P                   P                  VP                  P                  4       R # r-   )r.   rG   valueexitCoderI   s   &&r   r   _ValueGetter.processEnded   s    v||445r   rU   N)r!   r"   r#   r$   r   r   r&   r'   r(   s   @r   rS   rS   }   s     !6 6r   rS   c                &    \        \        WW#V4      # )z7Spawn a process and return its exit code as a Deferred.)r   rS   )r   r   r   r   r	   s   &&&&&r   getProcessValuer\      s    $\:SPWXXr   c                   6   a  ] tR t^t o RR ltR tR tRtV tR# )_EverythingGetterNc                    Wn         \        4       V n        \        4       V n        V P                  P                  V n        V P                  P                  V n        W n        R # r-   )r.   r   outBuferrBufr?   rD   r1   
stdinBytes)r   r.   rb   s   &&&r   r   _EverythingGetter.__init__   sB     ii;;,,;;,,$r   c                    V P                   eC   V P                  P                  ^ V P                   4       V P                  P                  4        R # R # r-   )rb   r9   writeToChild
closeStdin)r   s   &r   connectionMade _EverythingGetter.connectionMade   s;    ??&NN''4??; NN%%'	 'r   c                N   V P                   P                  4       pV P                  P                  4       pVP                  pVP                  pVP
                  '       d*   V P                  P                  W#VP
                  34       R # V P                  P                  W#V34       R # r-   )	r`   rH   ra   rX   rY   signalr.   r7   rG   )r   rJ   outr;   ecodes   &&    r   r   _EverythingGetter.processEnded   ss    kk""$kk""$LLzz888MM!!3QXX"67MM""Cd#34r   )r.   ra   r1   r`   rD   rb   r-   )	r!   r"   r#   r$   r   rg   r   r&   r'   r(   s   @r   r^   r^      s     %(5 5r   r^   c           
     0    \        \        V VVVVV3R7      # )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   )r   r^   )r   r   r   r   r	   rb   s   &&&&&&r   getProcessOutputAndValuerp      s(     %- r   c                 |    V F#  p \         P                  P                  V4       K%  	  V #   \         d     K7  i ; ir-   )warningsfiltersremove
ValueError)passthroughaddedFiltersfs   && r   _resetWarningFiltersry      sA    	##A& 
   		s   ,;;c                   V  F  w  rE\         P                  ! V/ VB  K  	  \         P                  R\        V 4       p V! V/ VB p\	        V\
        P                  4      '       d   VP                  \        V4       V# \        RV4       V#   \         dB    \        P                  ! 4       p\        RT4       T^,          P                  T^,          4      hi ; i)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)rr   filterwarningsrs   len
isinstancer   r   addBothry   BaseExceptionsysexc_infowith_traceback)	suppressedWarningsrx   akwr   kwargsrw   resultr   s	   &&*,     r   runWithWarningsSuppressedr      s    4 +00 +##$=c*<&=>LA fenn--NN/>  !|4  6<<>T<0qk((!556s   B ACc                4   a a \        S 4      V V3R l4       pV# )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                  $   < \        SS.V O5/ VB # r-   )r   )r   r   rx   r   s   *,r   warningSuppressingWrapper3suppressWarnings.<locals>.warningSuppressingWrapper   s    ();QIIbIIr   r   )rx   r   r   s   fj r   suppressWarningsr      s%     1XJ J %$r    )Nr   )r   r   rQ   r\   rp   )r%   r   rr   	functoolsr   ior   r
   r   r   twisted.pythonr   r   r   r   ProcessProtocolr+   rQ   rS   r\   r^   rp   ry   r   r   __all__r   r   r   <module>r      s   

     , "	)W ) -0)) -0` ')btTTU <68++ 6 &(RdD Y
500 58 RdDT&(V%r   