Skip to content

Commit df292e5

Browse files
committed
Disable all progress bars if stdout is not a TTY
* bdx/__init__.py (make_progress_bar): Also disable the progressbar if sys.stdout is not a tty.
1 parent 9a9f43b commit df292e5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

bdx/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,9 @@ def error(msg, *args):
8181
def make_progress_bar(*args, **kwargs):
8282
"""Return ``tqdm`` progress bar if available."""
8383
disable = os.getenv("BDX_DISABLE_PROGRESS_BAR") is not None
84+
try:
85+
disable |= not os.isatty(sys.stdout.fileno())
86+
except IOError:
87+
# In case fileno() is unsupported
88+
pass
8489
return tqdm.tqdm(*args, disable=disable, **kwargs)

0 commit comments

Comments
 (0)