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/application/runner/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/application/runner/test/__pycache__/test_pidfile.cpython-310.pyc
o

�b;2�@s�dZddlZddlmZddlmZmZddlm	Z	m
Z
mZddlm
Z
ddlZddlmZddlmZdd	lmZd
dlmZdd
lmZmZmZmZmZmZmZde
de	fde
de	ffdd�ZGdd�dejj j!�Z"Gdd�dejj j!�Z#dS)z3
Tests for L{twisted.application.runner._pidfile}.
�N)�wraps)�getpid�name)�Any�Callable�Optional)�verifyObject)�FilePath)�platform)�SkipTest�)�_pidfile�)�AlreadyRunningError�InvalidPIDFileError�IPIDFile�NonePIDFile�
NoPIDFound�PIDFile�StalePIDFileError�f.�returnc	s*t��dtdtdtdtf�fdd��}|S)a=
    Decorator for tests that are not expected to work on all platforms.

    Calling L{PIDFile.isRunning} currently raises L{NotImplementedError} on
    non-POSIX platforms.

    On an unsupported platform, we expect to see any test that calls
    L{PIDFile.isRunning} to raise either L{NotImplementedError}, L{SkipTest},
    or C{self.failureException}.
    (C{self.failureException} may occur in a test that checks for a specific
    exception but it gets NotImplementedError instead.)

    @param f: The test method to decorate.

    @return: The wrapped callable.
    �self�args�kwargsrcspt��dk}|r�|g|�Ri|��S|jtt|jf�|g|�Ri|��}t|t�r6|�t|��	d��dSdS)N�posixz isRunning is not implemented on )
r
�getType�assertRaises�NotImplementedErrorr�failureException�
isinstance�
assertTrue�str�
startswith)rrr�	supported�e�r��N/usr/lib/python3/dist-packages/twisted/application/runner/test/test_pidfile.py�wrapper1s
���
�z$ifPlatformSupported.<locals>.wrapper)rr)rr)r'r&r(�ifPlatformSupporteds r*c@seZdZdZd1deedefdd�Zd2dd�Zd2d	d
�Z	d2dd�Z
d2d
d�Zd2dd�Zd2dd�Z
d2dd�Zd2dd�Zd2dd�Zd2dd�Zd2dd�Zed2dd��Zed2dd ��Zed2d!d"��Zed2d#d$��Zed2d%d&��Zed2d'd(��Zd2d)d*�Zd2d+d,�Zed2d-d.��Zed2d/d0��ZdS)3�PIDFileTestsz
    Tests for L{PIDFile}.
    N�contentrcCs"t|���}|dur|�|�|S�N)r	�mktemp�
setContent)rr,�filePathr'r'r(r0Js
zPIDFileTests.filePathcCst|���}tt|�dS)z5
        L{PIDFile} conforms to L{IPIDFile}.
        N)rr0rr�r�pidFiler'r'r(�test_interfacePszPIDFileTests.test_interfacecCs|�tjdd�d�dS)zR
        L{PIDFile._format} returns the expected format when given a PID.
        �9��pids1337
N)�assertEqualr�_format)rr'r'r(�test_formatWithPIDWszPIDFileTests.test_formatWithPIDcCs.d}t|�tj|d���}|�||���dS)zK
        L{PIDFile.read} returns the PID from the given file path.
        r4r5N)rr0r8r7�read�rr6r2r'r'r(�test_readWithPID]szPIDFileTests.test_readWithPIDcCs:d}t|�d��}|�t|j�}|�t|�d|���dS)�f
        L{PIDFile.read} raises L{InvalidPIDFileError} when given an empty file
        path.
        ��#non-integer PID value in PID file: N�rr0rrr:r7r"�r�pidValuer2r%r'r'r(�test_readEmptyPIDg�zPIDFileTests.test_readEmptyPIDcCs:d}t|�|��}|�t|j�}|�t|�d|���dS)r=s$foo!r?Nr@rAr'r'r(�test_readWithBogusPIDrrDz"PIDFileTests.test_readWithBogusPIDcCs.t|���}|�t|j�}|�t|�d�dS)zc
        L{PIDFile.read} raises L{NoPIDFound} when given a non-existing file
        path.
        �PID file does not existN)rr0rrr:r7r"�rr2r%r'r'r(�test_readDoesntExist}sz!PIDFileTests.test_readDoesntExistcCsPddtdtfdd�}|�td|�t|���}|�t|j�}|�|j	t	j
