§
    Ètºf*  ã                   ó  — d Z ddlZddlZddlmZ ddlmZ d„ ZddlmZ  ej	        ¦   «         sddlm
Z
mZmZmZ dZn-d	Z	 ddlZdd
lmZ dZdZd„ Z
n# e$ r dZ
Y nw xY weZd„ Zd„ Zd„ Z G d„ d¦  «        Zd„ ZddgZdS )z&
Filesystem-based interprocess mutex.
é    N)Útime)Úplatformc                  óX   — t          t          t          ¦   «         dz  ¦  «        ¦  «        S )Niè  )ÚstrÚintÚ_uniquefloat© ó    úV/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/python/lockfile.pyÚuniquer      s!   € Ý�s•<‘>”> DÑ(Ñ)Ô)Ñ*Ô*Ð*r
   )Úrename)ÚkillÚreadlinkÚremoveÚsymlinkFT)ÚOpenProcessé   éW   c                 ó  — 	 t          dd| ¦  «         t          d¦  «        ‚# t          j        $ rR}|j        d         t
          k    rY d }~d S |j        d         t          k    rt          t          j	        d ¦  «        ‚‚ d }~ww xY 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   s•   € ð	GÝ˜A˜q #Ñ&Ô&Ð&õ #Ð#EÑFÔFÐFøõ Ô#ð ð ð Ø”6˜!”9Õ 3Ò3Ð3Ø�F�F�F�F�FØ”V˜A”YÕ"9Ò9Ð9Ý!¥%¤+¨tÑ4Ô4Ð4Øøøøøðøøøs   ‚" ¢B±A>Á1A>Á>Bc                 óÒ  — |dz   t          ¦   «         z   dz   }t          j                             |d¦  «        }t          j        |¦  «         d}t          ||¦  «        5 }|                     | ¦  «         |                     ¦   «          ddd¦  «         n# 1 swxY w Y   	 t          ||¦  «         dS # t          $ r* t          j
        |¦  «         t          j        |¦  «         ‚ w xY 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¤xÑ/°*Ñ<ˆÝ”W—\’\ +¨yÑ9Ô9ˆ
Ý
Œ�ÑÔÐð ˆå�:˜tÑ$Ô$ð 	¨Ø�GŠG�E‰NŒNˆNØ�GŠG‰IŒIˆIð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð	Ý�; Ñ)Ô)Ð)Ð)Ð)øÝð 	ð 	ð 	ÝŒI�jÑ!Ô!Ð!ÝŒH�[Ñ!Ô!Ð!Øð	øøøs   Á*BÂBÂBÂ B2 Â24C&c                 ód  — 	 t          t          j                             | d¦  «        d¦  «        }|5  |                     ¦   «         }ddd¦  «         n# 1 swxY w Y   |S # t
          $ rE}|j        t          j        k    s|j        t          j        k    rt          |j        d¦  «        ‚‚ d}~ww xY w)zq
        Read the contents of C{filename}. See the above comment block as to why
        this is needed.
        r   ÚrN)	r)   r%   r&   r'   Úreadr   r   ÚENOENTÚEIO)r/   ÚfObjÚresultr!   s       r   r   r   `   sè   € ð
		Ý�œŸš h°	Ñ:Ô:¸CÑ@Ô@ˆDð ð %ð %ØŸš™œ�ð%ð %ð %ñ %ô %ð %ð %ð %ð %ð %ð %øøøð %ð %ð %ð %àˆMøõ ð 	ð 	ð 	ØŒw�%œ,Ò&Ð&¨!¬'µU´YÒ*>Ð*>Ý˜aœg tÑ,Ô,Ð,Øøøøøð	øøøs)   ‚.A  ²AÁAÁAÁ 
B/Á*A B*Â*B/c                 ó’   — t          j        t           j                             | d¦  «        ¦  «         t          j        | ¦  «         d S )Nr   )r%   r   r&   r'   r-   )r/   s    r   Úrmlinkr<   r   s8   € Ý
Œ	•"”'—,’,˜x¨Ñ3Ô3Ñ4Ô4Ð4Ý
Œ�ÑÔÐÐÐr
   c                   ó,   — e Zd ZdZdZdZd„ Zd„ Zd„ ZdS )ÚFilesystemLocka  
    A mutex.

    This relies on the filesystem property that creating
    a symlink is an atomic operation and that it will
    fail if the symlink already exists.  Deleting the
    symlink will release the lock.

    @ivar name: The name of the file associated with this lock.

    @ivar clean: Indicates whether this lock was released cleanly by its
        last owner.  Only meaningful after C{lock} has been called and
        returns True.

    @ivar locked: Indicates whether the lock is currently held by this
        object.
    NFc                 ó   — || _         d S )N)Úname)Úselfr@   s     r   Ú__init__zFilesystemLock.__init__�   s   € ØˆŒ	ˆ	ˆ	r
   c                 ór  — d}	 	 t          t          t          j        ¦   «         ¦  «        | j        ¦  «         �no# t
          $ �ra}t          r%|j        t          j        t          j	        fv rY d}~dS |j        t          j
        k    �r	 t          | j        ¦  «        }nW# t
          $ rJ}|j        t          j        k    r	Y d}~Y d}~ŒÂt          r|j        t          j        k    r
