ó
    Ö›‘h!  ã                  óT  • % S r SSKJr  SSKrSSKJrJrJr  SSK	J
r
  SSKJrJrJr  SSKJrJr  SSKJr  SS	KJr   " S
 S\5      r\" \5       " S S5      5       r\" \5       " S S5      5       r\" 5       rS\S'    " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)z
PID file.
é    )ÚannotationsN)ÚgetpidÚkillÚname)ÚTracebackType)ÚAnyÚOptionalÚType)Ú	InterfaceÚimplementer)ÚLogger)ÚFilePathc                  ód   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	        SS jr
S	rg
)ÚIPIDFileé   z-
Manages a file that remembers a process ID.
c                 ó   • g)zû
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   ó    ÚgC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/application/runner/_pidfile.pyÚreadÚIPIDFile.read   ó   � r   c                 ó   • g)zv
Store the PID of the current process in this PID file.

@raise EnvironmentError: If this PID file cannot be written.
Nr   r   r   r   ÚwriteRunningPIDÚIPIDFile.writeRunningPID%   r   r   c                 ó   • g)zU
Remove this PID file.

@raise EnvironmentError: If this PID file cannot be removed.
Nr   r   r   r   ÚremoveÚIPIDFile.remove,   r   r   c                 ó   • g)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   Ú	isRunningÚIPIDFile.isRunning3   r   r   c                 ó   • g)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__ÚIPIDFile.__enter__A   r   r   c                ó   • g)z;
Exit a context using this PIDFile.

Removes the PID file.
Nr   )ÚexcTypeÚexcValueÚ	tracebacks      r   Ú__exit__ÚIPIDFile.__exit__K   r   r   r   N©ÚreturnÚint©r,   ÚNone©r,   Úbool)r,   z
'IPIDFile')r&   úOptional[Type[BaseException]]r'   úOptional[BaseException]r(   úOptional[TracebackType]r,   zOptional[bool])Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r    r#   r)   Ú__static_attributes__r   r   r   r   r      sI   † ñô	ôôôôð	Ø.ð	à)ð	ð +ð	ð 
÷		r   r   c                  ó®   • \ rS rSrSr\" 5       r\SS j5       rSS jr	SS jr
SS jrSS jrSS jrSS	 jr\SS
 j5       rSS jr        SS jrSrg)ÚPIDFileéW   z¿
Concrete implementation of L{IPIDFile}.

