a  ze;' @sddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z ddl m Z mZddlmZddlmZmZddlmZee eefZdZdd Zd d Zd d ZddZdddZddZdS)N)AnyCallableIterableListMappingOptionalUnion)SpinnerInterface open_spinner)InstallationSubprocessError)VERBOSEsubprocess_logger) HiddenTextz(----------------------------------------cGs2g}|D]$}t|tr"||q||q|S)z& Create a CommandArgs object. ) isinstancelistextendappend)args command_argsargr`/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/utils/subprocess.py make_commands    rcCsddd|DS)z/ Format command arguments for display.  css0|](}t|trtt|nt|VqdS)N)rrshlexquotestr.0rrrr .sz&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)rrsecretrrrr 9z'reveal_command_args..rr!rrrreveal_command_args4sr&cCs0t|}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}) exit_statuscommand_display cwd_display line_countoutputdivider)r"r formatlen LOG_DIVIDER)cmd_argscwdlinesr(commandr,msgrrrmake_subprocess_output_error<s   r6FraiseTc  Cs|dur g}|durg}|r*tj} tj} n tj} t} t| k} | oL|du}|dur^t|}| d|tj }|r| ||D]}| |dqz0t jt|t jt j| st jnt j||dd}Wn8ty}z | rtd||WYd}~n d}~00g}| s|jsJ|js"J|j|j}|s@qz|}||d| ||r,|snJ|q,z|W|jr|jn|jr|j0d|}nT|\}}|D]}| |q|||D]}| |q|||}|jo|j|v}|rL|s0J|rB| dn | d |r|d kr| s| rt!||||jd }t"|t#|j|n8|d krt$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)stdinstdoutstderrr2enverrorsz#Error %s while executing command %s r'errordoner7)r1r2r3r(warnz$Command "%s" had error code %s in %signorezInvalid value: on_returncode=)&r infologgingINFOverboser getEffectiveLevelr"osenvironcopyupdatepop subprocessPopenr&PIPESTDOUT Exceptioncriticalr:r9closereadlinerstriprspinwaitr communicate splitlines returncodefinishr6r?r warning ValueError)cmd show_stdoutr2 on_returncodeextra_ok_returncodes command_desc extra_environ unset_environspinnerlog_failed_cmd stdout_onlylog_subprocess used_levelshowing_subprocess use_spinnerr<nameprocexc all_outputliner,outerrout_lineerr_lineproc_had_errorr5rrrcall_subprocess`s                              rvcsdfdd }|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. Ncs<t }t||||dWdn1s.0YdS)N)r2rcre)r rv)r^r2rcremessagerrrunner s z+runner_with_spinner_message..runner)NNr)rxryrrwrrunner_with_spinner_messages rz) FNr7NNNNNTF)rDrHrrMtypingrrrrrrrpip._internal.cli.spinnersr r pip._internal.exceptionsr pip._internal.utils.loggingr r pip._internal.utils.miscrr CommandArgsr0rr"r&r6rvrzrrrrs6$  & $