Format: application/x-python-code
1 o
2
3 ��h� � @ s d Z ddlZddlZddlZddlZddlmZmZ ddlmZm Z ddl
4 mZmZ ddl
5 mZ ddlmZmZmZ dd lmZ dd
6 lmZ G dd� de�Zd
7 d� Zdd� Zdd� Zz$ejjjZeee�ge_ ee�e_!ejj"j#Z#e e#_$e ge#_ ddd�ZW n e%y� eZY nw dd� Z&dS )zWindows-specific implementation of process utilities.
8
9 This file is only meant to be imported by process.py, not by end-users.
10 � N)�c_int�POINTER)�LPCWSTR�HLOCAL)�STDOUT�TimeoutExpired)�Thread� )�read_no_interrupt�process_handler� arg_split)� py3compat)�DEFAULT_ENCODINGc @ s e Zd ZdZdd� Zdd� ZdS )�AvoidUNCPatha� A context manager to protect command execution from UNC paths.
11
12 In the Win32 API, commands can't be invoked with the cwd being a UNC path.
13 This context manager temporarily changes directory to the 'C:' drive on
14 entering, and restores the original working directory on exit.
15
16 The context manager returns the starting working directory *if* it made a
17 change and None otherwise, so that users can apply the necessary adjustment
18 to their system calls in the event of a change.
19
20 Examples
21 --------
22 ::
23 cmd = 'dir'
24 with AvoidUNCPath() as path:
25 if path is not None:
26 cmd = '"pushd %s &&"%s' % (path, cmd)
27 os.system(cmd)
28 c C s2 t �� | _| j�d�| _| jrt �d� | jS d S )Nz\\zC:)�os�getcwd�path�
29 startswith�is_unc_path�chdir)�self� r �Rc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/_process_win32.py� __enter__9 s
30
31 zAvoidUNCPath.__enter__c C s | j rt�| j� d S d S )N)r r r r )r �exc_type� exc_value� tracebackr r r �__exit__E s �zAvoidUNCPath.__exit__N)�__name__�
32 __module__�__qualname__�__doc__r r r r r r r % s r c s` t � � �fdd�}� �fdd�}t|d��� t|d��� ��� }|du r-t�d� n|S q) zCallback for _system.c �2 t �j��� D ]} | �� d�} t| tjd� qd S �N�replace)�file)r
33 �stdout�
34 splitlines�decode�print�sys��line��enc�pr r �stdout_readN � �z!_system_body.<locals>.stdout_readc r"