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_lockfile.cpython-310.pyc
o

�b�;�@s�dZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
dZd	Ze��rBe	d
�durBe	d�durBdZd
ZGdd�de
�ZGdd�de
�ZdS)z'
Tests for L{twisted.python.lockfile}.
�N)�skipIf�
skipUnless)�lockfile)�
requireModule)�platform)�TestCaseF�zwin32api.OpenProcess�
pywintypesTzZOn windows, lockfile.kill is not implemented in the absence of win32api and/or pywintypes.c@sxeZdZdZdd�Zee��d�dd��Zdd�Z	ee��d	�d
d��Z
eee
�dd
��Zeee
�dd��Zdd�ZdS)�	UtilTestszM
    Tests for the helper functions used to implement L{FilesystemLock}.
    cCs:|��}t�d|�|�ttjd|�}|�|jtj�dS)z�
        L{lockfile.symlink} raises L{OSError} with C{errno} set to L{EEXIST}
        when an attempt is made to create a symlink which already exists.
        �fooN)�mktempr�symlink�assertRaises�OSError�assertEqual�errno�EEXIST��self�name�exc�r�</usr/lib/python3/dist-packages/twisted/test/test_lockfile.py�test_symlinkEEXIST&szUtilTests.test_symlinkEEXIST�Bspecial rename EIO handling only necessary and correct on Windows.cCsD|��}dd�}|�td|�|�ttj|d�}|�|jtj�dS)a<
        L{lockfile.symlink} raises L{OSError} with C{errno} set to L{EIO} when
        the underlying L{rename} call fails with L{EIO}.

        Renaming a file on Windows may fail if the target of the rename is in
        the process of being deleted (directory deletion appears not to be
        atomic).
        cS�ttjd���N�rr�EIO��src�dstrrr�
fakeRename?�z4UtilTests.test_symlinkEIOWindows.<locals>.fakeRename�renamerN)	r�patchrr�IOErrorr
rrr)rrr"rrrr�test_symlinkEIOWindows0s

z UtilTests.test_symlinkEIOWindowscCs,|��}|�ttj|�}|�|jtj�dS)z�
        L{lockfile.readlink} raises L{OSError} with C{errno} set to L{ENOENT}
        when an attempt is made to read a symlink which does not exist.
        N)rrrr�readlinkrr�ENOENTrrrr�test_readlinkENOENTFszUtilTests.test_readlinkENOENT�Gspecial readlink EACCES handling only necessary and correct on Windows.cCsB|��}dd�}|�td|�|�ttj|�}|�|jtj�dS)a\
        L{lockfile.readlink} raises L{OSError} with C{errno} set to L{EACCES}
        on Windows when the underlying file open attempt fails with C{EACCES}.

        Opening a file on Windows may fail if the path is inside a directory
        which is in the process of being deleted (directory deletion appears
        not to be atomic).
        cSrr�rr�EACCES)�path�moderrr�fakeOpen^r#z6UtilTests.test_readlinkEACCESWindows.<locals>.fakeOpen�_openN)	rr%rrr&r(rrr-)rrr0rrrr�test_readlinkEACCESWindowsOs

z$UtilTests.test_readlinkEACCESWindowscCst�t��d�dS)z}
        L{lockfile.kill} returns without error if passed the PID of a
        process which exists and signal C{0}.
        rN)r�kill�os�getpid�rrrr�	test_killeszUtilTests.test_killcCs&|�ttjdd�}|�|jtj�dS)z�
        L{lockfile.kill} raises L{OSError} with errno of L{ESRCH} if
        passed a PID which does not correspond to any process.
        i���rN)rrrr3rr�ESRCH)rrrrr�test_killESRCHmszUtilTests.test_killESRCHcCs6|�tdd�t�|���}|��|�|���dS)z�
        Verify that when L{lockfile.kill} does end up as None (e.g. on Windows
        without pywin32), it doesn't end up being called and raising a
        L{TypeError}.
        r3N)r%r�FilesystemLockr�lock�assertFalse)r�flrrr�test_noKillCallwszUtilTests.test_noKillCallN)�__name__�
__module__�__qualname__�__doc__rrr�	isWindowsr'r*r2r�skipKill�skipKillReasonr7r9r>rrrrr
!s&
�
	�


	r
