a
ReJ' @ s d dl Z d dlZd dlZd dlZd dlmZmZmZmZm Z m
Z
mZmZ d dl
mZmZ d dlmZ d dlmZmZ d dlmZ erd dlmZ e eeef ZdZeeeef ed d
dZee e ef ed dd
Zee e ef e e d ddZee e ef ee e e eedddZdee e ef e ee deee ee ee
eef eee ee ee ee edddZ!eed dddZ"dS ) N)
TYPE_CHECKINGAnyCallableIterableListMappingOptionalUnion)SpinnerInterfaceopen_spinner)InstallationSubprocessError)VERBOSEsubprocess_logger)
HiddenText)Literalz(----------------------------------------)argsreturnc G s2 g }| D ]$}t |tr"|| q|| q|S )z&
Create a CommandArgs object.
)
isinstancelistextendappend)r command_argsarg r /builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/utils/subprocess.pymake_command! s
r c C s d dd | D S )z/
Format command arguments for display.
c s s0 | ](}t |trtt|nt|V qd S )N)r r shlexquotestr.0r r r r ; s z&format_command_args..)joinr r r r format_command_args2 s
r% c C s dd | D S )z=
Return the arguments in their raw, unredacted form.
c S s g | ]}t |tr|jn|qS r )r r secretr r r r
E z'reveal_command_args..r r$ r r r reveal_command_argsA s r) )cmd_argscwdlinesexit_statusr c C s0 t | }d|}dj|||t||td}|S )z
Create and return the error message to use to log a subprocess error
with command output.
:param lines: A list of lines, each ending with a newline.
zCommand errored out with exit status {exit_status}:
command: {command_display}
cwd: {cwd_display}
Complete output ({line_count} lines):
{output}{divider})r- command_displaycwd_display
line_countoutputdivider)r% r# formatlenLOG_DIVIDER)r* r+ r, r- commandr2 msgr r r make_subprocess_output_errorH s
r9 FraiseTz"Literal["raise", "warn", "ignore"])cmdshow_stdoutr+
on_returncodeextra_ok_returncodescommand_desc
extra_environ
unset_environspinnerlog_failed_cmdstdout_onlyr c
C s |du rg }|du rg }|r*t j}tj}n
t j}t}t |k}
|
oL|du}|du r^t| }|d| tj
}|r|| |D ]}||d qz0t
jt| t
jt
j|
st
jnt
j||dd}W n8 ty } z | rt d|| W Y d}~n
d}~0 0 g }|
s|jsJ |js"J |j |j }|s@qz| }||d || |r,|snJ | q,z| W |jr|j n|jr|j 0 d|}nT| \}}| D ]}|| q|| | D ]}|| q|| |}|jo|j|v}|rL|s0J |rB| d n
| d |r|d
kr|
s| rt!| |||jd}t "| t#|j|n8|dkrt $d
||j| n|dkrnt%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 %sbackslashreplace)stdinstdoutstderrr+ enverrorsz#Error %s while executing command %s
r. errordoner: )r* r+ r, r- warnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=)&r infologgingINFOverboser
getEffectiveLevelr% osenvironcopyupdatepop
subprocessPopenr) PIPESTDOUT ExceptioncriticalrG rF closereadlinerstripr spinwaitr# communicate
splitlines
returncodefinishr9 rL r warning
ValueError)r; r<