Command helpers - libvcs._internal.run¶
Misc. legacy helpers subprocess and finding VCS binaries.
libvcs._internal.run.run will be deprecated by
libvcs._internal.subprocess.
Note
This is an internal API not covered by versioning policy.
-
libvcs._internal.run.console_to_str(s)¶
From pypa/pip project, pip.backwardwardcompat. License MIT.
-
class libvcs._internal.run.CmdLoggingAdapter¶
Bases:
LoggerAdapterAdapter for additional command-related data to
logging.Extends
logging.LoggerAdapter’s functionality.Mixes in additional context via
logging.LoggerAdapter.process()forlogging.Formatterwhen emitting log entries.
-
class libvcs._internal.run.ProgressCallbackProtocol¶
Bases:
ProtocolCallback to report subprocess communication.
-
libvcs._internal.run._normalize_command_args(args)¶
Return subprocess arguments without splitting scalar strings or bytes.
- Parameters:
args (_CMD)
- Return type:
-
libvcs._internal.run._stringify_command(args)¶
Return a human-readable command for CommandError.
-
libvcs._internal.run.run(args, bufsize=-1, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=(), *, encoding=None, errors=None, user=None, group=None, extra_groups=None, umask=-1, log_in_real_time=False, check_returncode=True, callback=None)¶
Run a command.
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.- Parameters:
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: http://docs.python.org/library/subprocess.html#popen-constructor
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.CommandErrorshould 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): sys.stdout.write(output) sys.stdout.flush() run(['git', 'pull'], callback=progress_cb)
changes (Upcoming)
----------------
3.10 (When minimum python >=)
pipesize (int = -1 will be added after umask.)
bufsize (int)
executable (StrOrBytesPath | None)
stdin (_FILE | None)
stdout (_FILE | None)
stderr (_FILE | None)
close_fds (bool)
env (_ENV | None)
creationflags (int)
restore_signals (bool)
start_new_session (bool)
pass_fds (Any)
umask (int)
- Return type: