From 75ad2c2486cc7ad81fc5b7b59a7bd0b6dd0f2452 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 5 Aug 2021 01:50:01 -0300 Subject: Report how M+ download is progressing, and hopefully, finish it faster. Code "borrowed" from Mana Spheres (and borrowed from Stack Overflow in turn) --- game/3rdparty.rpy | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/game/3rdparty.rpy b/game/3rdparty.rpy index 49759fc..163915d 100644 --- a/game/3rdparty.rpy +++ b/game/3rdparty.rpy @@ -17,15 +17,21 @@ init 1 python: return False status_update("Saving %s..." %fname, 64) + msize = int(r.headers.get('content-length', 0)) + bsize = 4096 + csize = msize / 7 + cstep = 0 with open(installdir+"/%s" % fname, 'wb') as fd: - for chunk in r.iter_content(chunk_size=128): + for chunk in r.iter_content(bsize): fd.write(chunk) + cstep += bsize + status_update(pc=64+(cstep / csize)) - status_update("Verifying MD5 hash...", 67) + status_update("Verifying MD5 hash...", 70) r=requests.get(persistent.host+"/%s.md5" % fname, timeout=10.0) md5up=r.text.replace("\n", "") - status_update("Verifying MD5 hash...", 69) + status_update("Verifying MD5 hash...", 71) md5us=md5sum(installdir+"/%s" % fname) if md5up != md5us: status_update("MD5 Hash Error") @@ -46,7 +52,7 @@ init 1 python: if not download_manaplus("ManaPlus.AppImage"): return False - status_update("Marking as executable...", 70) + status_update("Marking as executable...", 72) execute("chmod +x \"%s\"" % installdir+"/ManaPlus.AppImage", shell=True) status_update("Installation successful!", 75) ######################################################### @@ -54,7 +60,7 @@ init 1 python: if not download_manaplus("ManaPlus.zip"): return False - status_update("Unzipping file...", 70) + status_update("Unzipping file...", 72) with zipfile.ZipFile(installdir+"/ManaPlus.zip", 'r') as zip_ref: zip_ref.extractall(installdir) status_update("Installation successful!", 75) -- cgit v1.2.3-70-g09d2