Skip to content

Commit

Permalink
utilities.py: Avoid extra printing in non-TUI enviroments
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Apr 30, 2022
1 parent 93a2eeb commit 218529a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions resources/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
box_string = "#" * box_length
dl = 0
total_downloaded_string = ""
global clear
with location.open("wb") as file:
count = 0
start = time.perf_counter()
Expand All @@ -367,11 +368,12 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
file.write(chunk)
count += len(chunk)
if is_gui is None:
cls()
print(box_string)
print(header)
print(box_string)
print("")
if clear:
cls()
print(box_string)
print(header)
print(box_string)
print("")
if total_file_size > 1024:
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")
Expand Down

0 comments on commit 218529a

Please sign in to comment.