diff options
author | Davide Cavalca <davide@cavalca.name> | 2022-02-22 01:48:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 01:48:25 +0100 |
commit | d02f59586ec33a7cb0e48dfe44b33b849883caad (patch) | |
tree | 925d62820d8db80bb2468a9a925e4c1c356edfc8 | |
parent | add error when device or model is invalid (checkupdate) (diff) | |
download | samloader-d02f59586ec33a7cb0e48dfe44b33b849883caad.tar samloader-d02f59586ec33a7cb0e48dfe44b33b849883caad.tar.gz samloader-d02f59586ec33a7cb0e48dfe44b33b849883caad.tar.bz2 samloader-d02f59586ec33a7cb0e48dfe44b33b849883caad.tar.lz samloader-d02f59586ec33a7cb0e48dfe44b33b849883caad.tar.xz samloader-d02f59586ec33a7cb0e48dfe44b33b849883caad.tar.zst samloader-d02f59586ec33a7cb0e48dfe44b33b849883caad.zip |
-rw-r--r-- | samloader/crypt.py | 6 | ||||
-rw-r--r-- | samloader/main.py | 7 | ||||
-rw-r--r-- | setup.py | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/samloader/crypt.py b/samloader/crypt.py index 29611a6..94414d6 100644 --- a/samloader/crypt.py +++ b/samloader/crypt.py @@ -6,7 +6,7 @@ import hashlib import xml.etree.ElementTree as ET from Cryptodome.Cipher import AES -from clint.textui import progress +from tqdm import tqdm from . import fusclient from . import request @@ -38,7 +38,8 @@ def decrypt_progress(inf, outf, key, length): if length % 16 != 0: raise Exception("invalid input block size") chunks = length//4096+1 - for i in progress.bar(range(chunks)): + pbar = tqdm(total=length, unit="B", unit_scale=True) + for i in range(chunks): block = inf.read(4096) if not block: break @@ -47,3 +48,4 @@ def decrypt_progress(inf, outf, key, length): outf.write(unpad(decblock)) else: outf.write(decblock) + pbar.update(4096) diff --git a/samloader/main.py b/samloader/main.py index 57210dc..48c9a82 100644 --- a/samloader/main.py +++ b/samloader/main.py @@ -5,7 +5,7 @@ import argparse import os import base64 import xml.etree.ElementTree as ET -from clint.textui import progress +from tqdm import tqdm from . import request from . import crypt @@ -46,11 +46,12 @@ def main(): r = client.downloadfile(path+filename, dloffset) if args.show_md5 and "Content-MD5" in r.headers: print("MD5:", base64.b64decode(r.headers["Content-MD5"]).hex()) - # TODO: use own progress bar instead of clint - for chunk in progress.bar(r.iter_content(chunk_size=0x10000), expected_size=((size-dloffset)/0x10000)+1): + pbar = tqdm(total=size, initial=dloffset, unit="B", unit_scale=True) + for chunk in r.iter_content(chunk_size=0x10000): if chunk: fd.write(chunk) fd.flush() + pbar.update(0x10000) fd.close() if args.do_decrypt: # decrypt the file if needed dec = out.replace(".enc4", "").replace(".enc2", "") # TODO: use a better way of doing this @@ -24,7 +24,7 @@ setuptools.setup( ], }, install_requires=[ - "clint", + "tqdm", "pycryptodomex", "requests" ], |