c@s�eZdZdd�Zdd�Zee��d�dd��Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ee��d�dd��Zee��d�dd��Zdd�Zdd�Zee��d�dd��Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(S))�LockingTestscsL�fdd�}|�td|�|��}t�|�}|�t|j�}|�|j��dS)Ncs
t�d��r)r)�source�dest�rrr�fakeSymlink��
z3LockingTests._symlinkErrorTest.<locals>.fakeSymlinkr
)	r%rrr:rrr;rr)rrrJ�lockfr;rrrIr�_symlinkErrorTest�s
zLockingTests._symlinkErrorTestcCs|�tj�dS)z�
        An exception raised by C{symlink} other than C{EEXIST} is passed up to
        the caller of L{FilesystemLock.lock}.
        N)rMr�ENOSYSr6rrr�test_symlinkError�szLockingTests.test_symlinkErrorz9POSIX-specific error propagation not expected on Windows.cCs|�tj�|�tj�dS)a 
        An L{OSError} raised by C{symlink} on a POSIX platform with an errno of
        C{EACCES} or C{EIO} is passed to the caller of L{FilesystemLock.lock}.

        On POSIX, unlike on Windows, these are unexpected errors which cannot
        be handled by L{FilesystemLock}.
        N)rMrr-rr6rrr�test_symlinkErrorPOSIX�sz#LockingTests.test_symlinkErrorPOSIXcCs<|��}t�|�}|�|���|�|j�|�|j�dS)z�
        If the lock has never been held, it can be acquired and the C{clean}
        and C{locked} attributes are set to C{True}.
        N)rrr:�
assertTruer;�clean�locked�rrLr;rrr�test_cleanlyAcquire�s

z LockingTests.test_cleanlyAcquirecCsh|��}t�|�}|�|���|��|�|j�t�|�}|�|���|�|j�|�|j�dS)z�
        If a lock is released cleanly, it can be re-acquired and the C{clean}
        and C{locked} attributes are set to C{True}.
        N)	rrr:rQr;�unlockr<rSrRrTrrr�test_cleanlyRelease�s

z LockingTests.test_cleanlyReleasecCsH|��}t�|�}|�|���t�|�}|�|���|�|j�dS)zK
        If a lock is currently locked, it cannot be locked again.
        N)rrr:rQr;r<rS)rrL�	firstLock�
secondLockrrr�test_cannotLockLocked�s

z"LockingTests.test_cannotLockLockedcs�d��fdd�}|��}|�td|�t�t��|�t�|�}|�|���|�|j	�|�|j
�|�t�|�tt
����dS)z�
        If a lock was held by a process which no longer exists, it can be
        acquired, the C{clean} attribute is set to C{False}, and the
        C{locked} attribute is set to C{True}.
        i90cs,|dkr
