subprocess¶
Exensions to Python’s subprocess
module.
More specifically, this module provides a customized version of
subprocess.run()
, which always sets check=True,
capture_output=True, enhances the raised exceptions string representation
with additional output information and makes it slightly more readable when
encountered in a stack trace.
-
exception
CalledProcessError
(returncode, cmd, output=None, stderr=None)[source]¶ Bases:
subprocess.CalledProcessError
A more verbose version of
subprocess.CalledProcessError
.Replaces the standard string representation of a
subprocess.CalledProcessError
with one that has more output and error information and is formatted to be more readable in a stack trace.
-
run
(*args, **kwargs)[source]¶ A “safer” version of
subprocess.run()
.“Safer” in this context means that this version always raises
CalledProcessError
if the process in question returns a non-zero exit status. This is done by setting check=True and capture_output=True, so you don’t have to specify these yourself anymore. You can though, if you want to override these defaults. Other than that, the function accepts the same parameters assubprocess.run()
.