�dS)	z�
        L{PIDFile.read} re-raises L{OSError} if the associated C{errno} is
        anything other than L{errno.ENOENT}.
        �r�modercS�ttjd��)Nz	I/O error)�OSError�errno�EIO)rJr'r'r(�oops��z>PIDFileTests.test_readOpenRaisesOSErrorNotENOENT.<locals>.oops�openN)rI)r"r	�patchrr0rrLr:r7rMrN)rrOr2�errorr'r'r(�#test_readOpenRaisesOSErrorNotENOENT�s
z0PIDFileTests.test_readOpenRaisesOSErrorNotENOENTcCs.d}t|���}|�|�|�|��|�dS)z9
        L{PIDFile._write} stores the given PID.
        i�N)rr0�_writer7r:r;r'r'r(�
test_writePID�s
zPIDFileTests.test_writePIDcCs t|���}|�t|jd�dS)zS
        L{PIDFile._write} raises L{ValueError} when given an invalid PID.
        �burpN)rr0r�
ValueErrorrUr1r'r'r(�test_writePIDInvalid�sz!PIDFileTests.test_writePIDInvalidcCs*t|���}|��|�|��t��dS)zT
        L{PIDFile.writeRunningPID} stores the PID for the current process.
        N)rr0�writeRunningPIDr7r:rr1r'r'r(�test_writeRunningPID�sz!PIDFileTests.test_writeRunningPIDcCs:t|�d��}|�|j���|��|�|j���dS)z9
        L{PIDFile.remove} removes the PID file.
        r>N)rr0r!�exists�remove�assertFalser1r'r'r(�test_remove�szPIDFileTests.test_removecC�Lt|���}|�d�dtdtddfdd�}|�td|�|�|���dS)	zR
        L{PIDFile.isRunning} returns true for a process that does exist.
        r4r6�signalrNcS�dSr-r'�r6rar'r'r(�kill��z2PIDFileTests.test_isRunningDoesExist.<locals>.killrd�rr0rU�intrRr
r!�	isRunning�rr2rdr'r'r(�test_isRunningDoesExist�s

z$PIDFileTests.test_isRunningDoesExistcCs&t|���}|��|�|���dS)a@
        L{PIDFile.isRunning} returns true for this process (which is running).

        @note: This differs from L{PIDFileTests.test_isRunningDoesExist} in
        that it actually invokes the C{kill} system call, which is useful for
        testing of our chosen method for probing the existence of a process.
        N)rr0rZr!rhr1r'r'r(�test_isRunningThis�s	zPIDFileTests.test_isRunningThiscCsLt|���}|�d�dtdtddfdd�}|�td|�|�t|j�dS)	z{
        L{PIDFile.isRunning} raises L{StalePIDFileError} for a process that
        does not exist (errno=ESRCH).
        r4r6rarNcSrK�NzNo such process�rLrM�ESRCHrcr'r'r(rd�rPz5PIDFileTests.test_isRunningDoesNotExist.<locals>.killrd)	rr0rUrgrRr
rrrhrir'r'r(�test_isRunningDoesNotExist��

z'PIDFileTests.test_isRunningDoesNotExistcCr`)	zx
        L{PIDFile.isRunning} returns true for a process that we are not allowed
        to kill (errno=EPERM).
        r4r6rarNcSrK)NzOperation not permitted)rLrM�EPERMrcr'r'r(rd�rPz3PIDFileTests.test_isRunningNotAllowed.<locals>.killrdrfrir'r'r(�test_isRunningNotAllowed�rpz%PIDFileTests.test_isRunningNotAllowedcCs8tdkrtd��t|���}|�d�|�|���dS)ac
        L{PIDFile.isRunning} returns true for a process that we are not allowed
        to kill (errno=EPERM).

        @note: This differs from L{PIDFileTests.test_isRunningNotAllowed} in
        that it actually invokes the C{kill} system call, which is useful for
        testing of our chosen method for probing the existence of a process
        that we are not allowed to kill.

        @note: In this case, we try killing C{init}, which is process #1 on
        POSIX systems, so this test is not portable.  C{init} should always be
        running and should not be killable by non-root users.
        rzThis test assumes POSIX�N)�SYSTEM_NAMErrr0rUr!rhr1r'r'r(�test_isRunningInit�s

zPIDFileTests.test_isRunningInitcCsJt|���}|��dtdtddfdd�}|�td|�|�t|j�dS)z�
        L{PIDFile.isRunning} re-raises L{OSError} if the attached C{errno}
        value from L{os.kill} is not an expected one.
        r6rarNcSrK)NzFile exists)rLrM�EEXISTrcr'r'r(rdrPz5PIDFileTests.test_isRunningUnknownErrno.<locals>.killrd)	rr0rZrgrRr
