mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 22:20:53 +10:00
logging: Use generic saving
This commit is contained in:
+3
-1
@@ -33,12 +33,14 @@ class OpenCoreLegacyPatcher:
|
|||||||
level=logging.NOTSET,
|
level=logging.NOTSET,
|
||||||
format="%(asctime)s - %(filename)s (%(lineno)d): %(message)s",
|
format="%(asctime)s - %(filename)s (%(lineno)d): %(message)s",
|
||||||
handlers=[
|
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.StreamHandler(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
logging.getLogger().handlers[1].setFormatter(logging.Formatter("%(message)s"))
|
logging.getLogger().handlers[1].setFormatter(logging.Formatter("%(message)s"))
|
||||||
logging.getLogger().setLevel(logging.INFO)
|
logging.getLogger().setLevel(logging.INFO)
|
||||||
|
logging.getLogger().handlers[1].maxBytes = 1024 * 1024 * 10
|
||||||
|
|
||||||
def generate_base_data(self):
|
def generate_base_data(self):
|
||||||
self.constants.detected_os = os_probe.detect_kernel_major()
|
self.constants.detected_os = os_probe.detect_kernel_major()
|
||||||
|
|||||||
+1
-4
@@ -3,10 +3,7 @@
|
|||||||
# Source: https://github.com/corpnewt/pymodules/blob/884c3de15b6a2570afde52fe8a14a3e946ffb18a/run.py
|
# Source: https://github.com/corpnewt/pymodules/blob/884c3de15b6a2570afde52fe8a14a3e946ffb18a/run.py
|
||||||
|
|
||||||
import sys, subprocess, time, threading, shlex, logging
|
import sys, subprocess, time, threading, shlex, logging
|
||||||
try:
|
from queue import Queue, Empty
|
||||||
from Queue import Queue, Empty
|
|
||||||
except:
|
|
||||||
from queue import Queue, Empty
|
|
||||||
|
|
||||||
ON_POSIX = 'posix' in sys.builtin_module_names
|
ON_POSIX = 'posix' in sys.builtin_module_names
|
||||||
|
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
|
|||||||
with location.open("wb") as file:
|
with location.open("wb") as file:
|
||||||
count = 0
|
count = 0
|
||||||
start = time.perf_counter()
|
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)
|
dl += len(chunk)
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
count += len(chunk)
|
count += len(chunk)
|
||||||
@@ -424,7 +424,8 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
|
|||||||
logging.info("")
|
logging.info("")
|
||||||
if total_file_size > 1024:
|
if total_file_size > 1024:
|
||||||
total_downloaded_string = f" ({round(float(dl / total_file_size * 100), 2)}%)"
|
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:
|
if verify_checksum is True:
|
||||||
# Verify checksum
|
# Verify checksum
|
||||||
|
|||||||
Reference in New Issue
Block a user