Misc. legacy helpers subprocess and finding VCS binaries. will be deprecated by libvcs._internal.subprocess.


This is an internal API not covered by versioning policy.

class, keyword, *args, **kwargs)[source]#

Bases: logging.LoggerAdapter

Adapter for additional command-related data to logging.

Extends logging.LoggerAdapter’s functionality.

Mixes in additional context via logging.LoggerAdapter.process() for logging.Formatter when emitting log entries.

  • bin_name (str) – name of the command or vcs tool being wrapped, e.g. ‘git’

  • keyword (str) – directory basename, name of repo, hint, etc. e.g. ‘django’

process(self, msg, kwargs)[source]#

Add additional context information for loggers.


Bases: Protocol

Callback to report subprocess communication.[source]#

From pypa/pip project, pip.backwardwardcompat. License MIT.[source]#

Make directories recursively.


path (str) – path to create, bufsize=- 1, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=(), *, text=None, encoding=None, errors=None, user=None, group=None, extra_groups=None, umask=- 1, log_in_real_time=True, check_returncode=True, callback=None)[source]#

Run ‘args’ in a shell and return the combined contents of stdout and stderr (Blocking). Throws an exception if the command exits non-zero.

Keyword arguments are passthrough to subprocess.Popen.

  • args (list or str, or single str, if shell=True) – the command to run

  • shell (bool) – boolean indicating whether we are using advanced shell features. Use only when absolutely necessary, since this allows a lot more freedom which could be exploited by malicious code. See the warning here:

  • cwd (str) – dir command is run from. Defaults to path.

  • log_in_real_time (bool) – boolean indicating whether to read stdout from the subprocess in real time instead of when the process finishes.

  • check_returncode (bool) – Indicate whether a libvcs.exc.CommandError should be raised if return code is different from 0.

  • callback (ProgressCallbackProtocol) –

    callback to return output as a command executes, accepts a function signature of (output, timestamp). Example usage:

    def progress_cb(output, timestamp):
    run(['git', 'pull'], callback=progress_cb)

  • bufsize (int) –

  • executable (Optional[libvcs._internal.types.StrOrBytesPath]) –

  • stdin (Optional[_FILE]) –

  • stdout (Optional[_FILE]) –

  • stderr (Optional[_FILE]) –

  • preexec_fn (Optional[Callable[[], Any]]) –

  • close_fds (bool) –

  • env (Optional[_ENV]) –

  • universal_newlines (bool) –

  • startupinfo (Optional[Any]) –

  • creationflags (int) –

  • restore_signals (bool) –

  • start_new_session (bool) –

  • pass_fds (Any) –

  • text (Optional[bool]) –

  • encoding (Optional[str]) –

  • errors (Optional[str]) –

  • user (Optional[Union[str, int]]) –

  • group (Optional[Union[str, int]]) –

  • extra_groups (Optional[Iterable[Union[str, int]]]) –

  • umask (int) –, default_paths=['/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin'])[source]#

Return path of bin. Python clone of /usr/bin/which.

from salt.util - - license apache

  • exe (str) – Application to search PATHs for.

  • default_path (list) – Application to search PATHs for.


Path to binary

Return type: