From 02d283b64549e07c45d97f86638d3daf450c974e Mon Sep 17 00:00:00 2001 From: Vadim Troshchinskiy Date: Fri, 29 Nov 2024 14:32:28 +0100 Subject: [PATCH] Use tqdm --- gitlib/gitlib.py | 17 +++++++++-------- gitlib/requirements.txt | 4 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gitlib/gitlib.py b/gitlib/gitlib.py index 84d5c41..217cf8e 100755 --- a/gitlib/gitlib.py +++ b/gitlib/gitlib.py @@ -40,6 +40,7 @@ import posix1e import blkid from filesystem import * from ntfs import * +from tqdm import tqdm class OgProgressPrinter(git.RemoteProgress): """ @@ -65,18 +66,18 @@ class OgProgressPrinter(git.RemoteProgress): def __init__(self, parentLogger): super().__init__() self.logger = parentLogger - self.prev_len = 0 - print("\n", file=sys.stderr) + if sys.stdin.isatty(): + self.progress = tqdm() def update(self, op_code, cur_count, max_count=None, message=""): self.logger.debug(f"Progress: {op_code} {cur_count}/{max_count}: {message}") - status_string = "Progress: %s %s/%s: %s" % (op_code, cur_count, max_count, message) - padded_string = status_string.rjust(self.prev_len, " ") - self.prev_len = len(status_string) - - print(f"\r{padded_string}", file=sys.stderr, end="") + if self.progress: + self.progress.total = max_count + self.progress.n = cur_count + self.progress.desc = message + self.progress.refresh() def __del__(self): print("\n", file=sys.stderr) @@ -1572,4 +1573,4 @@ if __name__ == '__main__': # # Make sure all filesystem changes are written, just in case the oglive is rebooted without an unmount - os.sync() \ No newline at end of file + os.sync() diff --git a/gitlib/requirements.txt b/gitlib/requirements.txt index 32076cd..96b33e8 100644 --- a/gitlib/requirements.txt +++ b/gitlib/requirements.txt @@ -1,9 +1,11 @@ gitdb==4.0.11 GitPython==3.1.43 -libarchive==0.4.7 libarchive-c==5.1 nose==1.3.7 +pathlib==1.0.1 +pkg_resources==0.0.0 pylibacl==0.7.0 pylibblkid==0.3 pyxattr==0.8.1 smmap==5.0.1 +tqdm==4.66.5