Format: application/x-python-code
⬇ Download File (3.8 KB)
   1  o
   2  
   3  ��h+"�@sddZddlZddlZddlZddlZddlmZmZddl	m
   4  Z
   5  Gdd�de�Ze�j
   6  Z
   7  dd	�ZdS)
   8  z}Posix-specific implementation of process utilities.
   9  
  10  This file is only meant to be imported by process.py, not by end-users.
  11  �N�)�	getoutput�	arg_split)�DEFAULT_ENCODINGc@sNeZdZdZdZdZdZdZedd��Z	ddd�Z
  12  d	d
  13  �Zdd�Zd
  14  d�Z
  15  dS)�ProcessHandlerz7Execute subprocesses under the control of pexpect.
  16      g�������?g�������?NcCsJ|jdur"ddl}tj�dd�}|�|�|_|jdur"td�|���|jS)Nr�SHELL�shz"{}" shell not found)�_sh�pexpect�os�environ�get�which�OSError�format)�selfr
  17  Z
  18  shell_name�r�Rc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/_process_posix.pyr1s
  19  
  20  zProcessHandler.shcCsF|durtjn||_|durtjn||_|durtj|_dS||_dS)z%Arguments are used for pexpect calls.N)r�read_timeout�terminate_timeout�sys�stdout�logfile)rrrrrrr�__init__<s
  21  ����zProcessHandler.__init__cC�Lddl}z|j|jd|gd��dd�WSty%tdtjdd	�YdSw�
  22  a"Run a command and return its stdout/stderr as a string.
  23  
  24          Parameters
  25          ----------
  26          cmd : str
  27              A command to be executed in the system shell.
  28  
  29          Returns
  30          -------
  31          output : str
  32              A string containing the combination of stdout and stderr from the
  33          subprocess, in whatever order the subprocess originally wrote to its
  34          file descriptors (so the order of the information in this string is the
  35          correct order as would be seen if running the command in a terminal).
  36          rN�-c��argsz
  37  �
  38  z^C�)�file�end�r
  39  �runr�replace�KeyboardInterrupt�printr�stderr�r�cmdr
  40  rrrrE��zProcessHandler.getoutputcCrrr#r)rrr�getoutput_pexpect[r+z ProcessHandler.getoutput_pexpectc
  41  Cs�ddl}t}|j|jg}|�|j�}d}zEt|d�r%|j|jd|gd�}n
  42  |j|jd|gd�}t	j
  43  j}	|�||j
  44  �}	t|j|d��|d�dd	�|�|	|krRnt|j�}q4WnLty�|�td
  45  ��z4z"t|j�}|�||j�t|j|d��|d�dd	�t	j
  46  ��Wn	ty�YnwW|jdd�n|jdd�wYnw|��|jdur�|jdur�dS|jS|jdkr�|jdS|jS)
  47  z�Execute a command in a subshell.
  48  
  49          Parameters
  50          ----------
  51          cmd : str
  52              A command to be executed in the system shell.
  53  
  54          Returns
  55          -------
  56          int : child's exitstatus
  57          rN�spawnbrrTr%r )r"�)�force�)r
  58  r�TIMEOUTZEOF�index�hasattrr-rZspawnrr�flushZexpect_listrr'�before�decode�lenr&Zsendline�chrr�	terminateZisaliveZ
  59  exitstatusZsignalstatus)
  60  rr*r
  61  �enc�patternsZ	EOF_indexZout_size�childr4Zres_idxrrr�systemqsP
  62  
  63  �
  64  �� �
  65  
  66  
  67  zProcessHandler.system)NNN)�__name__�
  68  __module__�__qualname__�__doc__rrrr	�propertyrrrr,r=rrrrrs
  69  
  70  
  71  	rc
  72  Csbz	t�|d�WdSty0}z|jtjkrWYd}~dS|jtjkr+WYd}~dS�d}~ww)NrFT)r�killr�errnoZESRCHZEPERM)�pid�errrrr�	check_pid�s	���rG)rArDr�
  73  subprocess�sprZ_process_commonrrZIPython.utils.encodingr�objectrr=rGrrrr�<module>s0