AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/test/__pycache__/test_iutils.cpython-310.pyc
o

�b@5�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZddl
mZddlmZddlmZddlmZmZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZdS)zD
Test running processes with the APIs in L{twisted.internet.utils}.
�N)�skipIf)�error�
interfaces�reactor�utils)�Deferred)�platform)�SuppressedWarningsTests)�SynchronousTestCase�TestCasec@s�eZdZdZe�ed�durdZdZdZ	e
jZdd�Z
dd�Zdd	�Zd
d�Zdd
�Zdd�Zee��d�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)%�ProcessUtilsTestszt
    Test running a process using L{getProcessOutput}, L{getProcessValue}, and
    L{getProcessOutputAndValue}.
    Nz)reactor doesn't implement IReactorProcesscCsV|��}t|d��}|�tj�|�tj�Wd�n1s wYtj�|�S)zj
        Write the given list of lines to a text file and return the absolute
        path to it.
        �wtN)�mktemp�open�write�os�linesep�join�path�abspath)�self�sourceLines�script�
scriptFile�r�:/usr/lib/python3/dist-packages/twisted/test/test_iutils.py�makeSourceFile$s
�z ProcessUtilsTests.makeSourceFilecCs.|�gd��}t�|jd|g�}|�|jd�S)z�
        L{getProcessOutput} returns a L{Deferred} which fires with the complete
        output of the process it runs after that process exits.
        )�
import syszfor s in b'hello world\n':z    s = bytes([s])z    sys.stdout.buffer.write(s)z    sys.stdout.flush()�-ushello world
�rr�getProcessOutput�exe�addCallback�assertEqual�rr�drrr�test_output.s
�	zProcessUtilsTests.test_outputcsF��ddg�}t��jd|g�}��|t�}�fdd�}|�|�|S)z�
        The L{Deferred} returned by L{getProcessOutput} is fired with an
        L{IOError} L{Failure} if the child process writes to stderr.
        rz!sys.stderr.write("hello world\n")rcs��|jtj�S�N)�
assertFailure�processEndedr�ProcessDone)�err�rrr�cbFailedL�z?ProcessUtilsTests.test_outputWithErrorIgnored.<locals>.cbFailed)rrr r!r(�IOErrorr")rrr%r-rr,r�test_outputWithErrorIgnored?s�
z-ProcessUtilsTests.test_outputWithErrorIgnoredcCs2|�gd��}tj|jd|gdd�}|�|jd�S)z�
        If a C{True} value is supplied for the C{errortoo} parameter to
        L{getProcessOutput}, the returned L{Deferred} fires with the child's
        stderr output as well as its stdout output.
        )rzsys.stdout.write("foo")�sys.stdout.flush()zsys.stderr.write("foo")�sys.stderr.flush()rT)�errortoosfoofoorr$rrr�test_outputWithErrorCollectedRs
�z/ProcessUtilsTests.test_outputWithErrorCollectedcCs,|�dg�}t�|jd|g�}|�|jd�S)z|
        The L{Deferred} returned by L{getProcessValue} is fired with the exit
        status of the child process.
        zraise SystemExit(1)r�)rr�getProcessValuer!r"r#r$rrr�
test_valuegszProcessUtilsTests.test_valuecs6��gd��}�fdd�}t��jd|g�}|�|�S)a
        The L{Deferred} returned by L{getProcessOutputAndValue} fires with a
        three-tuple, the elements of which give the data written to the child's
        stdout, the data written to the child's stderr, and the exit status of
        the child.
        )rz*sys.stdout.buffer.write(b'hello world!\n')z,sys.stderr.buffer.write(b'goodbye world!\n')zsys.exit(1)cs2|\}}}��|d���|d���|d�dS)Ns