This implementation is presently not supported on non-POSIX platforms.
Specifically, calling L{PIDFile.isRunning} will raise
L{NotImplementedError}.
c                ó:   • [        U 5       S3R                  5       $ )z`
Format a PID file's content.

@param pid: A process ID.

@return: Formatted PID file contents.
Ú
)r-   Úencode©Úpids    r   Ú_formatÚPIDFile._formatc   s   € ô �c“(�˜2ˆ×%Ñ%Ó'Ð'r   c                ó   • Xl         g)z4
@param filePath: The path to the PID file on disk.
N©ÚfilePath)ÚselfrG   s     r   Ú__init__ÚPIDFile.__init__n   s	   € ð !�r   c                óL  • Sn U R                   R                  5        nU H  n  O   S S S 5         [        U5      $ ! , (       d  f       N= f! [         a/  nUR                  [        R                  :X  a  [        S5      ee S nAff = f! [         a    [        SU< 35      ef = f)Nr   úPID file does not existz#non-integer PID value in PID file: )	rG   ÚopenÚOSErrorÚerrnoÚENOENTÚ
NoPIDFoundr-   Ú
ValueErrorÚInvalidPIDFileError)rH   Ú	pidStringÚfhÚes       r   r   ÚPIDFile.readt   sŸ   € Øˆ	ð	Ø—‘×#Ñ#Ô%¨Û!#�IÙñ "$÷ &ð	Ü�y“>Ð!÷ &Õ%ûô ó 	Ø�w‰wœ%Ÿ,™,Ó&Ü Ð!:Ó;Ð;Øûð	ûô ó 	Ü%Ø5°i±]ÐCóð ð	ús<   „A ž
<¨A ±
B	 ¼
A
ÁA Á
A Á
BÁ*BÂBÂ	B#c                óT   • U R                   R                  U R                  US95        g)zz
Store a PID in this PID file.

@param pid: A PID to store.

@raise EnvironmentError: If this PID file cannot be written.
rA   N)rG   Ú
setContentrC   ©rH   rB   s     r   Ú_writeÚPIDFile._write†   s!   € ð 	�‰× Ñ  §¡°# Ð!6Õ7r   c                ó6   • U R                  [        5       5        g ©N)r[   r   ©rH   s    r   r   ÚPIDFile.writeRunningPID�   s   € Ø�‰”F“HÕr   c                ó8   • U R                   R                  5         g r^   )rG   r   r_   s    r   r   ÚPIDFile.remove“   s   € Ø�‰×ÑÕr   c                óž   •  U R                  5       n[        S:X  a  U R                  U5      $ [	        S[         35      e! [         a     gf = f)NFÚposixz isRunning is not implemented on )r   rQ   ÚSYSTEM_NAMEÚ_pidIsRunningPOSIXÚNotImplementedErrorrZ   s     r   r    ÚPIDFile.isRunning–   sT   € ð	Ø—)‘)“+ˆCô ˜'Ó!Ø×*Ñ*¨3Ó/Ð/ä%Ð(HÌÈÐ&VÓWÐWøô ó 	Ùð	ús   ‚? ¿
AÁAc                óÜ   •  [        U S5        g! [         aR  nUR                  [        R                  :X  a  [	        S5      eUR                  [        R
                  :X  a   SnAge SnAff = f)aá  
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   rN   rO   ÚESRCHÚStalePIDFileErrorÚEPERM)rB   rV   s     r   rf   ÚPIDFile._pidIsRunningPOSIX¡   sY   € ð"
	Ü��aŒLð øô ó 	Ø�w‰wœ%Ÿ+™+Ó%Ü'Ð(QÓRÐRØ—‘œEŸK™KÓ'Üàûð	ús   ‚ �
A+™AA&Á%A&Á&A+c                ó¾   •  U R                  5       (       a
  [        5       e U R                  5         U $ ! [         a    U R                  R	                  S5         N9f = f)Nz&Replacing stale PID file: {log_source})r    ÚAlreadyRunningErrorrk   Ú_logÚinfor   r_   s    r   r#   ÚPIDFile.__enter__¾   sZ   € ð	EØ�~‰~×ÑÜ)Ó+Ð+ð  ð 	×ÑÔØˆøô !ó 	EØ�I‰I�N‰NÐCÖDð	Eús   ‚4 ´%AÁAc                ó$   • U R                  5         g r^   )r   ©rH   r&   r'   r(   s       r   r)   ÚPIDFile.__exit__Ç   s   € ð 	�‰ŒØr   rF   N)rB   r-   r,   Úbytes)rG   zFilePath[Any]r,   r/   r+   ©rB   r-   r,   r/   r.   r0   )rB   r-   r,   r1   )r,   z	'PIDFile'©r&   r2   r'   r3   r(   r4   r,   r/   )r5   r6   r7   r8   r9   r   rp   ÚstaticmethodrC   rI   r   r[   r   r   r    rf   r#   r)   r:   r   r   r   r<   r<   W   s…   † ññ ‹8€Dàó(ó ð(ô!ôô$8ôôô	Xð óó ðô8ðà.ðð *ðð +ð	ð
 
÷r   r<   c                  óx   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jr        SS
 jrSrg)ÚNonePIDFileéÑ   z”
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.
c                ó   • g r^   r   r_   s    r   rI   ÚNonePIDFile.__init__Ú   s   € Ør   c                ó   • [        S5      e)NrL   )rQ   r_   s    r   r   ÚNonePIDFile.readÝ   s   € ÜÐ2Ó3Ð3r   c                ó6   • [        [        R                  S5      e)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)rN   rO   rl   rZ   s     r   r[   ÚNonePIDFile._writeà   s   € ô ”e—k‘kÐ#<Ó=Ð=r   c                ó&   • U R                  S5        g )Nr   )r[   r_   s    r   r   ÚNonePIDFile.writeRunningPIDì   s   € Ø�‰�A�r   c                ó6   • [        [        R                  S5      e)NzNo such file or directory)rN   rO   rP   r_   s    r   r   ÚNonePIDFile.removeï   s   € Ü”e—l‘lÐ$?Ó@Ð@r   c                ó   • g)NFr   r_   s    r   r    ÚNonePIDFile.isRunningò   s   € Ør   c                ó   • U $ r^   r   r_   s    r   r#   ÚNonePIDFile.__enter__õ   s   € Øˆr   c                ó   • g r^   r   rt   s       r   r)   ÚNonePIDFile.__exit__ø   s   € ð r   r   Nr.   r+   rw   r0   )r,   z'NonePIDFile'rx   )r5   r6   r7   r8   r9   rI   r   r[   r   r   r    r#   r)   r:   r   r   r   r{   r{   Ñ   sV   † ñôô4ô
>ôôAôôðà.ðð *ðð +ð	ð
 
÷r   r{   ÚnonePIDFilec                  ó   • \ rS rSrSrSrg)ro   i  z
Process is already running.
r   N©r5   r6   r7   r8   r9   r:   r   r   r   ro   ro     ó   † ôr   ro   c                  ó   • \ rS rSrSrSrg)rS   i
  z 
PID file contents are invalid.
r   Nr�   r   r   r   rS   rS   
  r�   r   rS   c                  ó   • \ rS rSrSrSrg)rk   i  zO
PID file contents are valid, but there is no process with the referenced
PID.
r   Nr�   r   r   r   rk   rk     s   † ôr   rk   c                  ó   • \ rS rSrSrSrg)rQ   i  z
No PID found in PID file.
r   Nr�   r   r   r   rQ   rQ     r�   r   rQ   ) r9   Ú
__future__r   rO   Úosr   r   r   re   Útypesr   Útypingr   r	   r
   Úzope.interfacer   r   Útwisted.loggerr   Útwisted.python.filepathr   r   r<   r{   r�   Ú__annotations__Ú	Exceptionro   rS   rk   rQ   r   r   r   Ú<module>r�      s¶   ðò
õ #ã ß 0Ñ 0Ý ß &Ñ &ç 1å !Ý ,ô?ˆyô ?ñD ˆXÓ÷vð vó ðvñr ˆXÓ÷,ð ,ó ð,ñ^ $›€ˆXÓ %ô˜)ô ô˜)ô ô˜	ô ô�õ r   