CasperSecurity

Current Path : /lib/python3/dist-packages/landscape/lib/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/twisted_util.cpython-310.pyc

o

���c|�	@s�ddlZddlmZmZddlmZddlmZmZddl	m
Z
ddlmZddl
mZmZddlmZGd	d
�d
e�Zddd
�ZGdd�de�Zdidddddddf	dd�ZdS)�N)�DeferredList�Deferred)�ProcessProtocol)�Process�
ProcessReader)�reactor)�Failure)�
itervalues�
networkString)�
encode_valuesc@seZdZdZdS)�SignalErrorz3An error if the process was terminated by a signal.N)�__name__�
__module__�__qualname__�__doc__�rr�</usr/lib/python3/dist-packages/landscape/lib/twisted_util.pyr
srFcCs.t|d|d�}|�dd��|�dd��|S)N�)�fireOnOneErrback�
consumeErrorscSsdd�|D�S)NcSsg|]}|d�qS)rr)�.0�xrrr�
<listcomp>sz4gather_results.<locals>.<lambda>.<locals>.<listcomp>r)�rrrr�<lambda>sz gather_results.<locals>.<lambda>cSs|jjS�N)�value�
subFailure)�frrrrs)r�addCallback�
addErrback)�	deferreds�consume_errors�drrr�gather_resultss�r$c@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)�AllOutputProcessProtocolz<A process protocol for getting stdout, stderr and exit code.NcCs:||_t��|_t��|_|jj|_||_||_d|_	dS�N�)
�deferred�io�BytesIO�outBuf�errBuf�write�errReceived�stdin�
line_received�
_partial_line)�selfr(r/r0rrr�__init__s



z!AllOutputProcessProtocol.__init__cCs.|jdur|j�t|j��|j��dSdSr)r/�	transportr-r
�
closeStdin)r2rrr�connectionMade%s
�z'AllOutputProcessProtocol.connectionMadecCsX|j�|�|jdur
dS|�d�}|j|d|d<|��|_|D]}|�|�q"dS)N�
r)r+r-r0�splitr1�pop)r2�data�lines�linerrr�outReceived*s


�z$AllOutputProcessProtocol.outReceivedcCsv|jr|�|j�d|_|j��}|j��}|j}|j}|jr0tt	|||j��}|j
�|�dS|j
�|||f�dSr&)
r1r0r+�getvaluer,r�exitCode�signalrrr(�errback�callback)r2�reason�out�err�e�code�failurerrr�processEnded:s

z%AllOutputProcessProtocol.processEnded)NN)r
rrrr3r6r=rIrrrrr%s
	r%rTc

s`|g}
|
�|�t�}t||	|d�}t|�}tj|||
|||||d��|s.�fdd�}
|
�_|S)a�
    Spawn a process using Twisted reactor.

    Return a deferred which will be called with process stdout, stderr and exit
    code.

    @param wait_pipes: if set to False, don't wait for stdin/stdout pipes to
        close when process ends.
    @param line_received: an optional callback called with every line of
        output from the process as parameter.

    @note: compared to reactor.spawnProcess, this version does NOT require the
    executable name as first element of args.
    )r/r0)�args�env�path�uid�gid�usePTYcsJ�jr�jst�j�D]}t|t�r|��|��qi�_t���dS)a�A less strict version of Process.maybeCallProcessEnded.

            This behaves exactly like the original method, but in case the
            process has ended already and sent us a SIGCHLD, it doesn't wait
            for the stdin/stdout pipes to close, because the child process
            itself might have passed them to its own child processes.

            @note: Twisted 8.2 now has a processExited hook that could
                be used in place of this workaround.
            N)	�pipes�pidr	�
isinstancer�doRead�stopReadingr�maybeCallProcessEnded)�pipe��processrrrUhs

z,spawn_process.<locals>.maybeCallProcessEnded)�extendrr%rr�spawnProcessrU)�
executablerJrKrLrMrNrO�
wait_pipesr0r/�	list_args�result�protocolrUrrWr�
spawn_processIs
�
�r`)F)r)�twisted.internet.deferrr�twisted.internet.protocolr�twisted.internet.processrr�twisted.internetr�twisted.python.failurer�twisted.python.compatr	r
�landscape.lib.encodingr�	Exceptionrr$r%r`rrrr�<module>s

0�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY