From b6a000b7b9999d26db017ee38eaff16bb8fefa3a Mon Sep 17 00:00:00 2001 From: bipinkrish Date: Sat, 25 Feb 2023 16:36:39 +0530 Subject: [PATCH] Added progress bar --- setup/libadobe.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/setup/libadobe.py b/setup/libadobe.py index 05b96ca..1d4b75a 100644 --- a/setup/libadobe.py +++ b/setup/libadobe.py @@ -257,12 +257,24 @@ def sendHTTPRequest_DL2FILE(URL, outputfile): if ret_code != 200: return ret_code + total_size = int(handler.headers.get("Content-Length", 0)) + bytes_so_far = 0 + + print() with open(outputfile, "wb") as f: while True: chunk = handler.read(chunksize) if not chunk: break + bytes_so_far += len(chunk) f.write(chunk) + + # progress bar + progress = float(bytes_so_far) / total_size + progress_bar_width = 40 + progress_bar = ('[' + '=' * int(progress * progress_bar_width)).ljust(progress_bar_width + 1) + ']' + percent = round(progress * 100, 2) + print("Downloaded %d of %d bytes %s %0.2f%%" % (bytes_so_far, total_size, progress_bar, percent), end='\r') return 200