§
    Ètºf!  ã                  óž  — U d Z ddlmZ ddlZddlmZmZmZ ddl	m
Z
 ddlmZmZmZ ddlmZmZ ddlmZ dd	lmZ  G d
„ de¦  «        Z ee¦  «         G d„ d¦  «        ¦   «         Z ee¦  «         G d„ d¦  «        ¦   «         Z e¦   «         Zded<    G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )z
PID file.
é    )ÚannotationsN)ÚgetpidÚkillÚname)ÚTracebackType)ÚAnyÚOptionalÚType)Ú	InterfaceÚimplementer)ÚLogger)ÚFilePathc                  óB   — e Zd ZdZdd„Zdd„Zdd„Zdd	„Zdd„Zdd„Z	dS )ÚIPIDFilez5
    Manages a file that remembers a process ID.
    ÚreturnÚintc                 ó   — dS )a+  
        Read the process ID stored in this PID file.

        @return: The contained process ID.

        @raise NoPIDFound: If this PID file does not exist.
        @raise EnvironmentError: If this PID file cannot be read.
        @raise ValueError: If this PID file's content is invalid.
        N© r   ó    úb/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/application/runner/_pidfile.pyÚreadzIPIDFile.read   ó   € € € r   ÚNonec                 ó   — dS )zŽ
        Store the PID of the current process in this PID file.

        @raise EnvironmentError: If this PID file cannot be written.
        Nr   r   r   r   ÚwriteRunningPIDzIPIDFile.writeRunningPID%   r   r   c                 ó   — dS )zm
        Remove this PID file.

        @raise EnvironmentError: If this PID file cannot be removed.
        Nr   r   r   r   ÚremovezIPIDFile.remove,   r   r   Úboolc                 ó   — dS )a  
        Determine whether there is a running process corresponding to the PID
        in this PID file.

        @return: True if this PID file contains a PID and a process with that
            PID is currently running; false otherwise.

        @raise EnvironmentError: If this PID file cannot be read.
        @raise InvalidPIDFileError: If this PID file's content is invalid.
        @raise StalePIDFileError: If this PID file's content refers to a PID
            for which there is no corresponding running process.
        Nr   r   r   r   Ú	isRunningzIPIDFile.isRunning3   r   r   ú
'IPIDFile'c                 ó   — dS )zð
        Enter a context using this PIDFile.

        Writes the PID file with the PID of the running process.

        @raise AlreadyRunningError: A process corresponding to the PID in this
            PID file is already running.
        Nr   r   r   r   Ú	__enter__zIPIDFile.__enter__A   r   r   ÚexcTypeúOptional[Type[BaseException]]ÚexcValueúOptional[BaseException]Ú	tracebackúOptional[TracebackType]úOptional[bool]c                ó   — dS )zS
        Exit a context using this PIDFile.

        Removes the PID file.
        Nr   )r$   r&   r(   s      r   Ú__exit__zIPIDFile.__exit__K   r   r   N©r   r   ©r   r   ©r   r   )r   r!   )r$   r%   r&   r'   r(   r)   r   r*   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r    r#   r,   r   r   r   r   r      s–   € € € € € ðð ð	ð 	ð 	ð 	ðð ð ð ðð ð ð ðð ð ð ðð ð ð ð	ð 	ð 	ð 	ð 	ð 	r   r   c                  ó–   — e Zd ZdZ e¦   «         Zedd„¦   «         Zdd
„Zdd„Z	dd„Z
d d„Zd d„Zd!d„Zed"d„¦   «         Zd#d„Zd$d„ZdS )%ÚPIDFilezÓ
    Concrete implementation of L{IPIDFile}.

    This implementation is presently not supported on non-POSIX platforms.
    Specifically, calling L{PIDFile.isRunning} will raise
    L{NotImplementedError}.
    Úpidr   r   Úbytesc                óJ   — t          | ¦  «        › d�                     ¦   «         S )z€
        Format a PID file's content.

        @param pid: A process ID.

        @return: Formatted PID file contents.
        ú
)r   Úencode©r6   s    r   Ú_formatzPIDFile._formatc   s"   € õ �c‘(”(ˆˆˆ×%Ò%Ñ'Ô'Ð'r   ÚfilePathúFilePath[Any]r   c                ó   — || _         dS )zD
        @param filePath: The path to the PID file on disk.
        N)r=   )Úselfr=   s     r   Ú__init__zPIDFile.__init__n   s   € ð !ˆŒˆˆr   c                óD  — d}	 | j                              ¦   «         5 }|D ]} d d d ¦  «         n# 1 swxY w Y   n7# t          $ r*}|j        t          j        k    rt          d¦  «        ‚‚ d }~ww xY w	 t          |¦  «        S # t          $ r t          d|›�¦  «        ‚w xY w)Nr   úPID file does not existz#non-integer PID value in PID file: )	r=   ÚopenÚOSErrorÚerrnoÚENOENTÚ
