diff --git a/resources/wx_gui/gui_install_oc.py b/resources/wx_gui/gui_install_oc.py index fbe117435..b8236745b 100644 --- a/resources/wx_gui/gui_install_oc.py +++ b/resources/wx_gui/gui_install_oc.py @@ -76,9 +76,11 @@ class InstallOCFrame(wx.Frame): # Need to clean up output on pre-Sierra # Disk images are mixed in with regular disks (ex. payloads.dmg) + ignore = ["disk image", "read-only", "virtual"] for disk in self.available_disks.copy(): - if "read-only" in self.available_disks[disk]['name']: - del self.available_disks[disk] + for string in ignore: + if string in self.available_disks[disk]['name'].lower(): + del self.available_disks[disk] def _display_disks(self) -> None: diff --git a/resources/wx_gui/gui_macos_installer_download.py b/resources/wx_gui/gui_macos_installer_download.py index 430a12f79..23be682e6 100644 --- a/resources/wx_gui/gui_macos_installer_download.py +++ b/resources/wx_gui/gui_macos_installer_download.py @@ -98,12 +98,12 @@ class macOSInstallerDownloadFrame(wx.Frame): self.Show() # Grab installer catalog - def fetch_installers(): + def _fetch_installers(): remote_obj = macos_installer_handler.RemoteInstallerCatalog(seed_override=macos_installer_handler.SeedType.DeveloperSeed) self.available_installers = remote_obj.available_apps self.available_installers_latest = remote_obj.available_apps_latest - thread = threading.Thread(target=fetch_installers) + thread = threading.Thread(target=_fetch_installers) thread.start() while thread.is_alive(): diff --git a/resources/wx_gui/gui_macos_installer_flash.py b/resources/wx_gui/gui_macos_installer_flash.py index 6aa4ad13e..45fae96d2 100644 --- a/resources/wx_gui/gui_macos_installer_flash.py +++ b/resources/wx_gui/gui_macos_installer_flash.py @@ -151,17 +151,19 @@ class macOSInstallerFlashFrame(wx.Frame): self.SetSize((-1, progress_bar.GetPosition()[1] + progress_bar.GetSize()[1] + 40)) # Fetch local disks - def fetch_disks(): + def _fetch_disks(): self.available_disks = macos_installer_handler.InstallerCreation().list_disk_to_format() # Need to clean up output on pre-Sierra # Disk images are mixed in with regular disks (ex. payloads.dmg) + ignore = ["disk image", "read-only", "virtual"] for disk in self.available_disks.copy(): - if "read-only" in self.available_disks[disk]['name']: - del self.available_disks[disk] + for string in ignore: + if string in self.available_disks[disk]['name'].lower(): + del self.available_disks[disk] - thread = threading.Thread(target=fetch_disks) + thread = threading.Thread(target=_fetch_disks) thread.start() while thread.is_alive(): @@ -198,7 +200,7 @@ class macOSInstallerFlashFrame(wx.Frame): # Search for disks again search_button = wx.Button(self.frame_modal, label="Search for disks again", pos=(-1, disk_button.GetPosition()[1] + disk_button.GetSize()[1]), size=(160, 30)) - search_button.Bind(wx.EVT_BUTTON, self.on_select) + search_button.Bind(wx.EVT_BUTTON, lambda event, temp=installer: self.on_select(temp)) search_button.Center(wx.HORIZONTAL) # Button: Return to Main Menu @@ -276,21 +278,25 @@ class macOSInstallerFlashFrame(wx.Frame): root_disk = disk['identifier'][5:] initial_bytes_written = float(utilities.monitor_disk_output(root_disk)) self.result = False - def flash(): + def _flash(): self.result = self._flash_installer(root_disk) - thread = threading.Thread(target=flash) + thread = threading.Thread(target=_flash) thread.start() # Wait for installer to be created while thread.is_alive(): - total_bytes_written = float(utilities.monitor_disk_output(root_disk)) + try: + total_bytes_written = float(utilities.monitor_disk_output(root_disk)) + except: + pass bytes_written = total_bytes_written - initial_bytes_written wx.CallAfter(bytes_written_label.SetLabel, f"Bytes Written: {bytes_written:.2f} MB") wx.CallAfter(progress_bar.SetValue, int(bytes_written)) wx.Yield() if self.result is False: + self.on_return_to_main_menu() return # Next verify the installer @@ -361,7 +367,6 @@ class macOSInstallerFlashFrame(wx.Frame): logging.info("- Failed to create macOS installer") popup = wx.MessageDialog(self, f"Failed to create macOS installer\n\nOutput: {output}\n\nError: {error}", "Error", wx.OK | wx.ICON_ERROR) popup.ShowModal() - self.on_return_to_main_menu() return False logging.info("- Successfully created macOS installer") @@ -513,7 +518,7 @@ class macOSInstallerFlashFrame(wx.Frame): def _validate_installer_pkg(self, disk: str) -> bool: verification_success = False error_message = "" - def integrity_check(): + def _integrity_check(): nonlocal error_message path = utilities.grab_mount_point_from_disk(disk + "s2") dmg_path = path + f"/{path.split('/')[2]}.app/Contents/SharedSupport/SharedSupport.dmg" @@ -531,7 +536,7 @@ class macOSInstallerFlashFrame(wx.Frame): error_message += "\n\nSTDERR: " + result.stderr.decode("utf-8") - thread = threading.Thread(target=integrity_check) + thread = threading.Thread(target=_integrity_check) thread.start() while thread.is_alive(): wx.Yield() @@ -546,6 +551,9 @@ class macOSInstallerFlashFrame(wx.Frame): def on_return_to_main_menu(self, event: wx.Event = None): if self.frame_modal: self.frame_modal.Hide() + if self: + if isinstance(self, wx.Frame): + self.Hide() main_menu_frame = gui_main_menu.MainFrame( None, title=self.title, @@ -555,4 +563,6 @@ class macOSInstallerFlashFrame(wx.Frame): main_menu_frame.Show() if self.frame_modal: self.frame_modal.Destroy() - self.Destroy() \ No newline at end of file + if self: + if isinstance(self, wx.Frame): + self.Destroy() \ No newline at end of file diff --git a/resources/wx_gui/gui_sys_patch.py b/resources/wx_gui/gui_sys_patch.py index df2ca7d53..56f0be106 100644 --- a/resources/wx_gui/gui_sys_patch.py +++ b/resources/wx_gui/gui_sys_patch.py @@ -80,10 +80,10 @@ class SysPatchFrame(wx.Frame): # Generate KDK object self.kdk_obj: kdk_handler.KernelDebugKitObject = None - def kdk_thread_spawn(): + def _kdk_thread_spawn(): self.kdk_obj = kdk_handler.KernelDebugKitObject(self.constants, self.constants.detected_os_build, self.constants.detected_os_version) - kdk_thread = threading.Thread(target=kdk_thread_spawn) + kdk_thread = threading.Thread(target=_kdk_thread_spawn) kdk_thread.start() while kdk_thread.is_alive():