-í
õÔ5;c       sß     d  Z  
  d k l Z  d k Z d k Z d k Z d k Z  e d d f d „ Z ( e ƒ  \ Z Z	 , d e i
 f d „  ƒ  YZ 0 e Z 4 d f  d	 „  ƒ  YZ Ò e Z Ô d
 „  Z ß e d j o à e ƒ  n d S(   s   FileLock - Implements a file lock mechanism that does not depend
               on fcntl.

    Copyright (c) 1997-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.

(   s   ExitFunctionsNs	   localhosts	   127.0.0.1c    s¿      y  d k  } Wn  t j
 o  | Sn X yO  |  t j o   | i ƒ  }  n ! | i |  ƒ } " | i | ƒ d }  Wn  # | i	 j
 o $ | Sn X& |  | f Sd S(   sÿ    Returns fully qualified (hostname, ip) for the given hostname.

        If hostname is not given, the default name of the local host
        is chosen.

        Defaults to default in case an error occurs while trying to
        determine the data.

    Ni    (
   s   sockets   ImportErrors   defaults   hostnames   Nones   gethostnames   gethostbynames   ips   gethostbyaddrs   error(   s   hostnames   defaults   sockets   ip(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   _fqhostname s   
s   Errorc      s   , t  Z - RS(   N(   s   __name__s
   __module__(    (    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   Error, s   	s   SymbolicFileLockc    	  s¤   4 t  Z d  Z D F d Z H d „  Z P d „  Z Y d d e i e e i e	 i
 e e d „ Z ¢ d e	 i e e i e	 i
 d „ Z ¿ e	 i d „ Z Ë d	 „  Z RS(
   sÚ   Implements a file lock mechanism that uses symbolic links
        for locking. 

        Note that since the mechanism does not use file system
        function calls this may not always work in the desired
        way.

        The lock is acquired per process, not per thread.

        Instancevariables:
         filename - file the lock applies to
         lockfilename - name of the lock file
         locked - indicator if the lock is in position (1) or not (0)

    i    c    sB   H J | |  _  K | d |  _ L d |  _ N t i |  i ƒ d  S(   Ns   .lockedi    (   s   filenames   selfs   lockfilenames   lockeds   ExitFunctionss   registers   unlock(   s   selfs   filename(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   __init__H s   c    sR   P R |  i o S |  i d ƒ n T y U t i |  i ƒ Wn V W n Xd  S(   Ni    (   s   selfs   lockeds   unlocks   ExitFunctionss
   deregister(   s   self(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   __del__P s   iô  f0.0001c	    sj  Y l m |  i o n d Sn o |  i }	 p d | t i ƒ  f } q | ƒ  | d }
 s t i
 i } t t i } u t i } v xÖv d oËx | |	 ƒ o; y y z | | |	 ƒ Wn { | j
 o
 } n X Pn € | | ƒ  | ƒ  |
 j o[ƒ y% „ t i | |	 ƒ d ƒ \ } } Wn1 … | j
 o" } † | d |  i | f ‚ n X‰ t i | ƒ } Š | | j o2 Œ t | d d d f ƒd }  | | j } n
  d }  | ou ’ y “ t i | d	 ƒ WnT ” | j
 oE } – y — t i |  i ƒ Wn ˜ | j
 o
 š n Xœ q„ n Xn  | d
 |  i | | | f ‚ n q„ W  d |  _ d S(   s=   Try to lock the file for this process, waiting 
            timeout ms if necessary.

            Raises an exception if a timeout occurs. Multiple locking
            by the same process is not an error. 

            Note that a non existent path to the file will also result
            in a timeout.

            If the lock is held by a process running on our host, a
            timeout will first invoke a check of the locking
            process. If it is not alive anymore, the lock is removed
            and granted to the current process.
            
        Ns   %s:%if0.001i   s   :s!   file "%s" could not be locked: %ss   defaults   ???i    s$   file "%s" is locked by process %s:%i(    s   selfs   lockeds   lockfilenames   hostnames   oss   getpids   lockinfos   times   timeouts   stops   paths   islinks   symlinks   makelinks   readlinks   errors   sleeps	   sleeptimes   strings   splits   hosts   locking_pids   Errors   whys   filenames   atois   _fqhostnames   other_ips   ips   samehosts   kills   unlink(   s   selfs   timeouts	   sleeptimes   sleeps   Errors   times   errors   hostnames   ips   lockfilenames   stops   hosts   readlinks   lockinfos   whys   makelinks   samehosts   other_ips   locking_pids   islink(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   lockY sN    
%	
(c    s”   ¢ ± ² |  i o ³ d Sn ´ d |  _ µ y ¶ | |  i ƒ Wn) · | j
 o ¸ | d |  i ‚ n X» | o ¼ | | ƒ n ½ d Sd S(   s   Release the lock, letting other processes using this
            mechanism access the file. 

            Multiple unlocking is not an error. Raises an exception if
            the lock file was already deleted by another process.

            After having unlocked the file the process sleeps for
            sleeptime seconds to give other processes a chance to
            acquire the lock too. If the lock will only be used every
            once in a while by the process, it is safe to set it to 0.

        Ni    s   lock file "%s" is already gonei   (   s   selfs   lockeds   unlinks   lockfilenames   errors   Errors	   sleeptimes   sleep(   s   selfs	   sleeptimes   unlinks   Errors   sleeps   error(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   unlock¢ s   
c    s=   ¿ Ä Å d |  _ Æ y Ç | |  i ƒ Wn È É n Xd S(   s/    Remove any existing lock on the file.
        i    N(   s   selfs   lockeds   unlinks   lockfilename(   s   selfs   unlink(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   remove_lock¿ s   c    s*   Ë Í d |  i i |  i t |  ƒ f Sd  S(   Ns   <%s for "%s" at %x>(   s   selfs	   __class__s   __name__s   filenames   id(   s   self(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   __repr__Ë s   (   s   __name__s
   __module__s   __doc__s   lockeds   __init__s   __del__s   times   sleeps   Errors   oss   errors   hostnames   ips   locks   unlinks   unlocks   remove_locks   __repr__(    (    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   SymbolicFileLock4 s   		-I$c     sp   Ô Ö t  d ƒ } × xP t d ƒ D× ]? }  Ø d |  GÙ | i ƒ  Ú t i |  d ƒ Û | i ƒ  q" WÝ Hd  S(   Ns	   test.locki'  s   %if100000.0(   s   SymbolicFileLocks   locks   ranges   is   times   sleeps   unlock(   s   is   lock(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   _testÔ s    	s   __main__(   s   __doc__s   ExitFunctionss   oss
   exceptionss   times   strings   Nones   _fqhostnames   hostnames   ips   StandardErrors   Errors   FileLockErrors   SymbolicFileLocks   FileLocks   _tests   __name__(   s   hostnames   strings   _fqhostnames   ips   _tests   times   SymbolicFileLocks   FileLocks   ExitFunctionss   Errors
   exceptionss   FileLockErrors   os(    (    s:   /mit/seven/lib/python2.2/site-packages/mx/Misc/FileLock.pys   ?
 s   '	ž	