From bb107972df3a5d7b9755524b66becad3fea6390c Mon Sep 17 00:00:00 2001
From: Davide Cavalca <dcavalca@fedoraproject.org>
Date: Fri, 24 Dec 2021 11:12:17 +0100
Subject: [PATCH] Use tqdm for progress bar instead of clint
---
samloader/crypt.py | 4 ++--
samloader/main.py | 5 ++---
setup.py | 2 +-
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/samloader/crypt.py b/samloader/crypt.py
index 29611a6..5f45c43 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,7 @@ 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)):
+ for i in tqdm(range(chunks)):
block = inf.read(4096)
if not block:
break
diff --git a/samloader/main.py b/samloader/main.py
index 57210dc..0941fed 100644
--- a/samloader/main.py
+++ b/samloader/main.py
@@ -5,7 +5,7 @@
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,8 +46,7 @@ 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):
+ for chunk in tqdm(r.iter_content(chunk_size=0x10000), total=int((size-dloffset)/0x10000)+1):
if chunk:
fd.write(chunk)
fd.flush()
diff --git a/setup.py b/setup.py
index 1442858..018448f 100644
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@
],
},
install_requires=[
- "clint",
+ "tqdm",
"pycryptodomex",
"requests"
],