a
ljJ' @ 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 Zcommand_argsarg r B/usr/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 Zsecretr 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+ Zcommand_displayZcwd_displayZ
line_countoutputZdivider)r$ r" formatlenLOG_DIVIDER)r( r) r* r+ Zcommandr- msgr r r make_subprocess_output_errorH s
r2 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|j |j }|s(qX| }||d || |r| qz| W |jr|j n|jr|j 0 d|}nT| \}}| D ]}|| q|| | D ]}|| q|| |}|jo|j|v}|r |r| d n
| d |r|d
krf|
sX| rXt!| |||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, errorZdoner3 )r( r) r* r+ warnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=)&r infologgingINFOverboser
ZgetEffectiveLevelr$ osenvironcopyupdatepop
subprocessPopenr' PIPEZSTDOUT ExceptionZcriticalr? closer@ readlinerstripr Zspinwaitr" Zcommunicate
splitlines
returncodeZfinishr2 rE r Zwarning
ValueError)r4 r5 r) r6 r7 r8 r9 r: r; r<