mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-21 06:30:52 +10:00
Add error handling for failed downloads
This commit is contained in:
+18
-2
@@ -992,6 +992,7 @@ class wx_python_gui:
|
|||||||
self.subheader.Centre(wx.HORIZONTAL)
|
self.subheader.Centre(wx.HORIZONTAL)
|
||||||
|
|
||||||
i = -20
|
i = -20
|
||||||
|
if avalible_installers:
|
||||||
for app in avalible_installers:
|
for app in avalible_installers:
|
||||||
print(f"macOS {avalible_installers[app]['Version']} ({avalible_installers[app]['Build']} - {utilities.human_fmt(avalible_installers[app]['Size'])} - {avalible_installers[app]['Source']})")
|
print(f"macOS {avalible_installers[app]['Version']} ({avalible_installers[app]['Build']} - {utilities.human_fmt(avalible_installers[app]['Size'])} - {avalible_installers[app]['Source']})")
|
||||||
self.install_selection = wx.Button(self.frame, label=f"macOS {avalible_installers[app]['Version']} ({avalible_installers[app]['Build']} - {utilities.human_fmt(avalible_installers[app]['Size'])})", size=(250, 30))
|
self.install_selection = wx.Button(self.frame, label=f"macOS {avalible_installers[app]['Version']} ({avalible_installers[app]['Build']} - {utilities.human_fmt(avalible_installers[app]['Size'])})", size=(250, 30))
|
||||||
@@ -1005,6 +1006,18 @@ class wx_python_gui:
|
|||||||
)
|
)
|
||||||
self.install_selection.Bind(wx.EVT_BUTTON, lambda event, temp=app: self.download_macos_click(f"macOS {avalible_installers[temp]['Version']} ({avalible_installers[temp]['Build']})", avalible_installers[temp]['Link']))
|
self.install_selection.Bind(wx.EVT_BUTTON, lambda event, temp=app: self.download_macos_click(f"macOS {avalible_installers[temp]['Version']} ({avalible_installers[temp]['Build']})", avalible_installers[temp]['Link']))
|
||||||
self.install_selection.Centre(wx.HORIZONTAL)
|
self.install_selection.Centre(wx.HORIZONTAL)
|
||||||
|
else:
|
||||||
|
self.install_selection = wx.StaticText(self.frame, label="No installers available")
|
||||||
|
i = i + 25
|
||||||
|
self.install_selection.SetPosition(
|
||||||
|
# Set Position right above bottom of frame
|
||||||
|
wx.Point(
|
||||||
|
self.subheader.GetPosition().x,
|
||||||
|
self.subheader.GetPosition().y + self.subheader.GetSize().height + i
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.install_selection.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
|
||||||
|
self.install_selection.Centre(wx.HORIZONTAL)
|
||||||
|
|
||||||
# Return to Main Menu
|
# Return to Main Menu
|
||||||
self.return_to_main_menu = wx.Button(self.frame, label="Return to Main Menu")
|
self.return_to_main_menu = wx.Button(self.frame, label="Return to Main Menu")
|
||||||
@@ -1058,8 +1071,7 @@ class wx_python_gui:
|
|||||||
self.frame.SetSize(-1, self.return_to_main_menu.GetPosition().y + self.return_to_main_menu.GetSize().height + 40)
|
self.frame.SetSize(-1, self.return_to_main_menu.GetPosition().y + self.return_to_main_menu.GetSize().height + 40)
|
||||||
|
|
||||||
# Download macOS install data
|
# Download macOS install data
|
||||||
installer.download_install_assistant(self.constants.payload_path, installer_link)
|
if installer.download_install_assistant(self.constants.payload_path, installer_link):
|
||||||
|
|
||||||
# Fix stdout
|
# Fix stdout
|
||||||
sys.stdout = self.stock_stdout
|
sys.stdout = self.stock_stdout
|
||||||
self.download_label.SetLabel(f"Finished Downloading {installer_name}")
|
self.download_label.SetLabel(f"Finished Downloading {installer_name}")
|
||||||
@@ -1077,6 +1089,10 @@ class wx_python_gui:
|
|||||||
self.return_to_main_menu.SetLabel("Flash Installer")
|
self.return_to_main_menu.SetLabel("Flash Installer")
|
||||||
self.return_to_main_menu.Bind(wx.EVT_BUTTON, self.flash_installer_menu)
|
self.return_to_main_menu.Bind(wx.EVT_BUTTON, self.flash_installer_menu)
|
||||||
self.return_to_main_menu.Centre(wx.HORIZONTAL)
|
self.return_to_main_menu.Centre(wx.HORIZONTAL)
|
||||||
|
else:
|
||||||
|
sys.stdout = self.stock_stdout
|
||||||
|
self.download_label.SetLabel(f"Failed to download {installer_name}")
|
||||||
|
self.download_label.Centre(wx.HORIZONTAL)
|
||||||
|
|
||||||
def flash_installer_menu(self, event=None):
|
def flash_installer_menu(self, event=None):
|
||||||
self.frame.DestroyChildren()
|
self.frame.DestroyChildren()
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ class RedirectLabel(object):
|
|||||||
self.out.Centre(wx.HORIZONTAL)
|
self.out.Centre(wx.HORIZONTAL)
|
||||||
wx.GetApp().Yield()
|
wx.GetApp().Yield()
|
||||||
|
|
||||||
|
def flush(self):
|
||||||
|
pass
|
||||||
|
|
||||||
class RedirectLabelAll(object):
|
class RedirectLabelAll(object):
|
||||||
def __init__(self,aWxTextCtrl):
|
def __init__(self,aWxTextCtrl):
|
||||||
self.out=aWxTextCtrl
|
self.out=aWxTextCtrl
|
||||||
|
|||||||
@@ -1165,11 +1165,14 @@ B. Exit
|
|||||||
self.download_macOS()
|
self.download_macOS()
|
||||||
|
|
||||||
def download_install_assistant(self, link):
|
def download_install_assistant(self, link):
|
||||||
installer.download_install_assistant(self.constants.payload_path, link)
|
if installer.download_install_assistant(self.constants.payload_path, link):
|
||||||
installer.install_macOS_installer(self.constants.payload_path)
|
installer.install_macOS_installer(self.constants.payload_path)
|
||||||
input("Press any key to continue...")
|
input("Press any key to continue...")
|
||||||
# To avoid selecting the wrong installer by mistake, let user select the correct one
|
# To avoid selecting the wrong installer by mistake, let user select the correct one
|
||||||
self.find_local_installer()
|
self.find_local_installer()
|
||||||
|
else:
|
||||||
|
print("Failed to start download")
|
||||||
|
input("Press any key to continue...")
|
||||||
|
|
||||||
|
|
||||||
def download_macOS_installer(self):
|
def download_macOS_installer(self):
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ def create_installer(installer_path, volume_name):
|
|||||||
|
|
||||||
def download_install_assistant(download_path, ia_link):
|
def download_install_assistant(download_path, ia_link):
|
||||||
# Downloads InstallAssistant.pkg
|
# Downloads InstallAssistant.pkg
|
||||||
utilities.download_file(ia_link, (Path(download_path) / Path("InstallAssistant.pkg")))
|
if utilities.download_file(ia_link, (Path(download_path) / Path("InstallAssistant.pkg"))):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def install_macOS_installer(download_path):
|
def install_macOS_installer(download_path):
|
||||||
args = [
|
args = [
|
||||||
@@ -85,7 +87,7 @@ def list_downloadable_macOS_installers(download_path, catalog):
|
|||||||
link = "https://swscan.apple.com/content/catalogs/others/index-12customerseed-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
|
link = "https://swscan.apple.com/content/catalogs/others/index-12customerseed-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
|
||||||
|
|
||||||
# Download and unzip the catalog
|
# Download and unzip the catalog
|
||||||
utilities.download_file(link, (Path(download_path) / Path("seed.sucatalog.gz")))
|
if utilities.download_file(link, (Path(download_path) / Path("seed.sucatalog.gz"))):
|
||||||
subprocess.run(["gunzip", "-d", "-f", Path(download_path) / Path("seed.sucatalog.gz")])
|
subprocess.run(["gunzip", "-d", "-f", Path(download_path) / Path("seed.sucatalog.gz")])
|
||||||
catalog_plist = plistlib.load((Path(download_path) / Path("seed.sucatalog")).open("rb"))
|
catalog_plist = plistlib.load((Path(download_path) / Path("seed.sucatalog")).open("rb"))
|
||||||
|
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ def download_file(link, location, is_gui=None):
|
|||||||
print(f"https://github.com/dortania/OpenCore-Legacy-Patcher/releases/download/{constants.Constants().patcher_version}/OpenCore-Patcher-TUI-Offline.app.zip")
|
print(f"https://github.com/dortania/OpenCore-Legacy-Patcher/releases/download/{constants.Constants().patcher_version}/OpenCore-Patcher-TUI-Offline.app.zip")
|
||||||
else:
|
else:
|
||||||
print(link)
|
print(link)
|
||||||
sys.exit()
|
return None
|
||||||
|
|
||||||
def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
|
def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
|
||||||
# When runnign through our GUI, we run as root, however we do not get uid 0
|
# When runnign through our GUI, we run as root, however we do not get uid 0
|
||||||
|
|||||||
Reference in New Issue
Block a user