hello world!
sgoodbye world!
r5�r#��out_err_code�outr+�coder,rr�gotOutputAndValue�s
z@ProcessUtilsTests.test_outputAndValue.<locals>.gotOutputAndValuer�rr�getProcessOutputAndValuer!r"�rrr=r%rr,r�test_outputAndValueqs�	
z%ProcessUtilsTests.test_outputAndValuez"Windows doesn't have real signals.csB��gd��}�fdd�}t��jd|g�}��|t�}|�|�S)z�
        If the child process exits because of a signal, the L{Deferred}
        returned by L{getProcessOutputAndValue} fires a L{Failure} of a tuple
        containing the child's stdout, stderr, and the signal which caused
        it to exit.
        )zimport sys, os, signalz"sys.stdout.write('stdout bytes\n')z"sys.stderr.write('stderr bytes\n')r1r2z$os.kill(os.getpid(), signal.SIGKILL)cs4|\}}}��|d���|d���|tj�dS)Ns
stdout bytes
s
stderr bytes
)r#�signal�SIGKILL)�out_err_sigr;r+�sigr,rrr=�s
z>ProcessUtilsTests.test_outputSignal.<locals>.gotOutputAndValuer)rrr?r!r(�tupler"r@rr,r�test_outputSignal�s�
z#ProcessUtilsTests.test_outputSignalcCsVtj�|���}t�|�|�ddg�}||jd|g|d�}|�||�t	�
���|S)N�import os, syszsys.stdout.write(os.getcwd())r)r)rrrr�makedirsrr!r"�encode�sys�getfilesystemencoding)r�utilFunc�check�dirrr%rrr�	_pathTest�s
�zProcessUtilsTests._pathTestcC�|�tj|j�S)z
        L{getProcessOutput} runs the given command with the working directory
        given by the C{path} parameter.
        )rPrr r#r,rrr�test_getProcessOutputPath�sz+ProcessUtilsTests.test_getProcessOutputPathc��fdd�}��tj|�S)z~
        L{getProcessValue} runs the given command with the working directory
        given by the C{path} parameter.
        c���|d�dS�Nrr8��result�ignoredr,rrrN�r.z9ProcessUtilsTests.test_getProcessValuePath.<locals>.check)rPrr6�rrNrr,r�test_getProcessValuePath�sz*ProcessUtilsTests.test_getProcessValuePathcrS)z�
        L{getProcessOutputAndValue} runs the given command with the working
        directory given by the C{path} parameter.
        c�&|\}}}��||���|d�dSrUr8��out_err_statusrOr;r+�statusr,rrrN��
zBProcessUtilsTests.test_getProcessOutputAndValuePath.<locals>.check)rPrr?rYrr,r�!test_getProcessOutputAndValuePath�sz3ProcessUtilsTests.test_getProcessOutputAndValuePathcCs�tj�|���}t�|�|�gd��}|�tjt���t�|�t	�
t�	d�j�}t�|t	j
t	jB�|�tj||�||jd|g�}|�||�t����|S)N)rHzcdir = os.getcwd()zsys.stdout.write(cdir)�.r)rrrrrIr�
addCleanup�chdir�getcwd�stat�S_IMODE�st_mode�chmod�S_IXUSR�S_IRUSRr!r"rJrKrL)rrMrNrOr�originalModer%rrr�_defaultPathTest�s
�
z"ProcessUtilsTests._defaultPathTestcCrQ)a
        If no value is supplied for the C{path} parameter, L{getProcessOutput}
        runs the given command in the same working directory as the parent
        process and succeeds even if the current working directory is not
        accessible.
        )rlrr r#r,rrr� test_getProcessOutputDefaultPath�sz2ProcessUtilsTests.test_getProcessOutputDefaultPathcrS)a
        If no value is supplied for the C{path} parameter, L{getProcessValue}
        runs the given command in the same working directory as the parent
        process and succeeds even if the current working directory is not
        accessible.
        crTrUr8rVr,rrrNr.z@ProcessUtilsTests.test_getProcessValueDefaultPath.<locals>.check)rlrr6rYrr,r�test_getProcessValueDefaultPath�sz1ProcessUtilsTests.test_getProcessValueDefaultPathcrS)a	
        If no value is supplied for the C{path} parameter,
        L{getProcessOutputAndValue} runs the given command in the same working
        directory as the parent process and succeeds even if the current
        working directory is not accessible.
        cr[rUr8r\r,rrrNr_zIProcessUtilsTests.test_getProcessOutputAndValueDefaultPath.<locals>.check)rlrr?rYrr,r�(test_getProcessOutputAndValueDefaultPathsz:ProcessUtilsTests.test_getProcessOutputAndValueDefaultPathcsD��ddg�}d�tj�jd|g�d�}��fdd�}|�|�|S)z�
        Standard input can be made available to the child process by passing
        bytes for the `stdinBytes` parameter.
        rz"sys.stdout.write(sys.stdin.read())sThese are the bytes to see.r)�
