From 5455b5edefd5f1d6b99ca5f5d1b9d471df25045b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 29 Apr 2016 11:05:23 +0200 Subject: Disable progress bar if output is not a terminal Signed-off-by: Florian Pritz --- fb.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fb.py b/fb.py index c1e4c5e..1557ed9 100755 --- a/fb.py +++ b/fb.py @@ -239,6 +239,10 @@ class ProgressBar: def __init__(self): samplecount = 20 + self.display_progress = True + if not sys.stderr.isatty(): + self.display_progress = False + self.progressData = { "lastUpdateTime": time.time(), "ullast": 0, @@ -259,6 +263,9 @@ class ProgressBar: data = self.progressData assert data["ulGlobalTotal"] > 0 + if not self.display_progress: + return + # update values here because if we carry one progress bar over multiple # requests we could miss update when running after the rate limiter uldiff = ulnow - data['ullast'] -- cgit v1.2.3-24-g4f1b