mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 22:20:53 +10:00
utilities.py: Avoid extra printing in non-TUI enviroments
This commit is contained in:
@@ -359,6 +359,7 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
|
|||||||
box_string = "#" * box_length
|
box_string = "#" * box_length
|
||||||
dl = 0
|
dl = 0
|
||||||
total_downloaded_string = ""
|
total_downloaded_string = ""
|
||||||
|
global clear
|
||||||
with location.open("wb") as file:
|
with location.open("wb") as file:
|
||||||
count = 0
|
count = 0
|
||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
@@ -367,11 +368,12 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
|
|||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
count += len(chunk)
|
count += len(chunk)
|
||||||
if is_gui is None:
|
if is_gui is None:
|
||||||
cls()
|
if clear:
|
||||||
print(box_string)
|
cls()
|
||||||
print(header)
|
print(box_string)
|
||||||
print(box_string)
|
print(header)
|
||||||
print("")
|
print(box_string)
|
||||||
|
print("")
|
||||||
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)}%)"
|
||||||
print(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")
|
print(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")
|
||||||
|
|||||||
Reference in New Issue
Block a user