mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-21 06:30:52 +10:00
utilities.py: Add optional cls() argument
This commit is contained in:
@@ -312,7 +312,7 @@ def verify_network_connection(url):
|
|||||||
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError, requests.exceptions.HTTPError):
|
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError, requests.exceptions.HTTPError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def download_file(link, location):
|
def download_file(link, location, is_gui=None):
|
||||||
if verify_network_connection(link):
|
if verify_network_connection(link):
|
||||||
if Path(location).exists():
|
if Path(location).exists():
|
||||||
Path(location).unlink()
|
Path(location).unlink()
|
||||||
@@ -343,15 +343,15 @@ def download_file(link, location):
|
|||||||
dl += len(chunk)
|
dl += len(chunk)
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
count += len(chunk)
|
count += len(chunk)
|
||||||
cls()
|
if is_gui is None:
|
||||||
print(box_string)
|
cls()
|
||||||
print(header)
|
print(box_string)
|
||||||
print(box_string)
|
print(header)
|
||||||
print("")
|
print(box_string)
|
||||||
|
print("")
|
||||||
if total_file_size != 0:
|
if total_file_size != 0:
|
||||||
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}")
|
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"Average Download Speed: {round(dl//(time.perf_counter() - start) / 100000 / 8, 2)} MB/s")
|
|
||||||
checksum = hashlib.sha256()
|
checksum = hashlib.sha256()
|
||||||
with location.open("rb") as file:
|
with location.open("rb") as file:
|
||||||
chunk = file.read(1024 * 1024 * 16)
|
chunk = file.read(1024 * 1024 * 16)
|
||||||
|
|||||||
Reference in New Issue
Block a user