sys_patch.py: Add network error handling

This commit is contained in:
Mykola Grymalyuk
2022-01-18 11:16:44 -07:00
parent b4830dfd0b
commit be3e7da342
4 changed files with 84 additions and 32 deletions
+10 -6
View File
@@ -6,15 +6,19 @@ To install UEFI is actually super simple! All it requires is to boot Windows' In
* Note: UEFI Windows is generally quite usable for Arrendale and newer models, however machines with Penryn CPUs may experience issues
* Recommended Models:
* MacBookAir4,x and newer
* MacBookPro8,x and newer
* Macmini5,x and newer
* iMac11,x and newer
* MacPro4,1 and newer
* Xserve3,1 and newer
* MacBookAir4,x - 5,x
* MacBookPro8,x - 10,x
* Macmini5,x - 6,x
* iMac11,x - 13,x
Once you know your model is supported, you're good to go with the rest of this guide
* Newer models than listed here will already natively support UEFI Windows through Boot Camp
For Mac Pro and Xserve users, please be aware that Windows has troubles with automatic installation, so please refer to cdf's guide on manual installation:
* [cdf's Mac Pro Thread](https://forums.macrumors.com/threads/opencore-on-the-mac-pro.2207814/)
## Disk Formatting
To start off, we'll need the following:
+57 -14
View File
@@ -34,7 +34,7 @@ class wx_python_gui:
self.WINDOW_HEIGHT_MAIN = 220
self.WINDOW_WIDTH_BUILD = 400
self.WINDOW_HEIGHT_BUILD = 500
self.WINDOW_SETTINGS_WIDTH = 230
self.WINDOW_SETTINGS_WIDTH = 250
self.WINDOW_SETTINGS_HEIGHT = 320
# Create Application
@@ -816,9 +816,23 @@ class wx_python_gui:
# Download resources
sys.stdout=menu_redirect.RedirectLabel(self.developer_note)
sys_patch_download.grab_patcher_support_pkg(self.constants).download_files()
download_result, os_ver, link = sys_patch_download.grab_patcher_support_pkg(self.constants).download_files()
sys.stdout=sys.__stdout__
if download_result is None:
# Create popup window to inform user of error
self.popup = wx.MessageDialog(
self.frame,
"A problem occured trying to download PatcherSupportPkg binaries\n\nIf you continue to have this error, download an Offline build from Github\nThese builds don't require a network connection to root patch",
"Network Error",
wx.YES_NO | wx.ICON_ERROR
)
self.popup.SetYesNoLabels("View on Github", "Ignore")
answer = self.popup.ShowModal()
if answer == wx.ID_YES:
webbrowser.open(self.constants.repo_link_latest)
self.main_menu()
self.subheader.SetLabel("Starting root volume patching")
self.developer_note.SetLabel("Starting shortly")
self.subheader.Centre(wx.HORIZONTAL)
@@ -1383,6 +1397,35 @@ class wx_python_gui:
self.header.SetFont(wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
self.header.Centre(wx.HORIZONTAL)
# Subheader
self.subheader = wx.StaticText(self.frame, label="Changing settings here require you")
self.subheader.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
self.subheader.SetPosition(
wx.Point(
self.header.GetPosition().x,
self.header.GetPosition().y + self.header.GetSize().height + 10
)
)
self.subheader.Centre(wx.HORIZONTAL)
self.subheader2 = wx.StaticText(self.frame, label="to run 'Build and Install OpenCore'")
self.subheader2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
self.subheader2.SetPosition(
wx.Point(
self.subheader.GetPosition().x,
self.subheader.GetPosition().y + self.subheader.GetSize().height
)
)
self.subheader2.Centre(wx.HORIZONTAL)
self.subheader3 = wx.StaticText(self.frame, label="then reboot for changes to be applied")
self.subheader3.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
self.subheader3.SetPosition(
wx.Point(
self.subheader2.GetPosition().x,
self.subheader2.GetPosition().y + self.subheader2.GetSize().height
)
)
self.subheader3.Centre(wx.HORIZONTAL)
# Dropdown
self.dropdown_model = wx.Choice(self.frame)
for model in model_array.SupportedSMBIOS:
@@ -1394,8 +1437,8 @@ class wx_python_gui:
self.dropdown_model.SetSelection(self.dropdown_model.GetItems().index(self.constants.custom_model or self.computer.real_model))
self.dropdown_model.SetPosition(
wx.Point(
self.header.GetPosition().x,
self.header.GetPosition().y + self.header.GetSize().height + 10
self.subheader3.GetPosition().x,
self.subheader3.GetPosition().y + self.subheader3.GetSize().height + 10
)
)
# Set size to largest item
@@ -1740,8 +1783,8 @@ class wx_python_gui:
self.debug_button.Center(wx.HORIZONTAL)
# Button: return to main menu
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Main Menu")
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.main_menu)
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Settings")
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.settings_menu)
self.return_to_main_menu_button.SetPosition(wx.Point(
self.debug_button.GetPosition().x,
self.debug_button.GetPosition().y + self.debug_button.GetSize().height + 10))
@@ -1962,11 +2005,11 @@ class wx_python_gui:
self.native_spoof_checkbox.Disable()
# Button: Return to Main Menu
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Main Menu")
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Settings")
self.return_to_main_menu_button.SetPosition(
wx.Point(self.native_spoof_checkbox.GetPosition().x, self.native_spoof_checkbox.GetPosition().y + self.native_spoof_checkbox.GetSize().height + 10)
)
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.main_menu)
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.settings_menu)
self.return_to_main_menu_button.Center(wx.HORIZONTAL)
self.frame.SetSize(wx.Size(-1, self.return_to_main_menu_button.GetPosition().y + self.return_to_main_menu_button.GetSize().height + 40))
@@ -2068,11 +2111,11 @@ class wx_python_gui:
self.launcher_script_textbox.Center(wx.HORIZONTAL)
self.launcher_script_textbox.SetEditable(False)
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Main Menu")
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Settings")
self.return_to_main_menu_button.SetPosition(
wx.Point(self.launcher_script_textbox.GetPosition().x, self.launcher_script_textbox.GetPosition().y + self.launcher_script_textbox.GetSize().height + 10)
)
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.main_menu)
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.settings_menu)
self.return_to_main_menu_button.Center(wx.HORIZONTAL)
# Set frame below return to main menu button
@@ -2171,11 +2214,11 @@ OpenCore Legacy Patcher by default knows the most ideal
self.sip_checkbox.SetValue(True)
# Button: returns to the main menu
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Main Menu")
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Settings")
self.return_to_main_menu_button.SetPosition(
wx.Point(self.sip_checkbox.GetPosition().x, self.sip_checkbox.GetPosition().y + self.sip_checkbox.GetSize().height + 15)
)
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.main_menu)
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.settings_menu)
self.return_to_main_menu_button.Center(wx.HORIZONTAL)
# Set the frame size
@@ -2268,8 +2311,8 @@ OpenCore Legacy Patcher by default knows the most ideal
self.wake_on_wlan_checkbox.SetToolTip(wx.ToolTip("Enables Wake on WLAN for Broadcom Wifi.\nBy default, Wake on WLAN is disabled to work around Apple's wake from sleep bug causing heavily degraded networking performance.\nNote: This option is only applicable for BCM943224, BCM94331, BCM94360 and BCM943602 chipsets"))
# Button: return to main menu
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Main Menu")
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.main_menu)
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Settings")
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.settings_menu)
self.return_to_main_menu_button.SetPosition(wx.Point(
self.wake_on_wlan_checkbox.GetPosition().x,
self.wake_on_wlan_checkbox.GetPosition().y + self.wake_on_wlan_checkbox.GetSize().height + 10))
+2
View File
@@ -20,6 +20,8 @@ class Constants:
self.nightly_url_patcher_support_pkg = "https://nightly.link/dortania/PatcherSupportPkg/workflows/build/master/"
self.discord_link = "https://discord.gg/rqdPgH8xSN"
self.guide_link = "https://dortania.github.io/OpenCore-Legacy-Patcher/"
self.repo_link = "https://github.com/dortania/OpenCore-Legacy-Patcher"
self.repo_link_latest = f"{self.repo_link}/releases/tag/{self.patcher_version}"
# OpenCore Versioning
# https://github.com/acidanthera/OpenCorePkg
+15 -12
View File
@@ -644,11 +644,12 @@ set million colour before rebooting"""
patch_input = input("Would you like to redownload?(y/n): ")
if patch_input in {"y", "Y", "yes", "Yes"}:
shutil.rmtree(Path(self.constants.payload_apple_root_path))
self.download_files()
output = self.download_files()
else:
self.download_files()
output = self.download_files()
else:
self.download_files()
output = self.download_files()
return output
def download_files(self):
if self.constants.gui_mode is False:
@@ -672,12 +673,14 @@ set million colour before rebooting"""
print("- Couldn't unzip")
return None
else:
print("- Download failed, please verify the below link works:")
print(link)
if download_result is None and self.constants.gui_mode is False:
print("\nIf you continue to have issues, try using the Offline builds")
print("located on Github next to the other builds")
input("Press enter to exit")
if self.constants.gui_mode is True:
print("- Download failed, please verify the below link works:")
print(link)
print("\nIf you continue to have issues, try using the Offline builds")
print("located on Github next to the other builds")
else:
input("\nPress enter to continue")
return None
def detect_gpus(self):
gpus = self.constants.computer.gpus
@@ -905,14 +908,14 @@ set million colour before rebooting"""
change_menu = input("Would you like to continue with Root Volume Patching?(y/n): ")
else:
change_menu = "y"
print("Continuing root patching")
print("- Continuing root patching")
if change_menu in ["y", "Y"]:
print("- Continuing with Patching")
print("- Verifying whether Root Patching possible")
if self.verify_patch_allowed() is True:
print("- Patcher is capable of patching")
self.check_files()
self.find_mount_root_vol(True)
if self.check_files():
self.find_mount_root_vol(True)
elif self.constants.gui_mode is False:
input("\nPress [ENTER] to return to the main menu: ")