From 5f30adab73902470389220bdd238164138998179 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Mon, 22 May 2023 12:38:39 -0600 Subject: [PATCH] logging_handler.py: Add CLI check --- resources/constants.py | 2 +- resources/logging_handler.py | 3 +++ resources/main.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/constants.py b/resources/constants.py index fd800a3a2..fa0dc916f 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -117,7 +117,7 @@ class Constants: ## Internal settings self.allow_oc_everywhere: bool = False # Set whether Patcher can be run on unsupported Macs self.gui_mode: bool = False # Determine whether running in a GUI or TUI - self.cli_mode: bool = False # Determine if running in CLI mode + self.cli_mode: bool = True # Determine if running in CLI mode self.validate: bool = False # Enable validation testing for CI self.recovery_status: bool = False # Detect if booted into RecoveryOS self.ignore_updates: bool = False # Ignore OCLP updates diff --git a/resources/logging_handler.py b/resources/logging_handler.py index cddaa85e0..88cdc2022 100644 --- a/resources/logging_handler.py +++ b/resources/logging_handler.py @@ -159,6 +159,9 @@ class InitializeLoggingSupport: """ logging.error("Uncaught exception in main thread", exc_info=(type, value, tb)) + if self.constants.cli_mode is True: + return + error_msg = f"OpenCore Legacy Patcher encountered the following internal error:\n\n" error_msg += f"{type.__name__}: {value}" if tb: diff --git a/resources/main.py b/resources/main.py index f2ab0dc38..770a68729 100644 --- a/resources/main.py +++ b/resources/main.py @@ -93,6 +93,7 @@ class OpenCoreLegacyPatcher: threading.Thread(target=analytics_handler.Analytics, args=(self.constants,)).start() if utilities.check_cli_args() is None: + self.constants.cli_mode = False logging.info(f"- No arguments present, loading {'GUI' if self.constants.wxpython_variant is True else 'TUI'} mode") return @@ -102,7 +103,6 @@ class OpenCoreLegacyPatcher: ignore_args = ["--auto_patch", "--gui_patch", "--gui_unpatch", "--update_installed"] if not any(x in sys.argv for x in ignore_args): self.constants.current_path = Path.cwd() - self.constants.cli_mode = True if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"): logging.info("- Rerouting payloads location") self.constants.payload_path = sys._MEIPASS / Path("payloads")