�
Ϫ�f* � � � d Z ddlZddlZddlmZ ddlmZ d� ZddlmZ ej � sddlm
Z
mZmZ
mZ dZnd Z ddlZdd
lmZ dZdZd
� Z
eZd� Zd� Zd� Z
G d� d� Zd� ZddgZy# e$ r dZ
Y �&w xY w)z&
Filesystem-based interprocess mutex.
� N)�time)�platformc �@ � t t t � dz � � S )Ni� )�str�int�_uniquefloat� � �9/usr/lib/python3/dist-packages/twisted/python/lockfile.py�uniquer s � ��s�<�>�D�(�)�*�*r
)�rename)�kill�readlink�remove�symlinkFT)�OpenProcess� �W c � � t dd| � t d� �# t j $ rQ}|j d t
k( rY d }~y |j d t k( rt t j d � �� d }~ww xY w)Nr z OpenProcess is required to fail.)
r �RuntimeError�
pywintypes�error�args�ERROR_ACCESS_DENIED�ERROR_INVALID_PARAMETER�OSError�errno�ESRCH)�pid�signal�es r r r 4 ss � �
G��A�q�#�&� #�#E�F�F�� �#�#�
��6�6�!�9� 3�3���V�V�A�Y�"9�9�!�%�+�+�t�4�4���
�s �
�A>�A9�1A9�9A>c � � |dz t � z dz }t j j |d� }t j |� d}t ||� 5 }|j
| � |j � ddd� t ||� y# 1 sw Y �xY w# t $ r, t j |� t j |� � w xY 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�fs r r r E s� � � ��n�v�x�/�*�<���W�W�\�\�+�y�9�
�
����� ��
�:�t�
$� ��
�G�G�E�N�
�G�G�I� � ��;��)� � �� � ��I�I�j�!��H�H�[�!�� �s �"B�B �B�5Cc �p � t t j j | d� d� }|5 |j � }ddd� |S # 1 sw Y S xY w# t
$ rV}|j t j k( s|j t j k( rt |j d� �� d}~ww xY w)zq
Read the contents of C{filename}. See the above comment block as to why
this is needed.
r �rN) r) r% r& |