NoPIDFoundr   Ú
ValueErrorÚInvalidPIDFileError)r@   Ú	pidStringÚfhÚes       r   r   zPIDFile.readt   s  € Øˆ	ð	Ø”×#Ò#Ñ%Ô%ð ¨Ø!#ð ð �IØðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð øøõ ð 	ð 	ð 	ØŒw�%œ,Ò&Ð&Ý Ð!:Ñ;Ô;Ð;Øøøøøð	øøøð
	Ý�y‘>”>Ð!øÝð 	ð 	ð 	Ý%ØC°iÐCÐCñô ð ð	øøøs9   „; �/£; ¯3³; ¶3·; »
A/Á%A*Á*A/Á3B ÂBc                ób   — | j                              |                      |¬¦  «        ¦  «         dS )zš
        Store a PID in this PID file.

        @param pid: A PID to store.

        @raise EnvironmentError: If this PID file cannot be written.
        r;   N)r=   Ú
setContentr<   ©r@   r6   s     r   Ú_writezPIDFile._write†   s.   € ð 	Œ× Ò  §¢°# Ñ!6Ô!6Ñ7Ô7Ð7Ð7Ð7r   c                óH   — |                       t          ¦   «         ¦  «         d S ©N)rQ   r   ©r@   s    r   r   zPIDFile.writeRunningPID�   s   € Ø�Š•F‘H”HÑÔÐÐÐr   c                ó8   — | j                              ¦   «          d S rS   )r=   r   rT   s    r   r   zPIDFile.remove“   s   € ØŒ×ÒÑÔÐÐÐr   r   c                ó¾   — 	 |                       ¦   «         }n# t          $ r Y dS w xY wt          dk    r|                      |¦  «        S t	          dt          › �¦  «        ‚)NFÚposixz isRunning is not implemented on )r   rH   ÚSYSTEM_NAMEÚ_pidIsRunningPOSIXÚNotImplementedErrorrP   s     r   r    zPIDFile.isRunning–   sp   € ð	Ø—)’)‘+”+ˆCˆCøÝð 	ð 	ð 	Ø�5�5ð	øøøõ ˜'Ò!Ð!Ø×*Ò*¨3Ñ/Ô/Ð/å%Ð&VÍÐ&VÐ&VÑWÔWÐWs   ‚ —
%¤%c                óÌ   — 	 t          | d¦  «         dS # t          $ rE}|j        t          j        k    rt	          d¦  «        ‚|j        t          j        k    rY d}~dS ‚ d}~ww xY w)a1  
        POSIX implementation for running process check.

        Determine whether there is a running process corresponding to the given
        PID.

        @param pid: The PID to check.

        @return: True if the given PID is currently running; false otherwise.

        @raise EnvironmentError: If this PID file cannot be read.
        @raise InvalidPIDFileError: If this PID file's content is invalid.
        @raise StalePIDFileError: If this PID file's content refers to a PID
            for which there is no corresponding running process.
        r   Tz'PID file refers to non-existing processN)r   rE   rF   ÚESRCHÚStalePIDFileErrorÚEPERM)r6   rM   s     r   rY   zPIDFile._pidIsRunningPOSIX¡   sy   € ð"
	Ý��a‰LŒLˆLð �4øõ ð 	ð 	ð 	ØŒw�%œ+Ò%Ð%Ý'Ð(QÑRÔRÐRØ”�EœKÒ'Ð'Ø�t�t�t�t�tàøøøøð	øøøs   ‚ ”
