Skip to content

Commit 001d0bb

Browse files
committed
Disable progress bar if not running in a terminal
1 parent 2ab4d50 commit 001d0bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

requake/scan/scan_catalog.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
GNU General Public License v3.0 or later
1010
(https://www.gnu.org/licenses/gpl-3.0-standalone.html)
1111
"""
12+
import sys
1213
import logging
1314
import csv
1415
from math import factorial
@@ -60,7 +61,10 @@ def _process_pairs(fp_out, nevents, catalog):
6061
writer.writerow(fieldnames)
6162
npairs = int(factorial(nevents)/(factorial(2)*factorial(nevents-2)))
6263
logger.info(f'Processing {npairs:n} event pairs')
63-
with tqdm(total=npairs, unit='pairs', unit_scale=True) as pbar:
64+
# Disable progress bar if not running in a terminal
65+
disable_bar = not sys.stderr.isatty()
66+
with tqdm(total=npairs, unit='pairs', unit_scale=True,
67+
disable=disable_bar) as pbar:
6468
for pair in combinations(catalog, 2):
6569
pbar.update()
6670
if not _pair_ok(pair):

0 commit comments

Comments
 (0)