From bed0f8890828046763c78df23732713b365b6038 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sat, 17 Feb 2024 01:06:01 +0100 Subject: [PATCH] show extraction progress --- setup.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4d19eeff..95ecf62e 100755 --- a/setup.py +++ b/setup.py @@ -7,10 +7,14 @@ import platform import tempfile from xml.etree import ElementTree +import datetime import py7zr import requests import yaml +from tqdm_loggable.auto import tqdm +from tqdm_loggable.tqdm_logging import tqdm_logging + url_repo_qtc_fmt = "https://download.qt.io/{release_type}_releases/qtcreator/{qtcv_maj}/{qtcv_full}/installer_source/{os}_{arch}/" @@ -47,6 +51,12 @@ def read_downloadable_archives(package): archive_names = io.StringIO(package.find("DownloadableArchives").text) return list(csv.reader(archive_names, delimiter=',', skipinitialspace=True))[0] +def extract_progress(archive_bytes, destination_path): + tqdm_logging.set_log_rate(datetime.timedelta(seconds=60)) + with py7zr.SevenZipFile(io.BytesIO(archive_bytes)) as zf: + for member in tqdm(zf.getnames(), desc='Extracting'): + zf.extract(member, destination_path) + def qtc_download_check_extract(cfg, dir_install): # if the Qt Creator version contains '-beta' or '-rc' we have to # use the "development" repo, otherwise use the "official" repo @@ -92,7 +102,7 @@ def qtc_download_check_extract(cfg, dir_install): if md5sums[archive_name] != hashlib.md5(content).hexdigest(): raise RuntimeError(archive_name+" MD5 hash sum does not match") - py7zr.SevenZipFile(io.BytesIO(content)).extractall(dir_install_qt) + extract_progress(content, dir_install_qt) if cfg['os'] == "Darwin": dir_install_qt = os.path.join(dir_install_qt, "Qt Creator.app", "Contents", "Resources") @@ -168,7 +178,7 @@ def qt_download_check_extract(cfg, dir_install): if sha1sum != hashlib.sha1(content).hexdigest(): raise RuntimeError(archive_name+" SHA1 hash sum does not match") - py7zr.SevenZipFile(io.BytesIO(content)).extractall(dir_install) + extract_progress(content, dir_install) qt_path = os.path.join(dir_install, "{}.{}.0".format(ver_maj, ver_min)) qt_archs = os.listdir(qt_path)