§
    �Ÿjô  ã                   ó’  — d Z ddlZddlZddlZddlZddlmZmZ ddlmZm	Z	 ddl
mZmZ ddlmZ ddlmZmZmZ dd	lmZ dd
lmZ  G d„ de¦  «        Zd„ Zd„ Zd„ Z	 ej        j        j        Ze ee¦  «        ge_          ee¦  «        e_!        ej        j"        j#        Z#e	e#_$        e	ge#_         dd„Zn# e%$ r eZY nw xY wd„ Z&dS )zWindows-specific implementation of process utilities.

This file is only meant to be imported by process.py, not by end-users.
é    N)Úc_intÚPOINTER)ÚLPCWSTRÚHLOCAL)ÚSTDOUTÚTimeoutExpired)ÚThreadé   )Úread_no_interruptÚprocess_handlerÚ	arg_split)Ú	py3compat)ÚDEFAULT_ENCODINGc                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚAvoidUNCPathaÂ  A context manager to protect command execution from UNC paths.

    In the Win32 API, commands can't be invoked with the cwd being a UNC path.
    This context manager temporarily changes directory to the 'C:' drive on
    entering, and restores the original working directory on exit.

    The context manager returns the starting working directory *if* it made a
    change and None otherwise, so that users can apply the necessary adjustment
    to their system calls in the event of a change.

    Examples
    --------
    ::
        cmd = 'dir'
        with AvoidUNCPath() as path:
            if path is not None:
                cmd = '"pushd %s &&"%s' % (path, cmd)
            os.system(cmd)
    c                 ó¸   — t          j        ¦   «         | _        | j                             d¦  «        | _        | j        rt          j        d¦  «         | j        S d S )Nz\\zC:)ÚosÚgetcwdÚpathÚ
startswithÚis_unc_pathÚchdir)Úselfs    úi/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/utils/_process_win32.pyÚ	__enter__zAvoidUNCPath.__enter__9   sN   € Ý”I‘K”KˆŒ	Øœ9×/Ò/°Ñ6Ô6ˆÔØÔð 	åŒH�T‰NŒNˆNØ”9Ðð �4ó    c                 óJ   — | j         rt          j        | j        ¦  «         d S d S )N)r   r   r   r   )r   Úexc_typeÚ	exc_valueÚ	tracebacks       r   Ú__exit__zAvoidUNCPath.__exit__E   s/   € ØÔð 	 ÝŒH�T”YÑÔÐÐÐð	 ð 	 r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r!   © r   r   r   r   %   s<   € € € € € ðð ð&
ð 
ð 
ð ð  ð  ð  ð  r   r   c                 ó  ‡ ‡— t           Šˆˆ fd„}ˆˆ fd„}t          |¬¦  «                             ¦   «          t          |¬¦  «                             ¦   «          	 ‰                      ¦   «         }|€t	          j        d¦  «         n|S Œ.)zCallback for _system.c                  ó¼   •— t          ‰j        ¦  «                             ¦   «         D ]3} |                      ‰d¦  «        } t	          | t
          j        ¬¦  «         Œ4d S ©NÚreplace)Úfile)r   ÚstdoutÚ