Y d}~Y d}~dS ‚ d}~ww xY w	 t          �t          t          |¦  «        d¦  «         n€# t
          $ rs}|j        t          j        k    rX	 t!          | j        ¦  «         n6# t
          $ r)}|j        t          j        k    rY d}~Y d}~Y d}~�Œy‚ d}~ww xY wd}Y d}~Y d}~�ŒŽ‚ d}~ww xY wY d}~dS ‚ d}~ww xY wd| _        || _        dS )zç
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise OSError: Any exception L{os.symlink()} may raise,
            other than L{errno.EEXIST}.
        TNFr   )r   r   r%   Úgetpidr@   r   Ú_windowsr   ÚEACCESr8   ÚEEXISTr   r7   r   r   r   r<   ÚlockedÚclean)rA   rI   r!   r   s       r   ÚlockzFilesystemLock.lock�   s  € ð ˆð0	ð,Ý��BœI™KœKÑ(Ô(¨$¬)Ñ4Ô4Ð4Ñ4øÝð *ñ *ð *Ýð ! ¤­E¬L½%¼)Ð+DÐ DÐ Dð !˜5˜5˜5˜5˜5Ø”7�eœlÒ*Ñ*ðÝ& t¤yÑ1Ô1˜˜øÝ"ð ð ð Øœ7¥e¤lÒ2Ð2ð %˜H˜H˜H˜H˜H˜H˜H˜HÝ%ð )¨!¬'µU´\Ò*AÐ*Að $) 5 5 5 5 5 5 5 5 5ØøøøøðøøøðÝÐ+Ý ¥ S¡¤¨1Ñ-Ô-Ð-øøÝ"ð ð ð Øœ7¥e¤kÒ1Ð1ð&Ý & t¤yÑ 1Ô 1Ð 1Ð 1øÝ#*ð &ð &ð &Ø#$¤7­e¬lÒ#:Ð#:ð %- H H H H H H H H H H H¡HØ %øøøøð&øøøð %*˜EØ$˜H˜H˜H˜H˜H˜H˜H™HØøøøøðøøøð  !˜5˜5˜5˜5˜5ØøøøøðU*øøøðV ˆDŒKØˆDŒJØ�4sÃ   …3: ºF&Á&F!Á1F!ÂBÂF!Â
C1Â'C,Â<F!ÃC,Ã!F!Ã+C,Ã,C1Ã1F!Ã5$DÄF!Ä
FÄ$FÄ:EÅFÅ
FÅE=Å.FÅ2F!Å<E=Å=FÆFÆF!ÆFÆFÆF!Æ F!Æ!F&c                 óÜ   — t          | j        ¦  «        }t          |¦  «        t          j        ¦   «         k    rt          d| j        ›d�¦  «        ‚t          | j        ¦  «         d| _        dS )zå
        Release this lock.

        This deletes the directory with the given name.

        @raise OSError: Any exception L{os.readlink()} may raise.
        @raise ValueError: If the lock is not owned by this process.
        zLock z not owned by this processFN)r   r@   r   r%   rD   Ú
ValueErrorr<   rH   )rA   r   s     r   ÚunlockzFilesystemLock.unlockÍ   sa   € õ �t”yÑ!Ô!ˆÝˆs‰8Œ8•r”y‘{”{Ò"Ð"ÝÐL T¤YÐLÐLÐLÑMÔMÐMÝˆtŒyÑÔÐØˆŒˆˆr
   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__rI   rH   rB   rJ   rM   r	   r
   r   r>   r>   w   sX   € € € € € ðð ð$ €EØ€Fðð ð ð;ð ;ð ;ðzð ð ð ð r
   r>   c                 óº   — t          | ¦  «        }d}	 |                     ¦   «         }|r|                     ¦   «          n# |r|                     ¦   «          w w xY w| S )zß
    Determine if the lock of the given name is held or not.

    @type name: C{str}
    @param name: The filesystem path to the lock to test

    @rtype: C{bool}
    @return: True if the lock is held, False otherwise.
    N)r>   rJ   rM   )r@   Úlr:   s      r   ÚisLockedrT   Ý   sh   € õ 	�tÑÔ€AØ€FðØ—’‘”ˆàð 	Ø�HŠH‰JŒJˆJøøð ð 	Ø�HŠH‰JŒJˆJˆJð	øøøàˆ:Ðs	   “> ¾ArT   )rQ   r   r%   r   r   Útwisted.python.runtimer   r   r   Ú	isWindowsr   r   r   r<   r   rE   r   Úwin32apir   r   r   ÚImportErrorÚopenr)   r>   rT   Ú__all__r	   r
   r   ú<module>r[      s¢  ððð ð
 €€€Ø 	€	€	€	Ø %Ð %Ð %Ð %Ð %Ð %à +Ð +Ð +Ð +Ð +Ð +ð+ð +ð +ð Ð Ð Ð Ð Ð à€xÔÑÔð \Ø<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<à€H€Hà€HðGØÐÐÐØ(Ð(Ð(Ð(Ð(Ð(ð  ÐØ"$Ðð
	Gð 
	Gð 
	Gð 
	Gøð ð ð ð Øˆˆˆðøøøð* €Eðð ð ð6ð ð ð$ð ð ð
cð cð cð cð cñ cô cð cðLð ð ð( ˜ZÐ
(€€€s   Á
A ÁAÁA