HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/python/__pycache__/lockfile.cpython-38.pyc
U

��W[&�@s dZddlmZmZddlZddlZddlmZddlm	Z	ddl
mZdd�Zdd	lm
Z
e	��s�dd
lmZddlmZddlmZdd
lmZdZnbdZzddlmZddlZWnek
r�dZYnXdZdZdd�ZeZdd�Zdd�Zdd�ZGdd�de�Zdd�ZddgZ dS)z&
Filesystem-based interprocess mutex.
�)�absolute_import�divisionN)�time)�platform)�_PY3cCsttt�d��S)Ni�)�str�int�_uniquefloat�r
r
�9/usr/lib/python3/dist-packages/twisted/python/lockfile.py�uniquesr)�rename)�kill)�symlink)�readlink)�removeFT)�OpenProcess��Wc
Csvztdd|�WnXtjk
rh}z8|jdtkr<WY�$dS|jdtkrVttjd���W5d}~XYn
Xt	d��dS)Nrz OpenProcess is required to fail.)
r�
pywintypes�error�args�ERROR_ACCESS_DENIED�ERROR_INVALID_PARAMETER�OSError�errno�ESRCH�RuntimeError)�pid�signal�er
r
rr5s
rc	Cs�|dt�d}tj�|d�}t�|�tr4d}nd}t||��}|�|�|��W5QRXzt	||�Wn"t�
|�t�|��YnXdS)z�
        Write a file at C{filename} with the contents of C{value}. See the
        above comment block as to why this is needed.
        �.z.newlinkr�wZwcN)r�os�path�join�mkdirr�_open�write�flushr
r�rmdir)�value�filenameZnewlinknameZ
newvalname�mode�fr
r
rrEs



rc
Cs�zttj�|d�d�}WnHtk
r`}z*|jtjksB|jtjkrNt|jd���W5d}~XYnX|�|�	�}W5QRX|SdS)zq
        Read the contents of C{filename}. See the above comment block as to why
        this is needed.
        r�rN)
r'r#r$r%�IOErrorr�ENOENT�EIOr�read)r,ZfObjr �resultr
r
rrbsrcCs"t�tj�|d��t�|�dS)Nr)r#rr$r%r*)r,r
r
r�rmlinkssr5c@s0eZdZdZdZdZdd�Zdd�Zdd	�ZdS)
�FilesystemLocka
    A mutex.

    This relies on the filesystem property that creating
    a symlink is an atomic operation and that it will
    fail if the symlink already exists.  Deleting the
    symlink will release the lock.

    @ivar name: The name of the file associated with this lock.

    @ivar clean: Indicates whether this lock was released cleanly by its
        last owner.  Only meaningful after C{lock} has been called and
        returns True.

    @ivar locked: Indicates whether the lock is currently held by this
        object.
    NFcCs
||_dS)N)�name)�selfr7r
r
r�__init__�szFilesystemLock.__init__cCs�d}zttt���|j�W�n�tk
�r�}�zptrV|jtjtj	fkrVWY��RdS|jtj
k�r�zt|j�}Wnfttfk
r�}zD|jtj
kr�WY�2WY��qn tr�|jtjkr�WY�WY��dS�W5d}~XYnXztdk	r�tt|�d�Wn�tk
�r�}z~|jtjk�r�zt|j�WnHtk
�rl}z(|jtj
k�rZWY�WY�4WY�Lq�W5d}~XYnXd}WY�WY�&q�W5d}~XYnXWY�
dS�W5d}~XYnXd|_||_dS)z�
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise: Any exception os.symlink() may raise, other than
        EEXIST.
        TFNr)rrr#�getpidr7r�_windowsrZEACCESr2ZEEXISTrr0r1rrrr5�locked�clean)r8r=r rr
r
r�lock�sD

zFilesystemLock.lockcCs>t|j�}t|�t��kr*td|jf��t|j�d|_dS)z�
        Release this lock.

        This deletes the directory with the given name.

        @raise: Any exception os.readlink() may raise, or
        ValueError if the lock is not owned by this process.
        z!Lock %r not owned by this processFN)rr7rr#r:�
ValueErrorr5r<)r8rr
r
r�unlock�s	

�
zFilesystemLock.unlock)	�__name__�
__module__�__qualname__�__doc__r=r<r9r>r@r
r
r
rr6ys>r6cCs.t|�}d}z|��}W5|r&|��X|S)z�
    Determine if the lock of the given name is held or not.

    @type name: C{str}
    @param name: The filesystem path to the lock to test

    @rtype: C{bool}
    @return: True if the lock is held, False otherwise.
    N)r6r@r>)r7�lr4r
r
r�isLocked�s

rF)!rDZ
__future__rrrr#rr	Ztwisted.python.runtimerZtwisted.python.compatrrr
Z	isWindowsrrrrr5r;Zwin32apirr�ImportErrorrr�openr'�objectr6rF�__all__r
r
r
r�<module>s<

j