splitlinesÚdecodeÚprintÚsys©ÚlineÚencÚps    €€r   Ústdout_readz!_system_body.<locals>.stdout_readN   ó]   ø€ Ý% a¤hÑ/Ô/×:Ò:Ñ<Ô<ð 	)ð 	)ˆDØ—;’;˜s IÑ.Ô.ˆDÝ�$�SœZÐ(Ñ(Ô(Ð(Ð(ð	)ð 	)r   c                  ó¼   •— t          ‰j        ¦  «                             ¦   «         D ]3} |                      ‰d¦  «        } t	          | t
          j        ¬¦  «         Œ4d S r)   )r   Ústderrr-   r.   r/   r0   r1   s    €€r   Ústderr_readz!_system_body.<locals>.stderr_readS   r6   r   )ÚtargetTNg{®Gáz„?)r   r	   ÚstartÚpollÚtimeÚsleep)r4   r5   r9   Úresultr3   s   `   @r   Ú_system_bodyr@   J   sµ   øø€ å
€Cð)ð )ð )ð )ð )ð )ð
)ð )ð )ð )ð )ð )õ
 �+ÐÑÔ×$Ò$Ñ&Ô&Ð&Ý
�+ÐÑÔ×$Ò$Ñ&Ô&Ð&ð
Ø—’‘”ˆØˆ>ÝŒJ�tÑÔÐÐàˆMðr   c                 ó�   — t          ¦   «         5 }|�d|›d| ›�} t          | t          ¦  «        cddd¦  «         S # 1 swxY w Y   dS )a7  Win32 version of os.system() that works with network shares.

    Note that this implementation returns None, as meant for use in IPython.

    Parameters
    ----------
    cmd : str or list
        A command to be executed in the system shell.

    Returns
    -------
    int : child process' exit code.
    Nú"pushd ú &&")r   r   r@   )Úcmdr   s     r   ÚsystemrE   f   s•   € õ& 
‰Œð 2˜4ØÐÐØ'+ t t¨S¨SÐ1ˆCÝ˜s¥LÑ1Ô1ð2ð 2ð 2ð 2ñ 2ô 2ð 2ð 2ð 2ð 2ð 2ð 2øøøð 2ð 2ð 2ð 2ð 2ð 2s   �;»?Á?c                 óÀ   — t          ¦   «         5 }|�d|›d| ›�} t          | d„ t          ¦  «        }ddd¦  «         n# 1 swxY w Y   |€d}t          j        |¦  «        S )zýReturn standard output of executing cmd in a shell.

    Accepts the same arguments as os.system().

    Parameters
    ----------
    cmd : str or list
        A command to be executed in the system shell.

    Returns
    -------
    stdout : str
    NrB   rC   c                 ó6   — |                       ¦   «         d         S )Nr   )Úcommunicate)r4   s    r   ú<lambda>zgetoutput.<locals>.<lambda>�   s   € ¨Q¯]ª]©_¬_¸QÔ-?€ r   r   )r   r   r   r   r.   )rD   r   Úouts      r   Ú	getoutputrK   ~   s»   € õ 
‰Œð I˜4ØÐÐØ'+ t t¨S¨SÐ1ˆCÝ˜cÐ#?Ð#?ÅÑHÔHˆðIð Ið Iñ Iô Ið Ið Ið Ið Ið Ið Iøøøð Ið Ið Ið Ið
 €{ØˆÝÔ˜CÑ Ô Ð s   �"=½AÁAFTc                 ó²  — |                       ¦   «         dk    rg S |st          | ||¬¦  «        S t          ¦   «         }t          t	          j        |                      ¦   «         ¦  «        t          j        |¦  «        ¦  «        }t          |j
        z  }d„ |                     t          j        |j        ¦  «        ¦  «        D ¦   «         }t          |¦  «        }|S )a4  Split a command line's arguments in a shell-like manner.

        This is a special version for windows that use a ctypes call to CommandLineToArgvW
        to do the argv splitting. The posix parameter is ignored.

        If strict=False, process_common.arg_split(...strict=False) is used instead.
        Ú )ÚposixÚstrictc                 ó   — g | ]}|‘ŒS r&   r&   )Ú.0Úargs     r   ú
<listcomp>zarg_split.<locals>.<listcomp>¯   s   € ÐkÐkÐk˜#�#ÐkÐkÐkr   )ÚstripÚpy_arg_splitr   ÚCommandLineToArgvWr   Úcast_unicodeÚlstripÚctypesÚbyrefr   ÚvalueÚfrom_addressÚ	addressofÚcontentsÚ	LocalFree)ÚcommandlinerN   rO   ÚargvnÚresult_pointerÚresult_array_typer?   Úretvals           r   r   r   ž   sÊ   € ð ×ÒÑÔ "Ò$Ð$ØˆIØð 	Iå °5ÀÐHÑHÔHÐHÝ‘”ˆÝ+­IÔ,BÀ;×CUÒCUÑCWÔCWÑ,XÔ,XÕZ`ÔZfÐglÑZmÔZmÑnÔnˆÝ# e¤kÑ1ÐØkÐkÐ!2×!?Ò!?ÅÔ@PÐQ_ÔQhÑ@iÔ@iÑ!jÔ!jÐkÑkÔkˆÝ˜>Ñ*Ô*ˆØˆr   c                 óh   — t          t          j        j                             dd| ¦  «        ¦  «        S )Nr
   r   )ÚboolrY   ÚwindllÚkernel32ÚOpenProcess)Úpids    r   Ú	check_pidrk   µ   s)   € õ •”Ô&×2Ò2°1°Q°sÑ;Ô;Ñ<Ô<Ð<r   )FT)'r%   r   r0   rY   r=   r   r   Úctypes.wintypesr   r   Ú
subprocessr   r   Ú	threadingr	   Ú_process_commonr   r   r   rU   rM   r   Úencodingr   Úobjectr   r@   rE   rK   rg   Úshell32rV   Ú	arg_typesÚrestyperh   r_   Úres_typeÚAttributeErrorrk   r&   r   r   ú<module>rw      sß  ððð ð" 
€	€	€	Ø 
€
€
€
Ø €€€Ø €€€à !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø Ð Ð Ð Ð Ð ð [Ð ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZØ Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &ð" ð " ð " ð " ð " �6ñ " ô " ð " ðJð ð ð82ð 2ð 2ð0!ð !ð !ð0ØœÔ.ÔAÐØ$+¨W¨W°U©^¬^Ð#<ÐÔ Ø!( ¨Ñ!1Ô!1ÐÔØ”Ô&Ô0€IØ€IÔØ!˜(€IÔðð ð ð ð øð( ð ð ð Ø€I€I€Iðøøøð=ð =ð =ð =ð =s   ÁAB7 Â7CÃ C