CasperSecurity

Current Path : /lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/lockfile.cpython-310.pyc

o

�bZ�@s�dZddlZddlZddlmZddlmZdd�ZddlmZe�	�s3ddlm
Z
mZmZ
mZd	Zn0d
ZzddlZddlmZWneyLdZ
Yn	wdZd
Zdd�Z
eZdd�Zdd�Zdd�Z
Gdd�d�Zdd�ZddgZdS)z&
Filesystem-based interprocess mutex.
�N)�time)�platformcCsttt�d��S)Ni�)�str�int�_uniquefloat�rr�9/usr/lib/python3/dist-packages/twisted/python/lockfile.py�uniquesr	)�rename)�kill�readlink�remove�symlinkFT)�OpenProcess��Wc
Csjztdd|�Wt	d��tjy4}z|jdtkr"WYd}~dS|jdtkr/ttjd���d}~ww)Nrz OpenProcess is required to fail.)
r�
pywintypes�error�args�ERROR_ACCESS_DENIED�ERROR_INVALID_PARAMETER�OSError�errno�ESRCH�RuntimeError)�pid�signal�errrr4s���rcCs�|dt�d}tj�|d�}t�|�d}t||��}|�|�|��Wd�n1s0wYzt||�WdSt	yOt�
|�t�|��w)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�wN)r	�os�path�join�mkdir�_open�write�flushr
�
BaseExceptionr
�rmdir)�value�filename�newlinkname�
newvalname�mode�frrrrEs


�

�rc
Cs�zttj�|d�d�}Wnty+}z|jtjks |jtjkr&t|jd���d}~ww|�
|��}Wd�|S1s>wY|S)zq
        Read the contents of C{filename}. See the above comment block as to why
        this is needed.
        r�rN)	r$r r!r"rr�ENOENT�EIO�read)r*�fObjr�resultrrrr`s��

��rcCs"t�tj�|d��t�|�dS)Nr)r r
r!r"r()r*rrr�rmlinkrsr5c@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)�selfr7rrr�__init__�s
zFilesystemLock.__init__cCs�d}	zttt���|j�Wn�ty�}z�tr)|jtjtj	fvr)WYd}~dS|jtj
kr�zt|j�}Wn2tyh}z&|jtjkrOWYd}~WYd}~qtrc|jtjkrcWYd}~WYd}~dS�d}~wwz
t
durut
t|�d�WnKty�}z?|jtjkr�zt|j�Wn#ty�}z|jtjkr�WYd}~WYd}~WYd}~q�d}~wwd}WYd}~WYd}~q�d}~wwWYd}~dS�d}~wwd|_||_dS)z�
        Acquire this lock.

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

        @raise OSError: Any exception L{os.symlink()} may raise,
            other than L{errno.EEXIST}.
        TNFr)rrr �getpidr7r�_windowsr�EACCESr1�EEXISTrr0rrrr5�locked�clean)r8r?rrrrr�lock�sX
��
� ������+zFilesystemLock.lockcCs@t|j�}t|�t��krtd|j�d���t|j�d|_dS)z�
        Release this lock.

        This deletes the directory with the given name.

        @raise OSError: Any exception L{os.readlink()} may raise.
        @raise ValueError: If the lock is not owned by this process.
        zLock z not owned by this processFN)rr7rr r:�
ValueErrorr5r>)r8rrrr�unlock�s

	

zFilesystemLock.unlock)	�__name__�
__module__�__qualname__�__doc__r?r>r9r@rBrrrrr6ws=r6cCs:t|�}d}z|��}W|r|��|S|r|��ww)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@rB)r7�lr4rrr�isLocked�s

�
�rH)rFrr rr�twisted.python.runtimerr	r
�	isWindowsrrr
r5rr;r�win32apir�ImportErrorrr�openr$r6rH�__all__rrrr�<module>s6�
f
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