File: //usr/lib/python3/dist-packages/twisted/python/__pycache__/lockfile.cpython-38.pyc
U
��W[& � @ s d Z ddlmZmZ ddlZddlZddlmZ ddlm Z ddl
mZ dd� Zdd lm
Z
e �� s�dd
lmZ ddlmZ ddlmZ dd
lmZ dZnbdZzddlmZ ddlZW n ek
r� dZY nX dZdZdd� ZeZdd� Zdd� Zdd� ZG dd� de�Zdd� ZddgZ dS )z&
Filesystem-based interprocess mutex.
� )�absolute_import�divisionN)�time)�platform)�_PY3c C s t tt� d ��S )Ni� )�str�int�_uniquefloat� r
r
�9/usr/lib/python3/dist-packages/twisted/python/lockfile.py�unique s r )�rename)�kill)�symlink)�readlink)�removeFT)�OpenProcess� �W c
C sv zt dd| � W nX tjk
rh } z8|jd tkr<W Y �$d S |jd tkrVttjd ��� W 5 d }~X Y n
X t d��d S )Nr z OpenProcess is required to fail.)
r �
pywintypes�error�args�ERROR_ACCESS_DENIED�ERROR_INVALID_PARAMETER�OSError�errno�ESRCH�RuntimeError)�pid�signal�er
r
r r 5 s
r c C s� |d t � d }tj�|d�}t�|� tr4d}nd}t||��}|�| � |�� W 5 Q R X zt ||� W n" t�
|� t�|� � Y nX dS )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
r r E s
r c
C s� zt tj�| d�d�}W nH tk
r` } z*|jtjksB|jtjkrNt|jd��� W 5 d}~X Y nX |� |� � }W 5 Q R X |S dS )zq
Read the contents of C{filename}. See the above comment block as to why
this is needed.
r �rN)
r'