tqdm auto-disabling with dynamic log level

This commit is contained in:
Casper da Costa-Luis
2019-08-10 14:41:08 +01:00
parent 9143f67ee0
commit f88bf9218a
2 changed files with 7 additions and 5 deletions
+6 -2
View File
@@ -12,8 +12,7 @@ class Tqdm(tqdm):
def __init__(
self,
iterable=None,
disable=logging.getLogger(__name__).getEffectiveLevel()
>= logging.CRITICAL,
disable=None,
bytes=False, # pylint: disable=W0622
desc_truncate=None,
**kwargs
@@ -32,6 +31,11 @@ class Tqdm(tqdm):
kwargs.setdefault(k, v)
if desc_truncate is not None:
kwargs.setdefault("desc", self.truncate(desc_truncate))
if disable is None:
disable = (
logging.getLogger(__name__).getEffectiveLevel()
>= logging.CRITICAL
)
super(Tqdm, self).__init__(
iterable=iterable, disable=disable, **kwargs
)
+1 -3
View File
@@ -348,9 +348,7 @@ class RemoteLOCAL(RemoteBASE):
cache = []
path_infos = []
names = []
for md5, info in Tqdm(
status_info.items(), desc="Analysing status"
):
for md5, info in Tqdm(status_info.items(), desc="Analysing status"):
if info["status"] == status:
cache.append(self.checksum_to_path_info(md5))
path_infos.append(remote.checksum_to_path_info(md5))