def page(): """Capture output to stdout/stderr, and send it through ttypager when done""" out = StringIO() with redirect._redirect_stdout(out): with redirect._redirect_stderr(out): try: yield except: import traceback traceback.print_exc() ttypager_wrap(out.getvalue(), indent=False)
def page(): """Capture output to stdout/stderr, and send it through ttypager when done""" out = StringIO() with redirect._redirect_stdout(out): with redirect._redirect_stderr(out): try: yield output = out.getvalue() except: import traceback output = (traceback.format_exc() + "\nOutput produced before exception:\n\n" + out.getvalue()) ttypager_wrap(output, indent=False)
def page(): """Capture output to stdout/stderr, and send it through ttypager when done""" out = ProgressStringIO() with redirect._redirect_stdout(out): with redirect._redirect_stderr(out): try: yield output = out.getvalue() except: import traceback output = (traceback.format_exc() + "\nOutput produced before exception:\n\n" + out.getvalue()) ttypager_wrap(output, indent=False)