stdinBytescs&|\}}}���|���d|�dSrU)�assertInr#r9�rrprrr=(s
zPProcessUtilsTests.test_get_processOutputAndValueStdin.<locals>.gotOutputAndValuer>)rrr%r=rrrr�#test_get_processOutputAndValueStdins���
z5ProcessUtilsTests.test_get_processOutputAndValueStdin) �__name__�
__module__�__qualname__�__doc__r�IReactorProcessr�skip�output�valuerK�
executabler!rr&r0r4r7rArr�	isWindowsrGrPrRrZr`rlrmrnrorsrrrrrs0




	
rc@seZdZdZdd�ZdS)�SuppressWarningsTestsz.
    Tests for L{utils.suppressWarnings}.
    cs�g��fdd�}|�td|�dd�}t�|dtdd�f�}|d	�|�t��d
�|d�|�t��d
�|d�|�t��d�d
S)zs
        L{utils.suppressWarnings} decorates a function so that the given
        warnings are suppressed.
        cs��||f�dSr')�append)r�a�kw�rWrr�showwarning@sz@SuppressWarningsTests.test_suppressWarnings.<locals>.showwarningr�cSst�|�dSr')�warnings�warn)�msgrrr�fEsz6SuppressWarningsTests.test_suppressWarnings.<locals>.f)�ignorezThis is message��messagezSanity check messager5zUnignored message�N)�patchr�r�suppressWarnings�dictr#�len)rr�r��grr�r�test_suppressWarnings9sz+SuppressWarningsTests.test_suppressWarningsN)rtrurvrwr�rrrrr~4sr~c@s*eZdZdZeej�Zdd�Zdd�ZdS)�DeferredSuppressedWarningsTestsz`
    Tests for L{utils.runWithWarningsSuppressed}, the version that supports
    Deferreds.
    cshdifdifg}t��|�|�fdd��t�d���d�t�d�|�dgdd	�|��D��d
S)z�
        If the function called by L{utils.runWithWarningsSuppressed} returns a
        C{Deferred}, the warning filters aren't removed until the Deferred
        fires.
        �r�z.*foo.*�r�z.*bar.*c��Sr'rrr�rr�<lambda>l�zGDeferredSuppressedWarningsTests.test_deferredCallback.<locals>.<lambda>�
ignore foo��ignore foo 2cS�g|]}|d�qSr�r��.0�wrrr�
<listcomp>p�zIDeferredSuppressedWarningsTests.test_deferredCallback.<locals>.<listcomp>N)r�runWithWarningsSuppressedr�r��callbackr#�
flushWarnings)r�filtersrr�r�test_deferredCallbackds


 z5DeferredSuppressedWarningsTests.test_deferredCallbackcsxdifdifg}t��|�|�fdd��}t�d���t��|�dd��t�d�|�dgdd	�|��D��d
S)z�
        If the function called by L{utils.runWithWarningsSuppressed} returns a
        C{Deferred}, the warning filters aren't removed until the Deferred
        fires with an errback.
        r�r�cr�r'rrr�rrr�zr�zFDeferredSuppressedWarningsTests.test_deferredErrback.<locals>.<lambda>r�cSs
|�t�Sr')�trap�ZeroDivisionError)r�rrrr�}s
r�cSr�r�rr�rrrr�r�zHDeferredSuppressedWarningsTests.test_deferredErrback.<locals>.<listcomp>N)	rr�r�r��errbackr��
addErrbackr#r�)rr�r%rr�r�test_deferredErrbackrs

 z4DeferredSuppressedWarningsTests.test_deferredErrbackN)	rtrurvrw�staticmethodrr�r�r�rrrrr�Zs

r�)rwrrBrerKr��unittestr�twisted.internetrrrr�twisted.internet.deferr�twisted.python.runtimer�twisted.python.test.test_utilr	�twisted.trial.unittestr
rrr~r�rrrr�<module>s"&

Anon7 - 2022
AnonSec Team