carputils
Doxygen code documentation for the python framework controlling openCARP
|
Execute external processes with output buffering and error checking. More...
Classes | |
class | DivertOutputError |
Functions | |
def | intercept_OSError (func) |
Decorator to intercept file not found OSErrors. More... | |
def | call (cmd, interactive=False, timeout=None, detached=False, stdout=None, stderr=None, args, kwargs) |
Run the specified command. More... | |
def | subprocess_exceptions () |
Make :func:call raise an exception on process non-zero exit status. More... | |
def | process_timeout (process, timeout) |
def | mp_one_run (run) |
Define how to start a single run with multiprocessing. More... | |
Execute external processes with output buffering and error checking.
def carputils.divertoutput.call | ( | cmd, | |
interactive = False , |
|||
timeout = None , |
|||
detached = False , |
|||
stdout = None , |
|||
stderr = None , |
|||
args, | |||
kwargs | |||
) |
Run the specified command.
This function manually captures the output and writes it to sys.stdout, meaning that replacing sys.stdout with a StringIO stream can be used to handle combined subprocess and python output more easily.
Example usage::
When used with the :func:subprocess_exceptions
context manager, checks the return code of the finished process and raises an exception if it did not exit correctly.
See also the :func:carputils.stream.divert_std
context manager, which allows control of the destination of the process output streams.
cmd | list of str List of command line arguments to execute. |
def carputils.divertoutput.intercept_OSError | ( | func | ) |
Decorator to intercept file not found OSErrors.
def carputils.divertoutput.mp_one_run | ( | run | ) |
Define how to start a single run with multiprocessing.
run = (num, total, cmd) where
num | run#; total: total number of runs; cmd: command line to run |
def carputils.divertoutput.process_timeout | ( | process, | |
timeout | |||
) |
def carputils.divertoutput.subprocess_exceptions | ( | ) |
Make :func:call
raise an exception on process non-zero exit status.
Example usage: