From 831495923a70012328a9ec53862491477167c3d0 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 30 May 2023 15:42:17 -0600 Subject: [PATCH] Support crash logging in CLI code --- Build-Binary.command | 2 +- resources/logging_handler.py | 1 + resources/wx_gui/gui_entry.py | 4 ++++ resources/wx_gui/gui_update.py | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Build-Binary.command b/Build-Binary.command index e1c886f6b..94b5da9ea 100755 --- a/Build-Binary.command +++ b/Build-Binary.command @@ -48,7 +48,7 @@ class CreateBinary: """ os.chdir(Path(__file__).resolve().parent) - print(f"Current Working Directory: \n\t{os.getcwd()}") + print(f"Current Working Directory:\n- {os.getcwd()}") def _parse_arguments(self): diff --git a/resources/logging_handler.py b/resources/logging_handler.py index 242f70d20..88bed6e20 100644 --- a/resources/logging_handler.py +++ b/resources/logging_handler.py @@ -213,6 +213,7 @@ class InitializeLoggingSupport: self._display_debug_properties() if self.constants.cli_mode is True: + threading.Thread(target=analytics_handler.Analytics(self.constants).send_crash_report, args=(self.log_filepath,)).start() return error_msg = f"OpenCore Legacy Patcher encountered the following internal error:\n\n" diff --git a/resources/wx_gui/gui_entry.py b/resources/wx_gui/gui_entry.py index c2bcda0ff..f7d2764cf 100644 --- a/resources/wx_gui/gui_entry.py +++ b/resources/wx_gui/gui_entry.py @@ -52,6 +52,10 @@ class EntryPoint: patches = sys_patch_detect.DetectRootPatch(self.constants.computer.real_model, self.constants).detect_patch_set() logging.info(f"Entry point set: {entry.__name__}") + + # Normally set by main.py, but transitions from CLI mode may not have this set + self.constants.gui_mode = True + self.frame: wx.Frame = entry( None, title=f"{self.constants.patcher_name} ({self.constants.patcher_version})", diff --git a/resources/wx_gui/gui_update.py b/resources/wx_gui/gui_update.py index b3e862ef0..43ddfcc3f 100644 --- a/resources/wx_gui/gui_update.py +++ b/resources/wx_gui/gui_update.py @@ -52,6 +52,9 @@ class UpdateFrame(wx.Frame): version_label = dict[key]["Version"] url = dict[key]["Link"] break + else: + wx.MessageBox("Failed to get update info", "Critical Error") + sys.exit(1) self.version_label = version_label self.url = url