mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 06:10:00 +10:00
updates.py: Adjust private function names
This commit is contained in:
@@ -255,7 +255,7 @@ class wx_python_gui:
|
|||||||
if local_build_date <= installed_build_date:
|
if local_build_date <= installed_build_date:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif updates.check_binary_updates(self.constants).check_if_build_newer(local_version, application_version) is False:
|
elif updates.CheckBinaryUpdates(self.constants)._check_if_build_newer(local_version, application_version) is False:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Ask user if they want to move the application to the Applications folder
|
# Ask user if they want to move the application to the Applications folder
|
||||||
@@ -310,7 +310,7 @@ class wx_python_gui:
|
|||||||
if ignore_updates is not True:
|
if ignore_updates is not True:
|
||||||
self.constants.ignore_updates = False
|
self.constants.ignore_updates = False
|
||||||
self.constants.has_checked_updates = True
|
self.constants.has_checked_updates = True
|
||||||
dict = updates.check_binary_updates(self.constants).check_binary_updates()
|
dict = updates.CheckBinaryUpdates(self.constants).check_binary_updates()
|
||||||
if dict:
|
if dict:
|
||||||
for entry in dict:
|
for entry in dict:
|
||||||
version = dict[entry]["Version"]
|
version = dict[entry]["Version"]
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class AutomaticSysPatch:
|
|||||||
if patches[patch] is True and not patch.startswith("Settings") and not patch.startswith("Validation"):
|
if patches[patch] is True and not patch.startswith("Settings") and not patch.startswith("Validation"):
|
||||||
patch_string += f"- {patch}\n"
|
patch_string += f"- {patch}\n"
|
||||||
# Check for updates
|
# Check for updates
|
||||||
dict = updates.check_binary_updates(self.constants).check_binary_updates()
|
dict = updates.CheckBinaryUpdates(self.constants).check_binary_updates()
|
||||||
if not dict:
|
if not dict:
|
||||||
logging.info("- No new binaries found on Github, proceeding with patching")
|
logging.info("- No new binaries found on Github, proceeding with patching")
|
||||||
if self.constants.launcher_script is None:
|
if self.constants.launcher_script is None:
|
||||||
@@ -128,7 +128,7 @@ class AutomaticSysPatch:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Check if installed version is newer than booted version
|
# Check if installed version is newer than booted version
|
||||||
if updates.check_binary_updates(self.constants).check_if_build_newer(
|
if updates.CheckBinaryUpdates(self.constants)._check_if_build_newer(
|
||||||
self.constants.computer.oclp_version.split("."), self.constants.patcher_version.split(".")
|
self.constants.computer.oclp_version.split("."), self.constants.patcher_version.split(".")
|
||||||
) is True:
|
) is True:
|
||||||
logging.info("- Installed version is newer than booted version")
|
logging.info("- Installed version is newer than booted version")
|
||||||
|
|||||||
+71
-45
@@ -10,17 +10,26 @@ from resources import network_handler, constants
|
|||||||
REPO_LATEST_RELEASE_URL: str = "https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/releases/latest"
|
REPO_LATEST_RELEASE_URL: str = "https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/releases/latest"
|
||||||
|
|
||||||
|
|
||||||
class check_binary_updates:
|
class CheckBinaryUpdates:
|
||||||
def __init__(self, global_constants: constants.Constants):
|
def __init__(self, global_constants: constants.Constants):
|
||||||
self.constants: constants.Constants = global_constants
|
self.constants: constants.Constants = global_constants
|
||||||
|
|
||||||
self.binary_version = self.constants.patcher_version
|
self.binary_version = self.constants.patcher_version
|
||||||
self.binary_version_array = [int(x) for x in self.binary_version.split(".")]
|
self.binary_version_array = [int(x) for x in self.binary_version.split(".")]
|
||||||
|
|
||||||
self.available_binaries = {}
|
|
||||||
|
|
||||||
|
def _check_if_build_newer(self, remote_version: list = None, local_version: list = None):
|
||||||
|
"""
|
||||||
|
Check if the remote version is newer than the local version
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
remote_version (list): Remote version to compare against
|
||||||
|
local_version (list): Local version to compare against
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if remote version is newer, False if not
|
||||||
|
"""
|
||||||
|
|
||||||
def check_if_build_newer(self, remote_version=None, local_version=None):
|
|
||||||
if remote_version is None:
|
if remote_version is None:
|
||||||
remote_version = self.remote_version_array
|
remote_version = self.remote_version_array
|
||||||
if local_version is None:
|
if local_version is None:
|
||||||
@@ -40,13 +49,32 @@ class check_binary_updates:
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def determine_local_build_type(self):
|
|
||||||
|
def _determine_local_build_type(self):
|
||||||
|
"""
|
||||||
|
Check if the local build is a GUI or TUI build
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: "GUI" or "TUI"
|
||||||
|
"""
|
||||||
|
|
||||||
if self.constants.wxpython_variant is True:
|
if self.constants.wxpython_variant is True:
|
||||||
return "GUI"
|
return "GUI"
|
||||||
else:
|
else:
|
||||||
return "TUI"
|
return "TUI"
|
||||||
|
|
||||||
def determine_remote_type(self, remote_name):
|
|
||||||
|
def _determine_remote_type(self, remote_name: str):
|
||||||
|
"""
|
||||||
|
Check if the remote build is a GUI or TUI build
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
remote_name (str): Name of the remote build
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: "GUI" or "TUI"
|
||||||
|
"""
|
||||||
|
|
||||||
if "TUI" in remote_name:
|
if "TUI" in remote_name:
|
||||||
return "TUI"
|
return "TUI"
|
||||||
elif "GUI" in remote_name:
|
elif "GUI" in remote_name:
|
||||||
@@ -54,45 +82,43 @@ class check_binary_updates:
|
|||||||
else:
|
else:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
|
|
||||||
|
|
||||||
def check_binary_updates(self):
|
def check_binary_updates(self):
|
||||||
# logging.info("- Checking for updates...")
|
"""
|
||||||
if network_handler.NetworkUtilities(REPO_LATEST_RELEASE_URL).verify_network_connection():
|
Check if any updates are available for the OpenCore Legacy Patcher binary
|
||||||
# logging.info("- Network connection functional")
|
|
||||||
response = requests.get(REPO_LATEST_RELEASE_URL)
|
Returns:
|
||||||
data_set = response.json()
|
dict: Dictionary with Link and Version of the latest binary update if available
|
||||||
# logging.info("- Retrieved latest version data")
|
"""
|
||||||
self.remote_version = data_set["tag_name"]
|
|
||||||
# logging.info(f"- Latest version: {self.remote_version}")
|
available_binaries: list = {}
|
||||||
self.remote_version_array = self.remote_version.split(".")
|
|
||||||
self.remote_version_array = [
|
if not network_handler.NetworkUtilities(REPO_LATEST_RELEASE_URL).verify_network_connection():
|
||||||
int(x) for x in self.remote_version_array
|
return None
|
||||||
]
|
|
||||||
if self.check_if_build_newer() is True:
|
response = requests.get(REPO_LATEST_RELEASE_URL)
|
||||||
# logging.info("- Remote version is newer")
|
data_set = response.json()
|
||||||
for asset in data_set["assets"]:
|
|
||||||
logging.info(f"- Found asset: {asset['name']}")
|
self.remote_version = data_set["tag_name"]
|
||||||
if self.determine_remote_type(asset["name"]) == self.determine_local_build_type():
|
|
||||||
# logging.info(f"- Found matching asset: {asset['name']}")
|
self.remote_version_array = self.remote_version.split(".")
|
||||||
self.available_binaries.update({
|
self.remote_version_array = [int(x) for x in self.remote_version_array]
|
||||||
asset['name']: {
|
|
||||||
"Name":
|
if self._check_if_build_newer() is False:
|
||||||
asset["name"],
|
return None
|
||||||
"Version":
|
|
||||||
self.remote_version,
|
for asset in data_set["assets"]:
|
||||||
"Link":
|
logging.info(f"- Found asset: {asset['name']}")
|
||||||
asset["browser_download_url"],
|
if self._determine_remote_type(asset["name"]) == self._determine_local_build_type():
|
||||||
"Type":
|
available_binaries.update({
|
||||||
self.determine_remote_type(asset["name"]),
|
asset['name']: {
|
||||||
"Github Link":
|
"Name": asset["name"],
|
||||||
f"https://github.com/dortania/OpenCore-Legacy-Patcher/releases/{self.remote_version}"
|
"Version": self.remote_version,
|
||||||
}
|
"Link": asset["browser_download_url"],
|
||||||
})
|
"Type": self._determine_remote_type(asset["name"]),
|
||||||
break
|
"Github Link": f"https://github.com/dortania/OpenCore-Legacy-Patcher/releases/{self.remote_version}"
|
||||||
if self.available_binaries:
|
}
|
||||||
return self.available_binaries
|
})
|
||||||
else:
|
return available_binaries
|
||||||
# logging.info("- No matching binaries available")
|
|
||||||
return None
|
|
||||||
# else:
|
|
||||||
# logging.info("- Failed to connect to GitHub API")
|
|
||||||
return None
|
return None
|
||||||
Reference in New Issue
Block a user