A#ž9AÁAÁA#ú	'PIDFile'c                óÊ   — 	 |                       ¦   «         rt          ¦   «         ‚n*# t          $ r | j                             d¦  «         Y nw xY w|                      ¦   «          | S )Nz&Replacing stale PID file: {log_source})r    ÚAlreadyRunningErrorr]   Ú_logÚinfor   rT   s    r   r#   zPIDFile.__enter__¾   s|   € ð	EØ�~Š~ÑÔð ,Ý)Ñ+Ô+Ð+ð,øå ð 	Eð 	Eð 	EØŒI�NŠNÐCÑDÔDÐDÐDÐDð	Eøøøà×ÒÑÔÐØˆs   ‚"% ¥$AÁAr$   r%   r&   r'   r(   r)   c                ó.   — |                       ¦   «          d S rS   )r   ©r@   r$   r&   r(   s       r   r,   zPIDFile.__exit__Ç   s   € ð 	�Š‰ŒˆØˆtr   N)r6   r   r   r7   )r=   r>   r   r   r-   ©r6   r   r   r   r.   r/   )r6   r   r   r   )r   r_   ©r$   r%   r&   r'   r(   r)   r   r   )r0   r1   r2   r3   r   rb   Ústaticmethodr<   rA   r   rQ   r   r   r    rY   r#   r,   r   r   r   r5   r5   W   s  € € € € € ðð ð ˆ6‰8Œ8€Dàð(ð (ð (ñ „\ð(ð!ð !ð !ð !ðð ð ð ð$8ð 8ð 8ð 8ðð ð ð ðð ð ð ð	Xð 	Xð 	Xð 	Xð ðð ð ñ „\ðð8ð ð ð ðð ð ð ð ð r   r5   c                  óR   — e Zd ZdZdd„Zdd„Zdd„Zdd	„Zdd
„Zdd„Z	dd„Z
dd„ZdS )ÚNonePIDFilez¤
    PID file implementation that does nothing.

    This is meant to be used as a "active None" object in place of a PID file
    when no PID file is desired.
    r   r   c                ó   — d S rS   r   rT   s    r   rA   zNonePIDFile.__init__Ú   s   € Øˆr   r   c                ó    — t          d¦  «        ‚)NrC   )rH   rT   s    r   r   zNonePIDFile.readÝ   s   € ÝÐ2Ñ3Ô3Ð3r   r6   c                ó6   — t          t          j        d¦  «        ‚)zä
        Store a PID in this PID file.

        @param pid: A PID to store.

        @raise EnvironmentError: If this PID file cannot be written.

        @note: This implementation always raises an L{EnvironmentError}.
        zOperation not permitted)rE   rF   r^   rP   s     r   rQ   zNonePIDFile._writeà   s   € õ •e”kÐ#<Ñ=Ô=Ð=r   c                ó0   — |                       d¦  «         d S )Nr   )rQ   rT   s    r   r   zNonePIDFile.writeRunningPIDì   s   € Ø�Š�A‰Œˆˆˆr   c                ó6   — t          t          j        d¦  «        ‚)NzNo such file or directory)rE   rF   rG   rT   s    r   r   zNonePIDFile.removeï   s   € Ý•e”lÐ$?Ñ@Ô@Ð@r   r   c                ó   — dS )NFr   rT   s    r   r    zNonePIDFile.isRunningò   s   € Øˆur   ú'NonePIDFile'c                ó   — | S rS   r   rT   s    r   r#   zNonePIDFile.__enter__õ   s   € Øˆr   r$   r%   r&   r'   r(   r)   c                ó   — d S rS   r   re   s       r   r,   zNonePIDFile.__exit__ø   s	   € ð ˆtr   Nr.   r-   rf   r/   )r   rq   rg   )r0   r1   r2   r3   rA   r   rQ   r   r   r    r#   r,   r   r   r   rj   rj   Ñ   sÂ   € € € € € ðð ðð ð ð ð4ð 4ð 4ð 4ð
>ð 
>ð 
>ð 
>ðð ð ð ðAð Að Að Aðð ð ð ðð ð ð ðð ð ð ð ð r   rj   ÚnonePIDFilec                  ó   — e Zd ZdZdS )ra   z%
    Process is already running.
    N©r0   r1   r2   r3   r   r   r   ra   ra     ó   € € € € € ðð ð ð r   ra   c                  ó   — e Zd ZdZdS )rJ   z(
    PID file contents are invalid.
    Nrv   r   r   r   rJ   rJ   
  rw   r   rJ   c                  ó   — e Zd ZdZdS )r]   z[
    PID file contents are valid, but there is no process with the referenced
    PID.
    Nrv   r   r   r   r]   r]     s   € € € € € ðð ð ð r   r]   c                  ó   — e Zd ZdZdS )rH   z#
    No PID found in PID file.
    Nrv   r   r   r   rH   rH     rw   r   rH   ) r3   Ú
__future__r   rF   Úosr   r   r   rX   Útypesr   Útypingr   r	   r
   Úzope.interfacer   r   Útwisted.loggerr   Útwisted.python.filepathr   r   r5   rj   rt   Ú__annotations__Ú	Exceptionra   rJ   r]   rH   r   r   r   ú<module>r„      s9  ðð
ð ð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1à !Ð !Ð !Ð !Ð !Ð !Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,ð?ð ?ð ?ð ?ð ?ˆyñ ?ô ?ð ?ðD €ˆXÑÔðvð vð vð vð vñ vô vñ Ôðvðr €ˆXÑÔð,ð ,ð ,ð ,ð ,ñ ,ô ,ñ Ôð,ð^ $˜™œ€Ð %Ð %Ð %Ñ %ðð ð ð ð ˜)ñ ô ð ðð ð ð ð ˜)ñ ô ð ðð ð ð ð ˜	ñ ô ð ðð ð ð ð �ñ ô ð ð ð r   