+
    ^|iZ                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RIH	t	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ^RIHt ^R	IHt ^R
IHtHt ^RIHt  ! R R4      tR R ltR R ltR R lt ]P@                  t ] PB                  PD                  t"]
]! ]4      .]"n#        ]! ]
4      ]"n$        ] PJ                  PL                  t&]	]&n'        ]	.]&n#        RR R lltR R lt)R#   ]( d    ]t Li ; i)zWindows-specific implementation of process utilities.

This file is only meant to be imported by process.py, not by end-users.
N)POINTERc_int)HLOCALLPCWSTR)STDOUT)Thread)TracebackType)ListOptional)	py3compat)	arg_split)process_handlerread_no_interrupt)DEFAULT_ENCODINGc                   H   a  ] tR t^t o RtV 3R lR ltV 3R lR ltRtV tR# )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                0   < V ^8  d   QhRS[ S[,          /# )   return)r
   str)format__classdict__s   ">/usr/lib/python3/dist-packages/IPython/utils/_process_win32.py__annotate__AvoidUNCPath.__annotate__.   s     
 
8C= 
    c                    \         P                  ! 4       V n        V P                  P                  R 4      V n        V P                  '       d#   \         P
                  ! R4       V P                  # R# )z\\zC:N)osgetcwdpath
startswithis_unc_pathchdir)selfs   &r   	__enter__AvoidUNCPath.__enter__.   sL    IIK	99//6HHTN99 r   c                p   < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RR/# )r   exc_type	exc_value	tracebackr   N)r
   typeBaseExceptionr   )r   r   s   "r   r   r   :   sG        4./  M*  M*	 
 
 r   c                n    V P                   '       d#   \        P                  ! V P                  4       R # R # )N)r!   r   r"   r   )r#   r'   r(   r)   s   &&&&r   __exit__AvoidUNCPath.__exit__:   s%     HHTYY r   )r!   r   N)	__name__
__module____qualname____firstlineno____doc__r$   r-   __static_attributes____classdictcell__)r   s   @r   r   r      s     (
 
   r   r   c                Z    V ^8  d   QhR\         P                  \        ,          R\        /# )r   pr   )
subprocessPopenbytesint)r   s   "r   r   r   D   s%     - -J$$U+ - -r   c                J  a a \         oR VV 3R llpR VV 3R llp\        VR7      p\        VR7      pVP                  4        VP                  4         S P                  4       pVf   \        P
                  ! R4       K-   TP                  4        TP                  4        T# )zCallback for _system.c                    V ^8  d   QhRR/# r   r   N )r   s   "r   r   "_system_body.<locals>.__annotate__K        A A Ar   c                  Z  <  SP                   f   Q h\        SP                   4      ;'       g    RP                  4        F0  p V P                  SR4      p\	        V\
        P                   R7       K2  	  R #   \         d*   p\	        RT 2\
        P                  R7        R p?R # R p?ii ; i)Nr   replacefilezError reading stdout: )stdoutr   
splitlinesdecodeprintsys	Exceptionstderr	byte_linelineeencr7   s      r   stdout_read!_system_body.<locals>.stdout_readK       	A88'''/9@@SLLN	 ''Y7d, O  	A*1#.SZZ@@	A   +A6 AA6 6B*B%%B*c                    V ^8  d   QhRR/# r>   r?   )r   s   "r   r   r@   T   rA   r   c                  Z  <  SP                   f   Q h\        SP                   4      ;'       g    RP                  4        F0  p V P                  SR4      p\	        V\
        P                   R7       K2  	  R #   \         d*   p\	        RT 2\
        P                   R7        R p?R # R p?ii ; i)Nr   rC   rD   zError reading stderr: )rL   r   rG   rH   rI   rJ   rK   rM   s      r   stderr_read!_system_body.<locals>.stderr_readT   rT   rU   )targetg{Gz?)r   r   startpolltimesleepjoin)r7   rR   rX   stdout_threadstderr_threadresultrQ   s   f     @r   _system_bodyrc   D   s    
C
A AA A +.M+.M
 >JJt Mr   c                F    V ^8  d   QhR\         R\        \        ,          /# r   cmdr   )r   r
   r;   )r   s   "r   r   r   t   s        r   c                    \        4       ;_uu_ 4       pVe   RV: RV : 2p \        V \        4      pVuuRRR4       #   + '       g   i     R# ; i)a  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   rc   )rf   r   ress   &  r   systemrk   t   s8    & 
4'+S1Cc<0	 
s	    >A	c                0    V ^8  d   QhR\         R\         /# re   )r   )r   s   "r   r   r      s     ! !3 !3 !r   c                    \        4       ;_uu_ 4       pVe   RV: RV : 2p \        V R \        4      pRRR4       Xf   Rp\        P                  ! V4      #   + '       g   i     L,; i)zReturn 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
Nrh   ri   c                 0    V P                  4       ^ ,          # )    )communicate)r7   s   &r   <lambda>getoutput.<locals>.<lambda>   s    Q]]_Q-?r   r   )r   r   r   r   rH   )rf   r   outs   &  r   	getoutputrt      sV     
4'+S1Cc#?H 

 {C   
s   !AA(	c          	      ^    V ^8  d   QhR\         R\        R\        R\        \         ,          /# )r   commandlineposixstrictr   )r   boolr	   )r   s   "r   r   r      s0      !%7;	cr   c                   V P                  4       R8X  d   . # V'       g   \        WVR7      # \        4       p\        V P	                  4       \
        P                  ! V4      4      p \        VP                  ,          pVP                  \
        P                  ! VP                  4      4       Uu. uF  pVf   K	  VNK  	  pp\        V4      pV# u upi   \        T4      pi ; i)a  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.
 )rw   rx   )strippy_arg_splitr   CommandLineToArgvWlstripctypesbyrefr   valuefrom_address	addressofcontents	LocalFree)	rv   rw   rx   argvnresult_pointerresult_array_typeargrb   _s	   &&&      r   r   r      s     "$IHH+K,>,>,@&,,uBUV	* '%++ 5 -99$$^%<%<=C 	    .)A .)As%   &AC .C9C?C C C c                0    V ^8  d   QhR\         R\        /# )r   pidr   )r;   ry   )r   s   "r   r   r      s     8 83 84 8r   c                 V    \        \        P                  P                  ^^ V 4      4      # )   )ry   windllkernel32OpenProcess)r   s   &r   	check_pidr      s"     ++Aq#677r   )FT)*r3   r   r   r8   rJ   r]   r   r   ctypes.wintypesr   r   r   	threadingr   typesr   typingr	   r
   r{   r   _process_commonr   r}   r   r   encodingr   r   rc   rk   rt   r   shell32r~   	arg_typesrestyper   r   res_typeAttributeErrorr   r?   r   r   <module>r      s   
  	  
  ! +    !  6 ? &(  ( V-`4!2)]]F::$+WU^#< !(!1))II!(IH8  Is   8A+C+ +	C76C7