Skip to content

Commit

Permalink
show extraction progress
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrauch committed Feb 17, 2024
1 parent 16de410 commit bed0f88
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bed0f88

Please sign in to comment.