Hacked By AnonymousFox
3
U��Zc
� @ s~ d dl Z d dlZd dlZd dlmZmZ d dlmZ d dlZG dd� de�Z G dd� d�Z
dd � Zed
krzej
e� pvd � dS )� N)�EWOULDBLOCK�EEXIST)�bstrc @ s e Zd ZdZdS )�LockfileLockedExceptionz$thrown ONLY when pid file is locked.N)�__name__�
__module__�__qualname__�__doc__� r
r
�!/usr/lib/python3.6/rhnLockfile.pyr s r c @ s* e Zd ZdZd dd�Zdd� Zdd� ZdS )
�Lockfilez�class that provides simple access to a PID-style lockfile.
methods: __init__(lockfile), acquire(), and release()
NOTE: currently acquires upon init
The *.pid file will be acquired, or an LockfileLockedException is raised.
Nc C s� t jjt jjt jj|���| _|| _| js4t j� | _t jj| j�}t jj |�s�yt j
|� W n8 tk
r� tj
� d }t|d�r�|jtkr�n� Y nX t j| jt jt jB t jB �| _| j� dS )zlcreate (if need be), and acquire lock on lockfile
lockfile example: '/var/run/up2date.pid'
� �errnoN)�os�path�abspath�
expanduser�
expandvars�lockfile�pid�getpid�dirname�exists�makedirs�OSError�sys�exc_info�hasattrr r �open�O_RDWR�O_CREAT�O_SYNC�f�acquire)�selfr r r �er
r
r �__init__$ s"