Re& @swddlmZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z mZddlmZddlmZmZdd lmZer dd lmZmZmZmZmZmZmZmZeeeefZ d Z!d d Z"ddZ#ddZ$ddZ%ddddddddddd Z&ddZ'dS))absolute_importN) shlex_quote)SpinnerInterface open_spinner)InstallationError)console_to_strstr_to_display)subprocess_logger) HiddenTextpath_to_display)MYPY_CHECK_RUNNING)AnyCallableIterableListMappingOptionalTextUnionz(----------------------------------------cGsGg}x:|D]2}t|tr2|j|q |j|q W|S)z& Create a CommandArgs object. ) isinstancelistextendappend)args command_argsargr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/subprocess.py make_commands  rcCsdjdd|DS)z/ Format command arguments for display.  css<|]2}t|tr*tt|n t|VqdS)N)rr rstr).0rrrr 8sz&format_command_args..)join)rrrrformat_command_args-s  r$cCsdd|DS)z= Return the arguments in their raw, unredacted form. cSs.g|]$}t|tr$|jn|qSr)rr secret)r!rrrr Cs z'reveal_command_args..r)rrrrreveal_command_args=sr'c Csst|}t|dd}t|}dj|}djd|d|d|dt|d |d t}|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. descz command byteszCommand errored out with exit status {exit_status}: command: {command_display} cwd: {cwd_display} Complete output ({line_count} lines): {output}{divider} exit_statuscommand_display cwd_display line_countoutputdivider)r$rr r#formatlen LOG_DIVIDER) cmd_argscwdlinesr*commandr+r,r.msgrrrmake_subprocess_output_errorGs     r8FraiseTc Cs;|dkrg}|dkr$g}|r?tj} tj} ntj} tj} tj| k} | os|dk } |dkrt|}| d|tj j }|r|j |x|D]}|j |dqWykt jt|dt jdt jdt jd|d|}|js,t|js;t|jjWnAtk r}z!| rwtjd||WYdd}~XnXg}xct|jj}|sP|j}|j|d | || r|st|jqWz|jWd|jr |jjX|jo6|j|k}| rn|sKt|ra|jd n |jd |r.|d kr| r| rt d |d|d|d|j}tj!|dj"|j|}t#|nL|dkr tj$d||j|n$|dkrnt%dj"|dj&|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. NzRunning command %sstderrstdinstdoutr4envz#Error %s while executing command %s errordoner9r3r5r*zSCommand errored out with exit status {}: {} Check the logs for full command output.warnz$Command "%s" had error code %s in %signorez!Invalid value: on_returncode={!r}r))'r infologgingINFOdebugDEBUGgetEffectiveLevelr$osenvironcopyupdatepop subprocessPopenr'STDOUTPIPEr;AssertionErrorr<close Exceptioncriticalrreadlinerstriprspinwait returncodefinishr8r?r0rwarning ValueErrorr#)cmd show_stdoutr4 on_returncodeextra_ok_returncodes command_desc extra_environ unset_environspinnerlog_failed_cmdlog_subprocess used_levelshowing_subprocess use_spinnerr=nameprocexc all_outputlineproc_had_errorr7exc_msgrrrcall_subprocessqs                            rrcsddfdd}|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. Ncs6t#}t|d|d|d|WdQRXdS)Nr4rcre)rrr)r^r4rcre)messagerrrunner s z+runner_with_spinner_message..runnerr)rsrtr)rsrrunner_with_spinner_messages  ru)( __future__rrDrIrNpip._vendor.six.movesrpip._internal.cli.spinnersrrpip._internal.exceptionsrpip._internal.utils.compatrrpip._internal.utils.loggingr pip._internal.utils.miscr r pip._internal.utils.typingr typingr rrrrrrrr Z CommandArgsr2rr$r'r8rrrurrrrs8   :   ,