+
    õÉÍjU1  ã                   óò   € ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
Ht ^ RIHtHtHtHt ^ RIHt ]P&                  ! ]4      t ! R R]4      t ! R R	]4      tR
 tR t ! R R4      tR# )é    N)ÚPath)ÚNamedTemporaryFile)ÚOptionalÚDictÚUnionÚList)ÚTeaErrorc                   ó   € ] tR t^tRtR# )ÚProcessError© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚI/opt/data/home/.local/lib/python3.14/site-packages/tea/process/process.pyr   r      s   † Ûr   r   c                   ó2   a a€ ] tR t^t oV 3R ltRtVtV ;t# )ÚExecutableNotFoundc                ó:   <€ Wn         \        SV `	  R V 2R7       R# )zExecutable not found: )ÚmessageN)ÚcommandÚsuperÚ__init__)Úselfr   Ú	__class__s   &&€r   r   ÚExecutableNotFound.__init__   s    ø€ ØŒÜ‰ÑÐ#9¸'¸Ð!CÐÖDr   ©r   )r   r   r   r   r   r   Ú__classdictcell__Ú__classcell__)r   Ú__classdict__s   @@r   r   r      s   ù‡ € ÷Eõ Er   r   c           
      ó:  € \         P                  P                  4        UUu/ uF  w  r\        V4      \        V4      bK  	  pppV eG   TP	                  V P                  4        UUu/ uF  w  r\        V4      \        V4      bK  	  upp4       V# u uppi u uppi ©N)ÚosÚenvironÚitemsÚstrÚupdate)ÚenvÚkeyÚvalueÚfull_envs   &   r   Ú_create_envr-      sw   € Ü79·z±z×7GÑ7GÔ7IÔJÑ7I©¨”�C“œ#˜e›*Ò$Ñ7I€HÑJØ
‚Ø�‰ÀÇ	Á	ÄÔLÁ±*°#œ˜S›¤3 u£:Ò-ÁÒLÔMØ€Oùó KùãLs   ¢ BÁ' B
c                óÔ   € V \         P                  ! V 4      8X  d(   \        P                  ! V \        P
                  4       R# \        P                  ! V \        P
                  4       R# )z]Kills a process by it's process ID.

Args:
    pid (int): Process ID of the process to kill.
N)ÚposixÚgetpgidr$   ÚkillpgÚsignalÚSIGKILLÚkill)Úpids   &r   r4   r4   $   s9   € ð Œe�mŠm˜CÓ Ô Ü
�	Š	�#”v—~‘~Ö&ä
�Š�”V—^‘^Ö$r   c                   ó<  a € ] tR t^0t o RtRV 3R lR lltR tR tR tR t	R	 t
]R
 4       t]R 4       t]R 4       t]R 4       tR tR tR V 3R lR llt]R 4       t]R 4       t]V 3R lR l4       tV 3R lR ltV 3R lR ltV 3R lR ltR tR t]tRtV tR# )!ÚProcessa3  Process class.

Simple example of Process class usage can be::

    >>> from tea.process import Process
    >>> p = Process('python', ['-c', 'import time;time.sleep(5);print(3)'])
    >>> p.start()
    >>> p.is_running
    True
    >>> p.wait()
    True
    >>> p.read()
    '3\\n'
    >>> p.eread()
    ''