ttjd��|�krttjd��dS)Nr�rr�EPERMr8��pid�signal��ownerrr�fakeKill��
�z4LockingTests.test_uncleanlyAcquire.<locals>.fakeKillr3N)rr%rr
�strr:rQr;r<rRrSrr(r4r5)rrbrLr;rr`r�test_uncleanlyAcquire�s
z"LockingTests.test_uncleanlyAcquirec�~��fdd�}|�td|��dd�}|�td|�|���t���}t�td���|�|���|�|j�|�|j	�dS)	z�
        If the lock is initially held but then released before it can be
        examined to determine if the process which held it still exists, it is
        acquired and the C{clean} and C{locked} attributes are set to C{True}.
        cst������t�|�Sr)r�rmlink�restorer(�r�rL�
readlinkPatchrr�fakeReadlink�s

z?LockingTests.test_lockReleasedBeforeCheck.<locals>.fakeReadlinkr(cS�,|dkr
ttjd��|dkrttjd��dS�Nr�u�r[r]rrrrb�rcz;LockingTests.test_lockReleasedBeforeCheck.<locals>.fakeKillr3roN�
r%rrr:r
rdrQr;rRrS)rrlrbr;rrjr�test_lockReleasedBeforeCheck��
z)LockingTests.test_lockReleasedBeforeCheckrcCsFdd�}|�td|�|��}t�|�}|�|���|�|j�dS)a�
        If the lock is released while an attempt is made to acquire
        it, the lock attempt fails and C{FilesystemLock.lock} returns
        C{False}.  This can happen on Windows when L{lockfile.symlink}
        fails with L{IOError} of C{EIO} because another process is in
        the middle of a call to L{os.rmdir} (implemented in terms of
        RemoveDirectory) which is not atomic.
        cSrrrrrrrrJszGLockingTests.test_lockReleasedDuringAcquireSymlink.<locals>.fakeSymlinkr
N)r%rrr:r<r;rS)rrJrLr;rrr�%test_lockReleasedDuringAcquireSymlinks
z2LockingTests.test_lockReleasedDuringAcquireSymlinkr+cCsVdd�}|�td|�|��}t�|�}t�td�|�|�|���|�|j�dS)z�
        If the lock is initially held but is released while an attempt
        is made to acquire it, the lock attempt fails and
        L{FilesystemLock.lock} returns C{False}.
        cSrrr,rirrrrl)szILockingTests.test_lockReleasedDuringAcquireReadlink.<locals>.fakeReadlinkr(roN)	r%rrr:r
rdr<r;rS)rrlrLr;rrr�&test_lockReleasedDuringAcquireReadlinks
z3LockingTests.test_lockReleasedDuringAcquireReadlinkcsj��fdd�}|�td|�|��}t�td�|�t�|�}|��|j�}|�|j	��|�
|j�dS)Ncs
��d��rrri�r�
exceptionTyperrrl8rKz5LockingTests._readlinkErrorTest.<locals>.fakeReadlinkr(ro)r%rrr
rdr:rr;rrr<rS)rrvrrlrLr;rrrur�_readlinkErrorTest7s
zLockingTests._readlinkErrorTestcCs |�ttj�|�ttj�dS)z�
        An exception raised by C{readlink} other than C{ENOENT} is passed up to
        the caller of L{FilesystemLock.lock}.
        N)rwrrrNr&r6rrr�test_readlinkErrorGszLockingTests.test_readlinkErrorcCs |�ttj�|�ttj�dS)z�
        Any L{IOError} raised by C{readlink} on a POSIX platform passed to the
        caller of L{FilesystemLock.lock}.

        On POSIX, unlike on Windows, these are unexpected errors which cannot
        be handled by L{FilesystemLock}.
        N)rwr&rrNr-r6rrr�test_readlinkErrorPOSIXOsz$LockingTests.test_readlinkErrorPOSIXcrf)	z�
        If a second process cleans up the lock after a first one checks the
        lock and finds that no process is holding it, the first process does
        not fail when it tries to clean up the lock.
        cs���t���t�|�Sr)rhrrgri�rL�rmlinkPatchrr�
fakeRmlinkes

z?LockingTests.test_lockCleanedUpConcurrently.<locals>.fakeRmlinkrgcSrmrnr[r]rrrrbnrcz=LockingTests.test_lockCleanedUpConcurrently.<locals>.fakeKillr3roNrp)rr|rbr;rrzr�test_lockCleanedUpConcurrently^rrz+LockingTests.test_lockCleanedUpConcurrentlycCs|dd�}|�td|�dd�}|�td|�|��}t�td�|�t�|�}|�t|j�}|�	|j
t
j�|�|j
�dS)	z�
        An exception raised by L{rmlink} other than C{ENOENT} is passed up
        to the caller of L{FilesystemLock.lock}.
        cSrr)rrrNrirrrr|�r#z1LockingTests.test_rmlinkError.<locals>.fakeRmlinkrgcSrmrnr[r]rrrrb�rcz/LockingTests.test_rmlinkError.<locals>.fakeKillr3roN)r%rrr
rdr:rrr;rrrNr<rS)rr|rbrLr;rrrr�test_rmlinkError}s
zLockingTests.test_rmlinkErrorcCsfdd�}|�td|�|��}t�td�|�t�|�}|�t|j�}|�	|j
t
j�|�|j
�dS)z�
        If L{kill} raises an exception other than L{OSError} with errno set to
        C{ESRCH}, the exception is passed up to the caller of
        L{FilesystemLock.lock}.
        cSrr)rrr\r]rrrrb�r#z-LockingTests.test_killError.<locals>.fakeKillr3roN)r%rrr
rdr:rrr;rrr\r<rS)rrbrLr;rrrr�test_killError�s
zLockingTests.test_killErrorcCs<|��}t�tt��d�|�t�|�}|�t|j	�dS)z�
        L{FilesystemLock.unlock} raises L{ValueError} if called for a lock
        which is held by a different process.
        �N)
rrr
rdr4r5r:r�
ValueErrorrVrTrrr�test_unlockOther�s
zLockingTests.test_unlockOthercCs\|��}|�t�|��t�|�}|�|���|�t�|��|��|�t�|��dS)zp
        L{isLocked} returns C{True} if the named lock is currently locked,
        C{False} otherwise.
        N)rr<r�isLockedr:rQr;rVrTrrr�
test_isLocked�s
zLockingTests.test_isLockedN)r?r@rArMrOrrrCrPrUrWrZrerqrrsrtrwrxryr}r~rr�r�rrrrrF�sF�
�
�
�

rF)rBrr4�unittestrr�twisted.pythonr�twisted.python.reflectr�twisted.python.runtimer�twisted.trial.unittestrrDrErCr
rFrrrr�<module>s$�b

Anon7 - 2022
AnonSec Team