From 4068bc16617f1b5c3bffeedca907229fbe1cdeea Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sun, 7 May 2023 12:23:57 -0600 Subject: [PATCH] GUI: Wait for payloads.dmg mount --- resources/wx_gui/gui_build.py | 3 +++ resources/wx_gui/gui_entry.py | 1 + resources/wx_gui/gui_support.py | 29 +++++++++++++++++++++++++++++ resources/wx_gui/gui_sys_patch.py | 3 +++ 4 files changed, 36 insertions(+) diff --git a/resources/wx_gui/gui_build.py b/resources/wx_gui/gui_build.py index 7f5a9eefd..d0cbfbc5c 100644 --- a/resources/wx_gui/gui_build.py +++ b/resources/wx_gui/gui_build.py @@ -79,6 +79,9 @@ class BuildFrame(wx.Frame): def _invoke_build(self): + while gui_support.PayloadMount(self.constants, self).is_unpack_finished() is False: + wx.Yield() + thread = threading.Thread(target=self._build) thread.start() diff --git a/resources/wx_gui/gui_entry.py b/resources/wx_gui/gui_entry.py index 544e0883d..45c394fd1 100644 --- a/resources/wx_gui/gui_entry.py +++ b/resources/wx_gui/gui_entry.py @@ -20,6 +20,7 @@ class SupportedEntryPoints: MAIN_MENU = gui_main_menu.MainMenu BUILD_OC = gui_build.BuildFrame INSTALL_OC = gui_install_oc.InstallOCFrame + SYS_PATCH = gui_sys_patch.SysPatchMenu class EntryPoint: diff --git a/resources/wx_gui/gui_support.py b/resources/wx_gui/gui_support.py index a0c1f9c26..49dc9412b 100644 --- a/resources/wx_gui/gui_support.py +++ b/resources/wx_gui/gui_support.py @@ -6,14 +6,43 @@ import logging import subprocess +from pathlib import Path + from resources import constants +class PayloadMount: + + def __init__(self, global_constants: constants.Constants, frame: wx.Frame) -> None: + self.constants: constants.Constants = global_constants + self.frame: wx.Frame = frame + + + def is_unpack_finished(self): + if self.constants.unpack_thread.is_alive(): + return False + + if Path(self.constants.payload_kexts_path).exists(): + return True + + # Raise error to end program + 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 rebooting and redownloading the application.", + "Internal Error occurred!", + style = wx.OK | wx.ICON_EXCLAMATION + ) + popup.ShowModal() + self.frame.Freeze() + sys.exit(1) + class ThreadHandler(logging.Handler): + def __init__(self, text_box: wx.TextCtrl): logging.Handler.__init__(self) self.text_box = text_box + def emit(self, record): wx.CallAfter(self.text_box.AppendText, self.format(record) + '\n') diff --git a/resources/wx_gui/gui_sys_patch.py b/resources/wx_gui/gui_sys_patch.py index 93c58d8c5..104323f5d 100644 --- a/resources/wx_gui/gui_sys_patch.py +++ b/resources/wx_gui/gui_sys_patch.py @@ -336,6 +336,9 @@ class SysPatchMenu(wx.Frame): def start_root_patching(self, patches: dict): logging.info("Starting root patching") + while gui_support.PayloadMount(self.constants, self).is_unpack_finished() is False: + wx.Yield() + if patches["Settings: Kernel Debug Kit missing"] is True: if self._kdk_download(self) is False: self.on_return_to_main_menu()