logging_handler.py: Add CLI check

This commit is contained in:
Mykola Grymalyuk
2023-05-22 12:38:39 -06:00
parent 4c9c7965b6
commit 5f30adab73
3 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -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
+3
View File
@@ -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:
+1 -1
View File
@@ -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")