capture_output
(class from pyomo.common.tee)
- class pyomo.common.tee.capture_output(output=None, capture_fd=False)[source]
Bases:
objectContext manager to capture output sent to sys.stdout and sys.stderr
This is a drop-in substitute for PyUtilib’s capture_output to temporarily redirect output to the provided stream or file.
- Parameters:
output (io.TextIOBase, TeeStream, str, or None) – Output stream where all captured stdout/stderr data is sent. If a
stris provided, it is used as a file name and opened (potentially overwriting any existing file). IfNone, aio.StringIOobject is created and used.capture_fd (bool) – If True, we will also redirect the process file descriptors
1(stdout),2(stderr), and the file descriptors fromsys.stdout.fileno()andsys.stderr.fileno()to theoutput. This is useful for capturing output emitted directly to the process stdout / stderr by external compiled modules.
- Returns:
This is the output stream object where all data is sent.
- Return type:
Methods
__init__([output, capture_fd])reset()setup()Member Documentation