Merge pull request #264 from mwander/isatty

Print tqdm progress bar only when running from interactive TTY
This commit is contained in:
Sean Whalen
2021-12-04 11:30:51 -05:00
committed by GitHub

View File

@@ -13,6 +13,7 @@ import json
from ssl import CERT_NONE, create_default_context
from multiprocessing import Pool, Value
from itertools import repeat
import sys
import time
from tqdm import tqdm
@@ -658,11 +659,15 @@ def _main():
repeat(opts.offline),
repeat(opts.n_procs >= 1)),
opts.chunk_size)
pbar = tqdm(total=len(file_paths))
while not results.ready():
pbar.update(counter.value - pbar.n)
time.sleep(0.1)
pbar.close()
if sys.stdout.isatty():
pbar = tqdm(total=len(file_paths))
while not results.ready():
pbar.update(counter.value - pbar.n)
time.sleep(0.1)
pbar.close()
else:
while not results.ready():
time.sleep(0.1)
results = results.get()
pool.close()
pool.join()