o aiJ'@sddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZmZddlmZerHddlmZe e eefZdZd e eeefd efd d Zd e e eefd efd dZd e e eefd e efddZde e eefde ede eded ef ddZ          d+de e eefde de eddde eede ed e e eefd!e eed"e ed#e e d$e e d efd%d&Z!d'ed ed(fd)d*Z"dS),N) TYPE_CHECKINGAnyCallableIterableListMappingOptionalUnion)SpinnerInterface open_spinner)InstallationSubprocessError)VERBOSEsubprocess_logger) HiddenText)Literalz(----------------------------------------argsreturncGs2g}|D]}t|tr||q||q|S)z& Create a CommandArgs object. ) isinstancelistextendappend)r command_argsargr/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/utils/subprocess.py make_command!s    rcCsddd|DS)z/ Format command arguments for display.  css2|]}t|trtt|nt|VqdS)N)rrshlexquotestr.0rrrr ;s  z&format_command_args..)joinrrrrformat_command_args2s r%cCsdd|DS)z= Return the arguments in their raw, unredacted form. cSs g|] }t|tr |jn|qSr)rrsecretr rrr Es z'reveal_command_args..rr$rrrreveal_command_argsAsr(cmd_argscwdlines exit_statuscCs0t|}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_display cwd_display line_countoutputdivider)r%r#formatlen LOG_DIVIDER)r)r*r+r,commandr1msgrrrmake_subprocess_output_errorHs r8FraiseTcmd show_stdout on_returncodez"Literal["raise", "warn", "ignore"]extra_ok_returncodes command_desc extra_environ unset_environspinnerlog_failed_cmd stdout_onlyc  Cs|durg}|dur g}|rtj} tj} ntj} t} t| k} | o&|du}|dur/t|}| d|tj }|r@| ||D]}| |dqBzt jt|t jt j| sZt jnt j||dd}Wntyy}z | rttd||d}~wwg}| s|jsJ|jsJ|j |j}|sn|}||d| ||r|sJ|qz|W|jr|jn |jr|jwwd|}n(|\}}|D]}| |q|||D]}| |q|||}|jo|j|v}|r|sJ|r| d n| d |rV|d kr7| s1| r1t!||||jd }t"|t#|j||d krGt$d||j||S|dkrO |St%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 %sT r-errordoner9)r)r*r+r,warnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=)&rinfologgingINFOverboser getEffectiveLevelr%osenvironcopyupdatepop subprocessPopenr(PIPESTDOUT ExceptioncriticalrFrEclosereadlinerstriprspinwaitr# communicate splitlines returncodefinishr8rKr warning ValueError)r:r;r*r<r=r>r?r@rArBrClog_subprocess used_levelshowing_subprocess use_spinnerrHnameprocexc all_outputliner1outerrout_lineerr_lineproc_had_errorr7rrrcall_subprocessks                              rxmessage).Nc s<  ddttdttdttttfddffdd }|S) zProvide a subprocess_runner that shows a spinner message. Intended for use with for pep517's Pep517HookCaller. Thus, the runner has an API that matches what's expected by Pep517HookCaller.subprocess_runner. Nr:r*r?rcs>t}t||||dWddS1swYdS)N)r*r?rA)r rx)r:r*r?rAryrrrunners "z+runner_with_spinner_message..runner)NN)rrrrr)ryr{rrzrrunner_with_spinner_message s  r|) FNr9NNNNNTF)#rPrTrrYtypingrrrrrrrr pip._internal.cli.spinnersr r pip._internal.exceptionsr pip._internal.utils.loggingr rpip._internal.utils.miscrrr CommandArgsr5rr%r(intr8boolrxr|rrrrs(   " %      #