GUI: Add branch selection

This commit is contained in:
Mykola Grymalyuk
2023-05-16 11:35:54 -06:00
parent 652e8659e4
commit 0f55b074af

View File

@@ -15,7 +15,8 @@ from resources import (
constants,
global_settings,
defaults,
generate_smbios
generate_smbios,
network_handler
)
from data import (
model_array,
@@ -1180,15 +1181,35 @@ Hardware Information:
def on_nightly(self, event: wx.Event) -> None:
# Ask prompt for which branch
branches = ["main"]
result = network_handler.NetworkUtilities().get("https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/branches")
if result is not None:
result = result.json()
for branch in result:
if branch["name"] == "gh-pages":
continue
if branch["name"] not in branches:
branches.append(branch["name"])
with wx.SingleChoiceDialog(self.parent, "Which branch would you like to download?", "Branch Selection", branches) as dialog:
if dialog.ShowModal() == wx.ID_CANCEL:
return
branch = dialog.GetStringSelection()
else:
branch = "main"
gui_update.UpdateFrame(
parent=self.parent,
title=self.title,
global_constants=self.constants,
screen_location=self.parent.GetPosition(),
url="https://nightly.link/dortania/OpenCore-Legacy-Patcher/workflows/build-app-wxpython/main/OpenCore-Patcher.app%20%28GUI%29.zip",
url=f"https://nightly.link/dortania/OpenCore-Legacy-Patcher/workflows/build-app-wxpython/{branch}/OpenCore-Patcher.app%20%28GUI%29.zip",
version_label="(Nightly)"
)
def on_export_constants(self, event: wx.Event) -> None:
# Throw pop up to get save location
with wx.FileDialog(self.parent, "Save Constants File", wildcard="JSON files (*.txt)|*.txt", style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog: