From b90956dc4a3be2f6d74f3d777efd5904106cf867 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Thu, 19 May 2022 08:55:51 -0600 Subject: [PATCH] gui_main.py: Add extra error handling for payload unpacking --- gui/gui_main.py | 25 +++++++++++++++++++++---- resources/reroute_payloads.py | 2 -- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gui/gui_main.py b/gui/gui_main.py index 5b868071b..b2379bcc5 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -107,6 +107,23 @@ class wx_python_gui: if self.constants.host_is_non_metal is True: return True return False + + def is_unpack_finished(self): + if not self.constants.unpack_thread.is_alive(): + if Path(self.constants.payload_path).exists(): + return True + else: + # Raise error to end program + self.popup = wx.MessageDialog( + self.frame, + f"During unpacking of our internal files, we seemed to have encountered an error.\n\nIf you keep seeing this error, please try redownloading the application.", + "Internal Error occured!", + style = wx.OK | wx.ICON_EXCLAMATION + ) + self.popup.ShowModal() + self.frame.Freeze() + self.OnCloseFrame(None) + return False def pulse_alternative(self, progress_bar): if self.non_metal_required is True: @@ -565,7 +582,7 @@ class wx_python_gui: def build_start(self, event=None): self.build_opencore.Disable() - while self.constants.unpack_thread.is_alive(): + while self.is_unpack_finished() is False: time.sleep(0.1) build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore() @@ -1023,7 +1040,7 @@ class wx_python_gui: self.frame.SetSize(-1, self.progress_bar.GetPosition().y + self.progress_bar.GetSize().height + 60) self.frame.Show() - while self.constants.unpack_thread.is_alive(): + while self.is_unpack_finished() is False: self.pulse_alternative(self.progress_bar) wx.GetApp().Yield() @@ -1169,7 +1186,7 @@ class wx_python_gui: sys.stdout = menu_redirect.RedirectText(self.text_box, True) sys.stderr = menu_redirect.RedirectText(self.text_box, True) wx.GetApp().Yield() - while self.constants.unpack_thread.is_alive(): + while self.is_unpack_finished() is False: time.sleep(0.1) try: sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, self.patches).start_unpatch() @@ -1288,7 +1305,7 @@ class wx_python_gui: thread_ia = threading.Thread(target=ia) thread_ia.start() - while thread_ia.is_alive() or self.constants.unpack_thread.is_alive(): + while thread_ia.is_alive() or self.is_unpack_finished() is False: self.pulse_alternative(self.progress_bar) wx.GetApp().Yield() available_installers = self.available_installers diff --git a/resources/reroute_payloads.py b/resources/reroute_payloads.py index 2a407e60a..bd3750da1 100644 --- a/resources/reroute_payloads.py +++ b/resources/reroute_payloads.py @@ -42,8 +42,6 @@ class reroute_payloads: print("- Failed to mount payloads.dmg") print(f"Output: {output.stdout.decode()}") print(f"Return Code: {output.returncode}") - print("- Exiting...") - sys.exit(1) def unmount_active_dmgs(self): # Find all DMGs that are mounted, and forcefully unmount them