OwlCyberSecurity - MANAGER
Edit File: subprocess.cpython-39.pyc
a )��e�# � @ sx d dl Z d dlZd dlZd dlZd dlmZmZmZmZm Z m Z mZmZ d dl mZ d dlmZmZ d dlmZ d dlmZmZ d dlmZ er�d dlmZ e eeef Zeeeef ed �d d�Zee e ef ed �dd �Zee e ef e e d �dd�Zdee e ef eee deee ee eef eee ee ee ee eed�dd�Z!eed d�dd�Z"dS )� N)� TYPE_CHECKING�Any�Callable�Iterable�List�Mapping�Optional�Union)�escape)�SpinnerInterface�open_spinner)�InstallationSubprocessError)�VERBOSE�subprocess_logger)� HiddenText)�Literal)�args�returnc G s2 g }| D ]$}t |t�r"|�|� q|�|� q|S )z& Create a CommandArgs object. )� isinstance�list�extend�append)r Zcommand_args�arg� r �_/home/gouroczh/virtualenv/pat/3.9/lib/python3.9/site-packages/pip/_internal/utils/subprocess.py�make_command s r c C s d� dd� | D ��S )z/ Format command arguments for display. � c s s0 | ](}t |t�rt�t|��nt�|�V qd S )N)r r �shlex�quote�str��.0r r r r � <genexpr>: s �z&format_command_args.<locals>.<genexpr>)�join�r r r r �format_command_args1 s �r% c C s dd� | D �S )z= Return the arguments in their raw, unredacted form. c S s g | ]}t |t�r|jn|�qS r )r r �secretr r r r � <listcomp>D � z'reveal_command_args.<locals>.<listcomp>r r$ r r r �reveal_command_args@ s r) F�raiseTz"Literal["raise", "warn", "ignore"])�cmd�show_stdout�cwd� on_returncode�extra_ok_returncodes� extra_environ� unset_environ�spinner�log_failed_cmd�stdout_only�command_descr c C s� |du rg }|du rg }|r*t j}tj}n t j}t}t �� |k} | oL|du}|d| � tj� � }|rp|� |� |D ]}|�|d� qtz0tj t| �tjtj| s�tjntj||dd�}W n8 ty� } z |r�t �d|| � � W Y d}~n d}~0 0 g }| �s�|j�sJ �|j�sJ �|j�� |j�� }|�s0�qj|�� }|�|d � ||� |�r|�s^J �|�� �qz|�� W |j�r�|j�� n|j�r�|j�� 0 d�|�}nT|�� \}}|�� D ]}||� �q�|�|� |�� D ]}||� �q�|�|� |}|j�o|j|v}|�r<|�s J �|�r2|�d� n |�d � |�r�|d k�r�t | |j| �s^|ndd�}|�r�t �!d|� t jd t"t#| ��ddid� t jdt"|�p�d�ddid� |�n8|dk�r�t �$d| |j|� n|dk�r�nt%d|����|S )a� Args: show_stdout: if true, use INFO to log the subprocess's stderr and stdout streams. Otherwise, use DEBUG. Defaults to False. extra_ok_returncodes: an iterable of integer return codes that are acceptable, in addition to 0. Defaults to None, which means []. unset_environ: an iterable of environment variable names to unset prior to calling subprocess.Popen(). log_failed_cmd: if false, failed commands are not logged, only raised. stdout_only: if true, return only stdout, else return both. When true, logging of both stdout and stderr occurs when the subprocess has terminated, else logging occurs as subprocess output is produced. NzRunning command %s�backslashreplace)�stdin�stdout�stderrr- �env�errorsz#Error %s while executing command %s� � �error�doner* )�command_description� exit_code�output_linesz[present-rich] %sz*[bold magenta]full command[/]: [blue]%s[/]�markupT)�extraz[bold magenta]cwd[/]: %sz [inherit]�warnz$Command "%s" had error code %s in %s�ignorezInvalid value: on_returncode=)&r �info�logging�INFO�verboser �getEffectiveLevel�os�environ�copy�update�pop� subprocess�Popenr) �PIPE�STDOUT� Exception�criticalr8 r7 �close�readline�rstripr �spin�waitr# �communicate� splitlines� returncode�finishr r>