U v_& @sddlmZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z mZddlmZddlmZmZdd lmZerdd lmZmZmZmZmZmZmZmZeeeefZ d Z!d d Z"ddZ#ddZ$ddZ%dddZ&ddZ'dS))absolute_importN) shlex_quote)SpinnerInterface open_spinner)InstallationError)console_to_strstr_to_display)subprocess_logger) HiddenTextpath_to_display)MYPY_CHECK_RUNNING)AnyCallableIterableListMappingOptionalTextUnionz(----------------------------------------cGs2g}|D]$}t|tr"||q||q|S)z& Create a CommandArgs object. ) isinstancelistextendappend)args command_argsargr/builddir/build/BUILDROOT/alt-python38-pip-20.2.4-1.el7.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/utils/subprocess.py make_commands    rcCsddd|DS)z/ Format command arguments for display.  css,|]$}t|trtt|nt|VqdS)N)rr rstr.0rrrr 7sz&format_command_args..)joinrrrrformat_command_args-s r&cCsdd|DS)z= Return the arguments in their raw, unredacted form. cSs g|]}t|tr|jn|qSr)rr secretr!rrr Bsz'reveal_command_args..rr%rrrreveal_command_args=sr)c CsDt|}t|dd}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. z command bytes)desczCommand 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.r0msgrrrmake_subprocess_output_errorGs   r:FraiseTc  Cs^|dkr g}|dkrg}|r*tj} tj} n tj} tj} t| k} | oN|dk } |dkr`t|}| d|tj }|r| ||D]}| |dqzBt jt|t jt jt j||d}|jst|jst|jWn:tk r}z| rtd||W5d}~XYnXg}t|j}|s2ql|}||d| || r|s`t|qz |W5|jr|jX|jo|j|k}| r|st|r|dn |d|rT|dkr| s| rt ||||jd }t!|d "|j|}t#|n8|d kr:t$d ||j|n|d krFnt%d"|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. NzRunning command %s)stderrstdinstdoutr6envz#Error %s while executing command %s errordoner;)r5r6r7r,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 returncodefinishr:rAr2rwarning ValueErrorr$)cmd show_stdoutr6 on_returncodeextra_ok_returncodes command_desc extra_environ unset_environspinnerlog_failed_cmdlog_subprocess used_levelshowing_subprocess use_spinnerr?nameprocexc all_outputlineproc_had_errorr9exc_msgrrrcall_subprocessqs                   rtcsdfdd }|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. Nc s(t}t||||dW5QRXdS)N)r6rerg)rrt)r`r6rergmessagerrrunner s z+runner_with_spinner_message..runner)NNr)rvrwrrurrunner_with_spinner_messages rx) FNr;NNNNNT)( __future__rrFrKrPpip._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 CommandArgsr4rr&r)r:rtrxrrrrs<     ( ,