rrLrhrir'r'r(�test_isRunningUnknownErrnos
z'PIDFileTests.test_isRunningUnknownErrnocCst|���}|�|���dS)zS
        L{PIDFile.isRunning} returns false if the PID file doesn't exist.
        N)rr0r^rhr1r'r'r(�test_isRunningNoPIDFile!sz$PIDFileTests.test_isRunningNoPIDFilecCsvt|���}|�|j���|�|�|j���|�|��t��Wd�n1s,wY|�|j���dS)z�
        When used as a context manager, a L{PIDFile} will store the current pid
        on entry, then removes the PID file on exit.
        N)rr0r^r\r!r7r:rr1r'r'r(�test_contextManager)s�z PIDFileTests.test_contextManagercCs�t|���}|�d�dtdtddfdd�}|�td|�|�t|j�}|�	t
|�d	�|�|�	|��t��Wd�dS1sCwYdS)
z�
        When used as a context manager, a L{PIDFile} will replace the
        underlying PIDFile rather than raising L{AlreadyRunningError} if the
        contained PID file exists but refers to a non-running PID.
        r4r6rarNcSrKrlrmrcr'r'r(rdArPz9PIDFileTests.test_contextManagerDoesntExist.<locals>.killrdz'PID file refers to non-existing process)
rr0rUrgrRr
rrrhr7r"r:r)rr2rdr%r'r'r(�test_contextManagerDoesntExist7s
"�z+PIDFileTests.test_contextManagerDoesntExistcCsZt|���}|�d�dtdtddfdd�}|�td|�|�|���|�t	|j
�dS)	z�
        When used as a context manager, a L{PIDFile} will raise
        L{AlreadyRunningError} if the there is already a running process with
        the contained PID.
        r4r6rarNcSrbr-r'rcr'r'r(rdVrez<PIDFileTests.test_contextManagerAlreadyRunning.<locals>.killrd)rr0rUrgrRr
r!rhrr�	__enter__rir'r'r(�!test_contextManagerAlreadyRunningLs
z.PIDFileTests.test_contextManagerAlreadyRunningr-�rN)�__name__�
__module__�__qualname__�__doc__r�bytesr	r0r3r9r<rCrErHrTrVrYr[r_r*rjrkrorrrurwrxryrzr|r'r'r'r(r+Es@












	



r+c@sVeZdZdZddd�Zddd�Zddd	�Zdd
d�Zddd
�Zddd�Z	ddd�Z
dS)�NonePIDFileTestsz#
    Tests for L{NonePIDFile}.
    rNcCst�}tt|�dS)z9
        L{NonePIDFile} conforms to L{IPIDFile}.
        N)rrrr1r'r'r(r3eszNonePIDFileTests.test_interfacecCs(t�}|�t|j�}|�t|�d�dS)z;
        L{NonePIDFile.read} raises L{NoPIDFound}.
        rFN)rrrr:r7r"rGr'r'r(�	test_readl�zNonePIDFileTests.test_readcCs*t�}|�t|jd�}|�|jtj�dS)zZ
        L{NonePIDFile._write} raises L{OSError} with an errno of L{errno.EPERM}.
        rN)rrrLrUr7rMrq�rr2rSr'r'r(�
test_writeuszNonePIDFileTests.test_writecC�(t�}|�t|j�}|�|jtj�dS)zk
        L{NonePIDFile.writeRunningPID} raises L{OSError} with an errno of
        L{errno.EPERM}.
        N)rrrLrZr7rMrqr�r'r'r(r[~sz%NonePIDFileTests.test_writeRunningPIDcCr�)zZ
        L{NonePIDFile.remove} raises L{OSError} with an errno of L{errno.EPERM}.
        N)rrrLr]r7rM�ENOENTr�r'r'r(r_�r�zNonePIDFileTests.test_removecCst�}|�|��d�dS)z<
        L{NonePIDFile.isRunning} returns L{False}.
        FN)rr7rhr1r'r'r(�test_isRunning�szNonePIDFileTests.test_isRunningcCs0t�}|�	Wd�dS1swYdS)zo
        When used as a context manager, a L{NonePIDFile} doesn't raise, despite
        not existing.
        N)rr1r'r'r(ry�s"�z$NonePIDFileTests.test_contextManagerr})r~rr�r�r3r�r�r[r_r�ryr'r'r'r(r�`s


	
	


	r�)$r�rM�	functoolsr�osrrrt�typingrrr�zope.interface.verifyr�twisted.trial.unittest�twisted�twisted.python.filepathr	�twisted.python.runtimer
r�runnerr
rrrrrrrr*�trial�unittest�TestCaser+r�r'r'r'r(�<module>s"$"&

Anon7 - 2022
AnonSec Team