Nc                óþ   <€ V ^8„  d   QhRS[ S[S[S[,          3,          RS[S[S[S[3,          ,          RS[S[ S[S[3,          ,          RS[RS[S[ S[S[3,          ,          RS[RS[RS[R	S[S[,          R
S[/
# )é   r   r)   ÚstdoutÚstdout_modeÚstderrÚstderr_modeÚdemuxÚredirect_outputÚworking_dirÚencoding)r   r'   r   r   r   r   Úbool)Úformatr!   s   "€r   Ú__annotate__ÚProcess.__annotate__B   sµ   ø€ ÷ H#ñ H#á‘s™D¡�I�~Õ&ðH#ñ ‘d™3¡˜8•nÕ%ðH#ñ ™™s¡D˜yÕ)Õ*ð	H#ñ
 ðH#ñ ™™s¡D˜yÕ)Õ*ðH#ñ ðH#ñ ðH#ñ ðH#ñ ™c•]ðH#ñ ñH#r   c                óF  € \        V\        4      '       d   V.MTV n        W n        RV n        RV n        RV n        RV n        W�n        Wpn	        T;'       g    T;'       g    TV n
        W n        RV n        VR9  d   \        R4      hW@n        RV n        V'       d   \!        V4      P#                  4       MRV n        RV n        RV n        VR9  d   \        R4      hW`n        RV n        V'       d   \!        V4      P#                  4       MRV n        RV n        RV n        R# )a¿  Create a Process object.

The only required parameter is the command to execute. It's important
to note that the constructor only initializes the class, it doesn't
executes the process. To actually execute the process you have to call
the `start` method.

Args:
    command: Path to the executable file or a list with the full
        command and it's arguments.
    env: Optional additional environment variables that will be added
        to the subprocess environment or that override currently set
        environment variables.
    stdout: Path to the file to which standard output would be
        redirected.
    stdout_mode: Open stdout file in `w` write or `a` append mode.
    stderr: Path to the file to which standard error would be
        redirected.
    stderr_mode: Open stderr file in `w` write or `a` append mode.
    demux: Demux stdout and stderr. Default: `True`. If demux is set to
        `False` `eread` will always return an empty string and all
        stderr will be redirected to stdout.
    redirect_output: `True` if you want to be able to get the standard
        output and the standard error of the subprocess, otherwise it
        will be redirected to /dev/null. If stdout or stderr are
        provided redirect_output will automatically be set to `True`.
    working_dir: Set the working directory from which the process will
        be started.
    encoding: Encoding to use to decode the standard output and
        standard error.
NFz$stdout_mode can be either `w` or `a`z$stderr_mode can be either `w` or `a`)ÚwÚa)Ú
isinstancer'   Ú_commandlineÚ_envÚ_processÚ_wait_threadÚ_pidÚ
_immutableÚ_working_dirÚ_demuxÚ_redirect_outputÚ	_encodingÚ_stdinr   Ú_stdout_modeÚ_stdout_tmpr   ÚabsoluteÚ_stdoutÚ_stdout_readerÚ_stdout_writerÚ_stderr_modeÚ_stderr_tmpÚ_stderrÚ_stderr_readerÚ_stderr_writer)r   r   r)   r:   r;   r<   r=   r>   r?   r@   rA   s   &&&&&&&&&&&r   r   ÚProcess.__init__B   s  € ôX *4°G¼S×)AÒ)A˜W™IÀwˆÔØŒ	ØˆŒØ ˆÔØˆŒ	ØˆŒØ'ÔàŒØ &× CÐ C¨&× CÐ C°OˆÔØ!ŒàˆŒà˜jÔ(ÜÐEÓFÐFØ'ÔØˆÔß28”t˜F“|×,Ñ,Ô.¸dˆŒØ"ˆÔØ"ˆÔà˜jÔ(ÜÐEÓFÐFØ'ÔØˆÔß28”t˜F“|×,Ñ,Ô.¸dˆŒØ"ˆÔØ"ˆÖr   c                ó\  € V P                   '       EdÚ   \        P                  V n        V P                  '       d_   \
        P                  ! V P                  V P                  R ,           4      V n        \
        P                  ! V P                  R4      V n	        M\\        RR7      V n        V P                  P                  V n        \
        P                  ! V P                  P                  R4      V n	        V P                  '       dÐ   V P                  '       d`   \
        P                  ! V P                  V P                   R ,           4      V n        \
        P                  ! V P                  R4      V n        R# \        RR7      V n        V P&                  P                  V n        \
        P                  ! V P&                  P                  R4      V n        R# \        P(                  V n        R# \
        P                  ! \*        P,                  R4      V n        \        P(                  V n        R# )ÚbÚrbÚwb)ÚmodeN)rR   Ú
subprocessÚPIPErT   rX   ÚioÚopenrU   rZ   rY   r   rV   ÚfileÚnamerQ   r]   r[   r_   r^   r\   ÚSTDOUTr$   Údevnull©r   s   &r   Ú__open_filesÚProcess.__open_filesŒ   sc  € Ø× × Ñ ä$Ÿ/™/ˆDŒKà�|�|ˆ|Ü&(§g¢gØ—L‘L $×"3Ñ"3°cÕ"9ó'�Ô#ô ')§g¢g¨d¯l©l¸DÓ&A�Õ#ä#5¸4Ô#@�Ô Ø&*×&6Ñ&6×&;Ñ&;�Ô#Ü&(§g¢g¨d×.>Ñ.>×.CÑ.CÀTÓ&J�Ô#à�{�{ˆ{Ø—<—<�<Ü*,¯'ª'ØŸ™ d×&7Ñ&7¸#Õ&=ó+�DÔ'ô +-¯'ª'°$·,±,ÀÓ*E�DÖ'ä'9¸tÔ'D�DÔ$Ø*.×*:Ñ*:×*?Ñ*?�DÔ'Ü*,¯'ª'°$×2BÑ2B×2GÑ2GÈÓ*N�DÖ'ä&0×&7Ñ&7�Ö#ä"$§'¢'¬"¯*©*°dÓ";ˆDÔÜ",×"3Ñ"3ˆDÖr   c                ód   € VR J;'       d&    \        VR4      ;'       d    VP                  '       * # )NÚclosed)Úhasattrrr   )r   Úfs   &&r   Ú	__is_openÚProcess.__is_open«   s)   € Ø˜ˆ}×FÐF¤¨¨HÓ!5×FÐF¸a¿h¹h¼,ÐFr   c                ó
  € V P                  V P                  4      '       d   V P                  P                  4        V P                  V P                  4      '       d   V P                  P                  4        V P                  V P
                  4      '       d   V P
                  P                  4        V P                  '       d@   V P                  V P                  4      '       d   V P                  P                  4        R # R # R # r#   )Ú_Process__is_openrV   Úcloser_   rZ   r\   rQ   rn   s   &r   Ú__close_write_filesÚProcess.__close_write_files®   s­   € à�>‰>˜$×*Ñ*×+Ò+Ø×Ñ×"Ñ"Ô$Ø�>‰>˜$×-Ñ-×.Ò.Ø×Ñ×%Ñ%Ô'à�>‰>˜$×*Ñ*×+Ò+Ø×Ñ×"Ñ"Ô$Ø�;�;ˆ;˜4Ÿ>™>¨$×*=Ñ*=×>Ò>Ø×Ñ×%Ñ%Ö'ñ ?‰;r   c                ó6  € V P                  V P                  4      '       d   V P                  P                  4        V P                  '       d<   V P                  V P                  4      '       d   V P                  P                  4        V P                  4        R # r#   )rx   rY   ry   rQ   r^   Ú_Process__close_write_filesrn   s   &r   Ú__close_filesÚProcess.__close_filesº   sd   € à�>‰>˜$×-Ñ-×.Ò.Ø×Ñ×%Ñ%Ô'Ø�;�;ˆ;˜4Ÿ>™>¨$×*=Ñ*=×>Ò>Ø×Ñ×%Ñ%Ô'à× Ñ Ö"r   c                óZ   € V P                   P                  4        V P                  4        R # r#   )rL   Úwaitr}   rn   s   &r   Ú__process_waitÚProcess.__process_waitÃ   s   € Ø�‰×ÑÔØ× Ñ Ö"r   c                óN   € V ! V^ ,          VR,          4      pWn         RVn        V# )z>Create an immutable process object used for listing processes.ºé   NNT)rN   rO   )Úclsr5   r   Úps   &&& r   Ú	immutableÚProcess.immutableÇ   s)   € ñ �˜•
˜G B�KÓ(ˆØŒØˆŒØˆr   c                ó(   € V P                   ^ ,          # )zCommand.©rJ   rn   s   &r   r   ÚProcess.commandÏ   s   € ð × Ñ  Õ#Ð#r   c                ó(   € V P                   R,          # )z
Arguments.r…   rŒ   rn   s   &r   Ú	argumentsÚProcess.argumentsÔ   s   € ð × Ñ  Õ$Ð$r   c                ó   € V P                   # )zFull command line.rŒ   rn   s   &r   Úcommand_lineÚProcess.command_lineÙ   s   € ð × Ñ Ð r   c           	     óð  € V P                   '       d   \        hV P                  4         \        P                  ! V P
                  V P                  V P                  V P                  \        V P                  4      V P                  R7      V n        \         P"                  ! T P$                  RR7      T n        T P&                  P)                  4        R#   \         d    \        T P                  R7      hi ; i)zStart the process.)Ústdinr:   r<   r)   Úcwdr   T)ÚtargetÚdaemonN)rO   ÚNotImplementedErrorÚ_Process__open_filesrf   ÚPopenrJ   rT   rZ   r_   r-   rK   rP   rL   ÚOSErrorr   r   Ú	threadingÚThreadÚ_Process__process_waitrM   Ústartrn   s   &r   r    ÚProcess.startÞ   sÁ   € à�?�?ˆ?Ü%Ð%ð 	×ÑÔð
	;Ü&×,Ò,Ø×!Ñ!Ø—k‘kØ×*Ñ*Ø×*Ñ*Ü §	¡	Ó*Ø×%Ñ%ôˆDŒMô &×,Ò,Ø×&Ñ&¨tô
ˆÔð 	×Ñ×ÑÖ!øô ô 	;Ü$¨T¯\©\Ô:Ð:ð	;ús   ªA&C Ã"C5c                ó
  €  V P                   e9   \        V P                  4       V P                  P	                  4        RV n         R# V P
                  '       d   \        V P                  4       R# R#   \         d     R# i ; i)z!Kill the process if it's running.NTF)rL   r4   r5   rM   ÚjoinrO   rœ   rn   s   &r   r4   ÚProcess.killö   sd   € ð	Ø�}‰}Ò(Ü�T—X‘X”Ø×!Ñ!×&Ñ&Ô(Ø $�”ÙØ——�Ü�T—X‘X”ÙáøÜô 	Úð	ús   ‚AA3 ÁA3 ÁA3 Á3BÂBc                ó0   <€ V ^8„  d   QhRS[ S[,          /# )r9   Útimeout©r   Úint)rC   r!   s   "€r   rD   rE     s   ø€ ÷  ñ  ™H¡S�Mñ  r   c                óh  € V P                   '       d   \        hVel   \        P                  ! 4       p\        P                  ! 4       V,
          VR,          8  d-   V P                  '       g   R# \        P                  ! R4       KT  R# V P                  '       d   \        P                  ! R4       K*  R# )aÄ  Wait for the process to finish.

It will wait for the process to finish running. If the timeout is
provided, the function will wait only `timeout` amount of seconds and
then return to it's caller.

Args:
    timeout: `None` if you want to wait to wait until the process
        actually finishes, otherwise it will wait just the `timeout`
        number of seconds.

Returns:
    bool: Return value only makes sense if you provided the timeout
        parameter. It will indicate if the process actually finished in
        the amount of time specified, i.e. if the we specify 3 seconds
        and the process actually stopped after 3 seconds it will return
        `True` otherwise it will return `False`.
iè  Tgš™™™™™¹?F)rO   r™   ÚtimeÚ
is_runningÚsleep)r   r¦   Úcurrent_times   && r   r�   ÚProcess.wait  sl   € ð& �?�?ˆ?Ü%Ð%àÒÜŸ9š9›;ˆLÜ—)’)“+ Õ,°¸$µÔ?Ø——�ÙÜ—
’
˜3–Ùà—/—/�/Ü—
’
˜3–Ùr   c                ó†   € V P                   '       d   \        hV P                  e   V P                  P                  e   R# R# )zxIndicate if the process is still running.

Returns:
    bool: `True` if the process is still running `False` otherwise.
FT)rO   r™   rL   Ú
returncodern   s   &r   r«   ÚProcess.is_running(  s2   € ð �?�?ˆ?Ü%Ð%à�=‰=Ò  D§M¡M×$<Ñ$<Ò$HÙÙr   c                ój   € V P                   '       d   V P                  # V P                  P                  # )z[PID of the process if it is running.

Returns:
    int: Process id of the running process.
)rO   rN   rL   r5   rn   s   &r   r5   ÚProcess.pid6  s%   € ð !ŸOŸO˜Oˆt�y‰yÐB°·±×1BÑ1BÐBr   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r9   Úreturnr§   )rC   r!   s   "€r   rD   rE   @  s   ø€ ÷ (ñ (™8¡C�=ñ (r   c                ó†   € V P                   '       d   \        hV P                  '       d   R# V P                  P                  # )z�Exit code if the process has finished running.

Returns:
    Optional[int]: Exit code or `None` if the process is still running.
N)rO   r™   r«   rL   r°   rn   s   &r   Ú	exit_codeÚProcess.exit_code?  s/   € ð �?�?ˆ?Ü%Ð%à�?�?ˆ?ÙØ�}‰}×'Ñ'Ð'r   c                ó    <€ V ^8„  d   QhRS[ /# )r9   Ústring©r'   )rC   r!   s   "€r   rD   rE   M  s   ø€ ÷ (ñ (™Cñ (r   c                óP  € V P                   '       d   \        hV P                  '       d|   VR,          R8w  d
   VR,          pV P                  P                  P                  VP                  V P                  4      4       V P                  P                  P                  4        R# R# )zpWrite a string to the process standard input.

Args:
    string: String to write to the process standard input.
Ú
Néÿÿÿÿ)	rO   r™   rR   rL   r•   ÚwriteÚencoderS   Úflush)r   r»   s   &&r   rÀ   ÚProcess.writeM  st   € ð �?�?ˆ?Ü%Ð%à× × Ð Ø�b�z˜TÔ!Ø˜$•�Ø�M‰M×Ñ×%Ñ% f§m¡m°D·N±NÓ&CÔDØ�M‰M×Ñ×%Ñ%Ö'ñ	 !r   c                ó    <€ V ^8„  d   QhRS[ /# rµ   r¼   )rC   r!   s   "€r   rD   rE   \  s   ø€ ÷ ñ ‘cñ r   c                óÀ   € V P                   '       d   \        hV P                  '       d4   V P                  P	                  4       P                  V P                  4      # R# )z÷Read from the process standard output.

Returns:
    str: The data process has written to the standard output if it has
        written anything. If it hasn't or you already read all the data
        process wrote, it will return an empty string.
Ú )rO   r™   rR   rY   ÚreadÚdecoderS   rn   s   &r   rÇ   ÚProcess.read\  sF   € ð �?�?ˆ?Ü%Ð%à× × Ð Ø×&Ñ&×+Ñ+Ó-×4Ñ4°T·^±^ÓDÐDÙr   c                ó    <€ V ^8„  d   QhRS[ /# rµ   r¼   )rC   r!   s   "€r   rD   rE   k  s   ø€ ÷ ñ ‘sñ r   c                óÐ   € V P                   '       d   \        hV P                  '       d<   V P                  '       d*   V P                  P                  4       P                  R4      # R# )zõRead from the process standard error.

Returns:
    str: The data process has written to the standard error if it has
        written anything. If it hasn't or you already read all the data
        process wrote, it will return an empty string.
úutf-8rÆ   )rO   r™   rR   rQ   r^   rÇ   rÈ   rn   s   &r   ÚereadÚProcess.ereadk  sJ   € ð �?�?ˆ?Ü%Ð%à× × Ð  T§[§[ [Ø×&Ñ&×+Ñ+Ó-×4Ñ4°WÓ=Ð=Ùr   c                ó&   € V P                  4        R # r#   )Ú_Process__close_filesrn   s   &r   Ú__del__ÚProcess.__del__z  s   € Ø×ÑÖr   c                ó<   € R V P                    RV P                   R2# )zProcess(pid=z
, command=Ú))r5   r   rn   s   &r   Ú__str__ÚProcess.__str__}  s   € Ø˜dŸh™h˜Z z°$·,±,°¸qÐAÐAr   )rJ   rQ   rS   rK   rO   rN   rL   rR   r]   r[   r^   r\   r_   rT   rX   rU   rY   rV   rZ   rM   rP   )	NNrG   NrG   TTNrÌ   r#   )r   r   r   r   Ú__doc__r   rš   rx   r}   rÐ   rŸ   Úclassmethodr‰   Úpropertyr   r�   r’   r    r4   r�   r«   r5   r¸   rÀ   rÇ   rÍ   rÑ   rÕ   Ú__repr__r   r   )r!   s   @r   r7   r7   0   s  ø‡ € ñ÷"H#ò H#òT4ò>Gò
(ò#ò#ð ñó ðð ñ$ó ð$ð ñ%ó ð%ð ñ!ó ð!ò"ò0÷  ò  ðD ñó ðð ñCó ðCð ÷(ó ð(÷(ð (÷ð ÷ð òòBð †Hr   r7   )rh   r$   rª   r/   r2   Úloggingr�   rf   Úpathlibr   Útempfiler   Útypingr   r   r   r   Ú
tea.errorsr	   Ú	getLoggerr   Úloggerr   r   r-   r4   r7   r   r   r   Ú<module>râ      sn   ðÛ 	Û 	Û Û Û Û Û Û Ý Ý 'ß .Ó .å ð 
×	Ò	˜8Ó	$€ô	�8ô 	ôE˜ô Eòò	%÷Pó Pr   