obspy.core.util.misc.CatchOutput

CatchOutput()[source]

A context manager that captures input to stdout/stderr. Python level only!

Always use with “with” statement. Does nothing otherwise.

>>> with CatchOutput() as out:  # doctest: +SKIP
...    sys.stdout.write("mystdout")
...    sys.stderr.write("mystderr")
>>> print(out.stdout)  # doctest: +SKIP
mystdout
>>> print(out.stderr)  # doctest: +SKIP
mystderr