reviewbot.utils.process¶
Utility functions for Process invocation and management.
Functions
|
Execute a command and return the output. |
|
Check whether an executable is in the user's search path. |
- execute(command, env=None, split_lines=False, ignore_errors=False, extra_ignore_errors=(), translate_newlines=True, with_errors=True, return_errors=False, none_on_ignored_error=False)[source]¶
Execute a command and return the output.
- Parameters
command (list of unicode) – The command to run.
env (dict, optional) – The environment variables to use when running the process.
split_lines (bool, optional) – Whether to return the output as a list (split on newlines) or a single string.
ignore_errors (bool, optional) – Whether to ignore non-zero return codes from the command.
extra_ignore_errors (tuple of int, optional) – Process return codes to ignore.
translate_newlines (bool, optional) – Whether to convert platform-specific newlines (such as rn) to the regular newline (n) character.
with_errors (bool, optional) – Whether the stderr output should be merged in with the stdout output or just ignored.
return_errors (bool, optional) – Whether to return the content of the stderr stream. If set, this argument takes precedence over the
with_errors
argument.none_on_ignored_error (bool, optional) – Whether to return
None
if there was an ignored error (instead of the process output).
- Returns
This returns a single value or 2-tuple, depending on the arguments.
If
return_errors
isTrue
, this will return the standard output and standard errors as strings in a tuple. Otherwise, this will just result the standard output as a string.If
split_lines
isTrue
, those strings will instead be lists of lines (preserving newlines).All resulting strings will be Unicode.
- Return type
object
- is_exe_in_path(name, cache={})[source]¶
Check whether an executable is in the user’s search path.
If the provided filename is an absolute path, it will be checked directly without looking in the search path.
Changed in version 3.0: Added the
cache
parameter.- Parameters
name (unicode) – The name of the executable, without any platform-specific executable extension. The extension will be appended if necessary.
cache (dict, optional) –
A result cache, to avoid repeated lookups.
This will store the paths to any files that are found (or
None
if not found).By default, the cache is shared across all calls. A custom cache can be provided instead.
- Returns
True if the executable can be found in the execution path.
- Return type
boolean