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.CalledProcessErrorA more verbose version of
subprocess.CalledProcessError.Replaces the standard string representation of a
subprocess.CalledProcessErrorwith 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
CalledProcessErrorif 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().