mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-23 11:30:15 +10:00
Convert PatcherSupportPkg downloader into function
This commit is contained in:
@@ -338,35 +338,8 @@ class PatchSysVolume:
|
|||||||
print("- Removing old Apple Binaries zip")
|
print("- Removing old Apple Binaries zip")
|
||||||
Path(self.constants.payload_apple_root_path_zip).unlink()
|
Path(self.constants.payload_apple_root_path_zip).unlink()
|
||||||
|
|
||||||
#Utilities.cls()
|
Utilities.download_file(link, self.constants.payload_apple_root_path_zip)
|
||||||
#print("- Downloading Apple binaries")
|
|
||||||
#popen_oclp = subprocess.Popen(
|
|
||||||
# ["curl", "-S", "-L", link, "--output", self.constants.payload_apple_root_path_zip],
|
|
||||||
# stdin=subprocess.PIPE,
|
|
||||||
# stdout=subprocess.PIPE,
|
|
||||||
# stderr=subprocess.STDOUT,
|
|
||||||
# universal_newlines=True,
|
|
||||||
#)
|
|
||||||
#for stdout_line in iter(popen_oclp.stdout.readline, ""):
|
|
||||||
# print(stdout_line, end="")
|
|
||||||
#popen_oclp.stdout.close()
|
|
||||||
|
|
||||||
response = requests.get(link, stream=True)
|
|
||||||
with self.constants.payload_apple_root_path_zip.open("wb") as file:
|
|
||||||
count = 0
|
|
||||||
for chunk in response.iter_content(1024 * 1024 * 4):
|
|
||||||
file.write(chunk)
|
|
||||||
count += len(chunk)
|
|
||||||
Utilities.cls()
|
|
||||||
print(f"- Downloading Apple binaries ({os_ver}) from PatcherSupportPkg")
|
|
||||||
print(f"- {count / 1024 / 1024}MB Downloaded")
|
|
||||||
checksum = hashlib.sha256()
|
|
||||||
with self.constants.payload_apple_root_path_zip.open("rb") as file:
|
|
||||||
chunk = file.read(1024 * 1024 * 16)
|
|
||||||
while chunk:
|
|
||||||
checksum.update(chunk)
|
|
||||||
chunk = file.read(1024 * 1024 * 16)
|
|
||||||
print(f"- Checksum: {checksum.hexdigest()}")
|
|
||||||
if self.constants.payload_apple_root_path_zip.exists():
|
if self.constants.payload_apple_root_path_zip.exists():
|
||||||
print("- Download completed")
|
print("- Download completed")
|
||||||
print("- Unzipping download...")
|
print("- Unzipping download...")
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import math
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import plistlib
|
import plistlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import requests
|
||||||
|
import hashlib
|
||||||
|
import requests
|
||||||
|
|
||||||
from Resources import Constants
|
from Resources import Constants
|
||||||
|
|
||||||
@@ -114,6 +117,28 @@ def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
|
|||||||
value = value.strip(b"\0").decode()
|
value = value.strip(b"\0").decode()
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def download_file(link, location):
|
||||||
|
print("- Attempting download from following link:")
|
||||||
|
print(link)
|
||||||
|
if Path(location).exists():
|
||||||
|
print("- Removing old file")
|
||||||
|
Path(location).unlink()
|
||||||
|
response = requests.get(link, stream=True)
|
||||||
|
with location.open("wb") as file:
|
||||||
|
count = 0
|
||||||
|
for chunk in response.iter_content(1024 * 1024 * 4):
|
||||||
|
file.write(chunk)
|
||||||
|
count += len(chunk)
|
||||||
|
cls()
|
||||||
|
print(f"- Downloading package")
|
||||||
|
print(f"- {count / 1024 / 1024}MB Downloaded")
|
||||||
|
checksum = hashlib.sha256()
|
||||||
|
with location.open("rb") as file:
|
||||||
|
chunk = file.read(1024 * 1024 * 16)
|
||||||
|
while chunk:
|
||||||
|
checksum.update(chunk)
|
||||||
|
chunk = file.read(1024 * 1024 * 16)
|
||||||
|
print(f"- Checksum: {checksum.hexdigest()}")
|
||||||
|
|
||||||
# def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False):
|
# def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False):
|
||||||
# return_option = ["Q", "Quit", None] if top_level else ["B", "Back", None]
|
# return_option = ["Q", "Quit", None] if top_level else ["B", "Back", None]
|
||||||
|
|||||||
Reference in New Issue
Block a user