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:  
...    sys.stdout.write("mystdout")
...    sys.stderr.write("mystderr")
>>> print(out.stdout)  
mystdout
>>> print(out.stderr)  
mystderr