diff --git a/Scripts/dsdt.py b/Scripts/dsdt.py index 7973e03..817cddd 100755 --- a/Scripts/dsdt.py +++ b/Scripts/dsdt.py @@ -320,7 +320,7 @@ class DSDT: zfile = os.path.basename(url) #print("Downloading {}".format(os.path.basename(url))) #self.dl.stream_to_file(url, os.path.join(ztemp,zfile), progress=False, headers=self.h) - self.fetcher.download_and_save_file(url, os.path.join(ztemp,zfile), False) + self.fetcher.download_and_save_file(url, os.path.join(ztemp,zfile)) search_dir = ztemp if zfile.lower().endswith(".zip"): print(" - Extracting") diff --git a/Scripts/gathering_files.py b/Scripts/gathering_files.py index 046bb56..798b911 100755 --- a/Scripts/gathering_files.py +++ b/Scripts/gathering_files.py @@ -282,6 +282,7 @@ class gatheringFiles: zip_path = os.path.join(self.temporary_dir, product_data.get("product_name")) + ".zip" self.fetcher.download_and_save_file(product_data.get("url"), zip_path) + self.utils.extract_zip_file(zip_path) if self.move_bootloader_kexts_to_product_directory(product_data.get("product_name")): if product_index is None: diff --git a/Scripts/resource_fetcher.py b/Scripts/resource_fetcher.py index 1608603..83a6825 100755 --- a/Scripts/resource_fetcher.py +++ b/Scripts/resource_fetcher.py @@ -2,7 +2,6 @@ import requests import ssl import os import certifi -import zipfile import plistlib class ResourceFetcher: @@ -54,16 +53,4 @@ class ResourceFetcher: file_writer.write(chunk) bytes_downloaded += len(chunk) if total_size != -1: - print(f"Downloaded {bytes_downloaded / (1024 * 1024):.2f} MB of {total_size / (1024 * 1024):.2f} MB", end='\r') - - if extract and destination_path.lower().endswith('.zip'): - self.extract_zip_file(destination_path) - - def extract_zip_file(self, zip_path, extraction_directory=None): - if extraction_directory is None: - extraction_directory = os.path.splitext(zip_path)[0] - - os.makedirs(extraction_directory, exist_ok=True) - - with zipfile.ZipFile(zip_path, 'r') as zip_ref: - zip_ref.extractall(extraction_directory) \ No newline at end of file + print(f"Downloaded {bytes_downloaded / (1024 * 1024):.2f} MB of {total_size / (1024 * 1024):.2f} MB", end='\r') \ No newline at end of file diff --git a/Scripts/utils.py b/Scripts/utils.py index 9a2e079..e011194 100755 --- a/Scripts/utils.py +++ b/Scripts/utils.py @@ -127,6 +127,15 @@ class Utils: return little_endian_hex.upper() + def extract_zip_file(self, zip_path, extraction_directory=None): + if extraction_directory is None: + extraction_directory = os.path.splitext(zip_path)[0] + + os.makedirs(extraction_directory, exist_ok=True) + + with zipfile.ZipFile(zip_path, 'r') as zip_ref: + zip_ref.extractall(extraction_directory) + def contains_any(self, data, search_item, start=0, end=None): return next((item for item in data[start:end] if item.lower() in search_item.lower()), None) diff --git a/updater.py b/updater.py index 4fcdb9e..ae24d79 100644 --- a/updater.py +++ b/updater.py @@ -34,7 +34,9 @@ class Updater: def download_update(self): self.utils.mkdirs(self.temporary_dir) - self.fetcher.download_and_save_file(self.download_repo_url, os.path.join(self.temporary_dir, os.path.basename(self.download_repo_url))) + file_path = os.path.join(self.temporary_dir, os.path.basename(self.download_repo_url)) + self.fetcher.download_and_save_file(self.download_repo_url, file_path) + self.utils.extract_zip_file(file_path) def update_files(self): target_dir = os.path.join(self.temporary_dir, "main", "OpCore-Simplify-main")