diff --git a/resources/main.py b/resources/main.py index 1d26177ac..b8d258fab 100644 --- a/resources/main.py +++ b/resources/main.py @@ -33,12 +33,14 @@ class OpenCoreLegacyPatcher: level=logging.NOTSET, format="%(asctime)s - %(filename)s (%(lineno)d): %(message)s", handlers=[ - logging.FileHandler(f"Library/Logs/OpenCore-Patcher-v{self.constants.patcher_version}.log"), + # TODO: Handle proper file storage + logging.FileHandler(f"OpenCore-Patcher-v{self.constants.patcher_version}.log"), logging.StreamHandler(), ], ) logging.getLogger().handlers[1].setFormatter(logging.Formatter("%(message)s")) logging.getLogger().setLevel(logging.INFO) + logging.getLogger().handlers[1].maxBytes = 1024 * 1024 * 10 def generate_base_data(self): self.constants.detected_os = os_probe.detect_kernel_major() diff --git a/resources/run.py b/resources/run.py index d65eb941f..669e675fb 100644 --- a/resources/run.py +++ b/resources/run.py @@ -3,10 +3,7 @@ # Source: https://github.com/corpnewt/pymodules/blob/884c3de15b6a2570afde52fe8a14a3e946ffb18a/run.py import sys, subprocess, time, threading, shlex, logging -try: - from Queue import Queue, Empty -except: - from queue import Queue, Empty +from queue import Queue, Empty ON_POSIX = 'posix' in sys.builtin_module_names diff --git a/resources/utilities.py b/resources/utilities.py index fef77219c..c4b81ec0d 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -411,7 +411,7 @@ def download_file(link, location, is_gui=None, verify_checksum=False): with location.open("wb") as file: count = 0 start = time.perf_counter() - for chunk in response.iter_content(1024 * 1024 * 4): + for i, chunk in enumerate(response.iter_content(1024 * 1024 * 4)): dl += len(chunk) file.write(chunk) count += len(chunk) @@ -424,7 +424,8 @@ def download_file(link, location, is_gui=None, verify_checksum=False): logging.info("") if total_file_size > 1024: total_downloaded_string = f" ({round(float(dl / total_file_size * 100), 2)}%)" - logging.info(f"{round(count / 1024 / 1024, 2)}MB Downloaded{file_size_string}{total_downloaded_string}\nAverage Download Speed: {round(dl//(time.perf_counter() - start) / 100000 / 8, 2)} MB/s") + if i % 100 == 0: + logging.info(f"{round(count / 1024 / 1024, 2)}MB Downloaded{file_size_string}{total_downloaded_string}\nAverage Download Speed: {round(dl//(time.perf_counter() - start) / 100000 / 8, 2)} MB/s") if verify_checksum is True: # Verify checksum