diff --git a/resources/build/build.py b/resources/build/build.py index b4381270e..dddebb624 100644 --- a/resources/build/build.py +++ b/resources/build/build.py @@ -7,6 +7,7 @@ import plistlib import shutil import zipfile import logging +import time from pathlib import Path from datetime import date @@ -145,6 +146,8 @@ class BuildOpenCore: support.BuildSupport(self.model, self.constants, self.config).cleanup() self._save_config() + time.sleep(5) + # Post-build handling support.BuildSupport(self.model, self.constants, self.config).sign_files() support.BuildSupport(self.model, self.constants, self.config).validate_pathing() diff --git a/resources/install.py b/resources/install.py index f5906ab17..9ae2b8623 100644 --- a/resources/install.py +++ b/resources/install.py @@ -100,6 +100,8 @@ class tui_disk_installation: " without altering line endings", ] + logging.info(f"- Mounting partition: {full_disk_identifier}") + if self.constants.detected_os >= os_data.os_data.el_capitan and not self.constants.recovery_status: result = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: @@ -128,8 +130,6 @@ class tui_disk_installation: ssd_type = False mount_path = Path(partition_info["MountPoint"]) disk_type = partition_info["BusProtocol"] - utilities.cls() - utilities.header(["Copying OpenCore"]) if mount_path.exists(): if (mount_path / Path("EFI/Microsoft")).exists() and self.constants.gui_mode is False: diff --git a/resources/wx_gui/gui_build.py b/resources/wx_gui/gui_build.py index e66b23da6..ad0e66938 100644 --- a/resources/wx_gui/gui_build.py +++ b/resources/wx_gui/gui_build.py @@ -76,13 +76,23 @@ class BuildFrame(wx.Frame): def _invoke_build(self): + thread = threading.Thread(target=self._build) + thread.start() + + while thread.is_alive(): + wx.Yield() + + self.install_button.Enable() + + + def _build(self): """ Calls build function and redirects stdout to the text box """ - logging.getLogger().handlers[0].stream = gui_support.RedirectText(self.text_box, False) + logger = logging.getLogger() + logger.addHandler(gui_support.ThreadHandler(self.text_box)) build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants) - logging.getLogger().handlers[0].stream = self.stock_output - self.install_button.Enable() + logger.removeHandler(logger.handlers[2]) def on_return_to_main_menu(self, event): diff --git a/resources/wx_gui/gui_install_oc.py b/resources/wx_gui/gui_install_oc.py index 09540f69d..f6d5716fa 100644 --- a/resources/wx_gui/gui_install_oc.py +++ b/resources/wx_gui/gui_install_oc.py @@ -15,6 +15,7 @@ class InstallOCFrame(wx.Frame): self.constants: constants.Constants = global_constants self.title: str = title + self.result: bool = False self.available_disks: dict = None self.stock_output = logging.getLogger().handlers[0].stream @@ -220,20 +221,19 @@ class InstallOCFrame(wx.Frame): self.dialog = dialog # Install OpenCore - self._install_oc(partition) + self._invoke_install_oc(partition) return_button.Enable() - def _install_oc(self, partition: dict) -> None: - """ - Install OpenCore to disk - """ - logging.info(f"- Installing OpenCore to {partition}") - logging.getLogger().handlers[0].stream = gui_support.RedirectText(self.text_box, False) - result = install.tui_disk_installation(self.constants).install_opencore(partition) - logging.getLogger().handlers[0].stream = self.stock_output + def _invoke_install_oc(self, partition: dict) -> None: + thread = threading.Thread(target=self._install_oc, args=(partition,)) + thread.start() - if result is True: + while thread.is_alive(): + # wx.Yield() + wx.GetApp().Yield() + + if self.result is True: if not self.constants.custom_model: gui_support.RestartHost(self).restart(message="OpenCore has finished installing to disk.\n\nYou will need to reboot and hold the Option key and select OpenCore/Boot EFI's option.\n\nWould you like to reboot?") else: @@ -245,6 +245,18 @@ class InstallOCFrame(wx.Frame): popup_message.ShowModal() + def _install_oc(self, partition: dict) -> None: + """ + Install OpenCore to disk + """ + logging.info(f"- Installing OpenCore to {partition}") + + logger = logging.getLogger() + logger.addHandler(gui_support.ThreadHandler(self.text_box)) + self.result = install.tui_disk_installation(self.constants).install_opencore(partition) + logger.removeHandler(logger.handlers[2]) + + def _reload_frame(self, event) -> None: """ Reload frame diff --git a/resources/wx_gui/gui_support.py b/resources/wx_gui/gui_support.py index 8271fb8dc..98c05fe64 100644 --- a/resources/wx_gui/gui_support.py +++ b/resources/wx_gui/gui_support.py @@ -8,6 +8,16 @@ import subprocess from resources import constants + +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') + + class RedirectText(object): """ Redirects stdout to a wxPython TextCtrl diff --git a/resources/wx_gui/gui_sys_patch.py b/resources/wx_gui/gui_sys_patch.py index 86ba38666..7fd1d8a95 100644 --- a/resources/wx_gui/gui_sys_patch.py +++ b/resources/wx_gui/gui_sys_patch.py @@ -20,13 +20,13 @@ class SysPatchMenu(wx.Frame): Uses a Modal Dialog for smoother transition from other frames """ def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None): - super(SysPatchMenu, self).__init__(parent, title=title, size=(350, 250)) + super(SysPatchMenu, self).__init__(parent, title=title, size=(350, 260)) self.title = title self.constants: constants.Constants = global_constants self.frame_modal: wx.Dialog = None - self.frame_modal = wx.Dialog(self, title=title, size=(370, 200)) + self.frame_modal = wx.Dialog(self, title=title, size=(360, 200)) self._generate_elements(self.frame_modal) @@ -116,26 +116,29 @@ class SysPatchMenu(wx.Frame): # Button: Start Root Patching - start_button = wx.Button(frame, label="Start Root Patching", pos=(10, patch_label.GetPosition().y + 40), size=(170, 30)) + start_button = wx.Button(frame, label="Start Root Patching", pos=(10, patch_label.GetPosition().y + 20), size=(170, 30)) start_button.Bind(wx.EVT_BUTTON, lambda event: self._start_root_patching(frame, patches, no_new_patches)) start_button.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) start_button.Center(wx.HORIZONTAL) # Button: Revert Root Patches - revert_button = wx.Button(frame, label="Revert Root Patches", pos=(10, start_button.GetPosition().y + start_button.GetSize().height - 5 - ), size=(170, 30)) + revert_button = wx.Button(frame, label="Revert Root Patches", pos=(10, start_button.GetPosition().y + start_button.GetSize().height - 5), size=(170, 30)) revert_button.Bind(wx.EVT_BUTTON, lambda event: self._revert_root_patching(frame, patches, can_unpatch)) revert_button.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) revert_button.Center(wx.HORIZONTAL) # Button: Return to Main Menu - return_button = wx.Button(frame, label="Return to Main Menu", pos=(10, revert_button.GetPosition().y + revert_button.GetSize().height + 10), size=(150, 30)) + return_button = wx.Button(frame, label="Return to Main Menu", pos=(10, revert_button.GetPosition().y + revert_button.GetSize().height), size=(150, 30)) return_button.Bind(wx.EVT_BUTTON, self.on_return_to_main_menu) return_button.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) return_button.Center(wx.HORIZONTAL) + if not patches: + start_button.Disable() + revert_button.Disable() + # Set frame size - frame.SetSize((-1, return_button.GetPosition().y + return_button.GetSize().height + 40)) + frame.SetSize((-1, return_button.GetPosition().y + return_button.GetSize().height + 35))