util.subprocess

Module Contents

exception util.subprocess.VerboseCalledProcessError(returncode, cmd, output=None, stderr=None)

Bases: subprocess.CalledProcessError

A CalledProcessError that includes captured stderr in its string representation.

util.subprocess.subprocess_run(cmd, *, check=False, skip_frames=0, stderr=None, **kwargs)

A simple wrapper for the real subprocess.run() that logs the command used.

When stderr=subprocess.PIPE and check=True, automatically converts CalledProcessError to VerboseCalledProcessError with captured stderr details.

util.subprocess.subprocess_Popen(cmd, *, skip_frames=0, **kwargs)

A simple wrapper for the real subprocess.Popen() that logs the command used.

util.subprocess.subprocess_stream(cmd, *, check=False, skip_frames=0, stderr=None, **kwargs)

Run ‘cmd’ via subprocess.Popen() and return an iterator over any lines the command outputs on stdout, in text mode.

When stderr=subprocess.PIPE and check=True, automatically converts CalledProcessError to VerboseCalledProcessError with captured stderr details.

To capture both stdout and stderr as yielded lines, use stderr=subprocess.STDOUT.