venv_management.shell module
Summary
Functions:
Return (status, output) of executing cmd in a shell. |
|
Determine whether a line of text contains a warning emitted by a shell. |
|
Remove shell warnings from lines of text. |
|
Build a command to run a given command in an interactive subshell. |
Reference
- venv_management.shell.sub_shell_command(command, suppress_setup_output=True)[source]
Build a command to run a given command in an interactive subshell.
- Parameters
command – The command for the subshell.
suppress_setup_output – Suppress output from the environment setup command if True, (the default), otherwise capture it.
- Returns
A string which can be used with the subprocess module.
- Raises
ValueError – If the subshell command could not be determined.
- venv_management.shell.get_status_output(cmd: List[str], success_statuses=None) Tuple[int, str] [source]
Return (status, output) of executing cmd in a shell.
- Parameters
cmd – A list of command arguments to be executed.
success_statuses – A container of integer status codes which indicate success.
Execute the string ‘cmd’ in a shell with ‘check_output’ and return a 2-tuple (status, output). Universal newlines mode is used, meaning that the result with be decoded to a string.
A trailing newline is stripped from the output. The exit status for the command can be interpreted according to the rules for the function ‘wait’.
- venv_management.shell.has_interactive_warning(line: str)[source]
Determine whether a line of text contains a warning emitted by a shell.
The shell program itself (e.g. bash) can emit warnings under certain circumstances which clutter output; for example, when running a shell in interactive mode without a connected terminal. This predicate can identify lines of text containing such warnings.
- Parameters
line – A string which may contain a shell warning.
- Returns
True if the line contains a shell warning, otherwise False.
- venv_management.shell.remove_interactive_shell_warnings(lines: str) str [source]
Remove shell warnings from lines of text.
The shell program itself (e.g. bash) can emit warnings under certain circumstances which clutter output; for example, when running a shell in interactive mode without a connected terminal. This predicate can identify lines of text containing such warnings.
- Parameters
lines – A string (possibly multiline) which may contain lines which have shell warnings.
- Returns
The argument string without any lines containing matching shell warnings.