ó
Xé?_c           @   s  d  Z  d d l Z y d d l Z Wn e k
 r5 n Xy d d l Z Wn e k
 rY n Xd e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ	 d	 e f d
 „  ƒ  YZ
 d e
 f d „  ƒ  YZ d e ƒ  k rà e Z	 n  d e
 f d „  ƒ  YZ d e ƒ  k re Z	 n  d S(   sO   
Platform-independent file locking. Inspired by and modeled after zc.lockfile.
iÿÿÿÿNt	   LockErrorc           B   s   e  Z d  Z d Z d „  Z RS(   s   Could not obtain a locks   Unable to lock %rc         C   s!   t  t |  ƒ j |  j | ƒ d  S(   N(   t   superR    t   __init__t   msg(   t   selft   path(    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR      s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR       s   t   UnlockErrorc           B   s   e  Z d  Z d Z RS(   s   Could not release a locks   Unable to unlock %r(   R   R   R   R   (    (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR	      s   t   LockFilec           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s_   
    A default, naive locking implementation. Always fails if the file
    already exists.
    c         C   sd   | |  _  y' t j | t j t j Bt j Bƒ } Wn  t k
 rR t |  j  ƒ ‚ n Xt j | ƒ d  S(   N(	   R   t   ost   opent   O_CREATt   O_WRONLYt   O_EXCLt   OSErrorR    t   close(   R   R   t   fd(    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   +   s    	'c         C   s   t  j |  j ƒ d  S(   N(   R   t   removeR   (   R   (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyt   release3   s    c         C   s   d  S(   N(    (   R   (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   6   s    (   R   R   R   R   R   R   (    (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR
   $   s   		t   SystemLockFilec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s?   
    An abstract base class for platform-specific locking.
    c         C   s»   | |  _  y t | d ƒ |  _ Wn# t k
 rD t | d ƒ |  _ n Xy |  j ƒ  Wn- |  j j d ƒ |  j j ƒ  |  ` ‚  n X|  j j d t j	 ƒ  ƒ |  j j
 ƒ  |  j j ƒ  d  S(   Ns   r+s   a+i   s    %s
(   R   R   t   fpt   IOErrort
   _lock_filet   seekR   t   writeR   t   getpidt   truncatet   flush(   R   R   (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   @   s    	c         C   s4   t  |  d ƒ s d  S|  j ƒ  |  j j ƒ  |  ` d  S(   NR   (   t   hasattrt   _unlock_fileR   R   (   R   (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   Y   s
    
c         C   s"   y t  j |  j ƒ Wn n Xd S(   s,   
        Attempt to remove the file
        N(   R   R   R   (   R   (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   `   s    c         C   s   d S(   sQ   Attempt to obtain the lock on self.fp. Raise UnlockError if not
        released.N(    (   R   (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   n   s    (   R   R   R   R   R   R   R   (    (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   :   s
   			t   WindowsLockFilec           B   s   e  Z d  „  Z d „  Z RS(   c         C   sM   y# t  j |  j j ƒ  t  j d ƒ Wn# t k
 rH t |  j j ƒ ‚ n Xd  S(   Ni   (   t   msvcrtt   lockingR   t   filenot   LK_NBLCKR   R    t   name(   R   (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   u   s    #c         C   s]   y3 |  j  j d ƒ t j |  j  j ƒ  t j d ƒ Wn# t k
 rX t |  j  j ƒ ‚ n Xd  S(   Ni    i   (	   R   R   R!   R"   R#   t   LK_UNLCKR   R	   R%   (   R   (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   |   s
    #(   R   R   R   R   (    (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR    s   s   	R!   t   UnixLockFilec           B   s   e  Z d  „  Z RS(   c         C   sW   t  j t  j B} y t  j |  j j ƒ  | ƒ Wn# t k
 rR t |  j j ƒ ‚ n Xd  S(   N(	   t   fcntlt   LOCK_EXt   LOCK_NBt   flockR   R#   R   R    R%   (   R   t   flags(    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR   ‰   s
    (   R   R   R   (    (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyR'   ‡   s   R(   (   R   R   R!   t   ImportErrorR(   t	   ExceptionR    R	   t   objectR
   R   R    t   globalsR'   (    (    (    s|   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/lockfile.pyt   <module>   s&   
9	