From d869e316b8c8aacdfc6b9cec3e545da8275c5421 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Mon, 24 Feb 2025 22:23:47 -0800 Subject: [PATCH] suppress printing errors to the terminal --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 75615a9..fd47e48 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,7 @@ V 1.2.1 import curses from pubsub import pub import os +import contextlib import logging import traceback import threading @@ -82,8 +83,9 @@ def main(stdscr): raise if __name__ == "__main__": - try: - curses.wrapper(main) - except Exception as e: - logging.error("Fatal error in curses wrapper: %s", e) - logging.error("Traceback: %s", traceback.format_exc()) \ No newline at end of file + with open(os.devnull, 'w') as fnull, contextlib.redirect_stderr(fnull), contextlib.redirect_stdout(fnull): + try: + curses.wrapper(main) + except Exception as e: + logging.error("Fatal error in curses wrapper: %s", e) + logging.error("Traceback: %s", traceback.format_exc()) \ No newline at end of file