def check_images(self): stdout, stderr = False, False saved_stdout, saved_stderr = sys.stdout, sys.stderr try: out, err = StringIO(), StringIO() sys.stdout, sys.stderr = out, err check_images_main() except SystemExit: pass finally: stdout, stderr = out.getvalue().strip(), err.getvalue().strip() sys.stdout, sys.stderr = saved_stdout, saved_stderr return stdout, stderr
def check_images(): """ Simulate execution of check_images utility main. """ saved_stdout, saved_stderr = sys.stdout, sys.stderr out, err = StringIO(), StringIO() try: sys.stdout, sys.stderr = out, err check_images_main() except SystemExit: pass finally: stdout, stderr = out.getvalue().strip(), err.getvalue().strip() sys.stdout, sys.stderr = saved_stdout, saved_stderr return stdout, stderr
def check_images(): """ Simulate execution of check_images utility main. """ saved_stdout, saved_stderr = sys.stdout, sys.stderr out, err = StringIO(), StringIO() try: sys.stdout, sys.stderr = out, err check_images_main() except SystemExit as ex: print("Encountered SystemExit exception, code {}".format(ex.code)) finally: stdout, stderr = out.getvalue().strip(), err.getvalue().strip() sys.stdout, sys.stderr = saved_stdout, saved_stderr return stdout, stderr