From 4a85353b3de889575d2a0b2f415ee8673e6f7037 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 23 Aug 2020 12:14:00 +0200 Subject: [PATCH] Fixed issues when importing from non terminal --- bpytop.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bpytop.py b/bpytop.py index 89b6860..3010694 100755 --- a/bpytop.py +++ b/bpytop.py @@ -470,8 +470,10 @@ class Config: try: CONFIG: Config = Config(CONFIG_FILE) - if DEBUG: - errlog.setLevel(DEBUG) + if not __name__ == "__main__": + errlog.setLevel(logging.ERROR) + elif DEBUG: + errlog.setLevel(logging.DEBUG) else: errlog.setLevel(getattr(logging, CONFIG.log_level)) if CONFIG.log_level == "DEBUG": DEBUG = True @@ -501,8 +503,11 @@ if psutil.version_info[0] < 5 or (psutil.version_info[0] == 5 and psutil.version class Term: """Terminal info and commands""" - width: int = os.get_terminal_size().columns #* Current terminal width in columns - height: int = os.get_terminal_size().lines #* Current terminal height in lines + width: int = 0 + height: int = 0 + if __name__ == "__main__": + width = os.get_terminal_size().columns + height = os.get_terminal_size().lines resized: bool = False _w : int = 0 _h : int = 0