summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-12-21 16:18:29 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-12-21 16:18:29 +0000
commit0f00fbbed38757a2b0628341f172c69d9c4dd60a (patch)
treeed40133119bd331ddcc40320bcd6320215a8cf62 /morphlib
parenta7431e36e66f0a263cc940fb2718eb934ab4b247 (diff)
downloadmorph-0f00fbbed38757a2b0628341f172c69d9c4dd60a.tar.gz
Don't show progress bars if stderr is being redirected to a file
Currently the logs of our continuous builder (https://mason-x86-64.baserock.org) are filled with lots of this sort of crap: stage1-binutils-misc[ ] 2.4/73.0 MB stage1-binutils-misc[ ] 2.4/73.0 MB stage1-binutils-misc[ ] 2.4/73.0 MB stage1-binutils-misc[ ] 2.4/73.0 MB stage1-binutils-misc[# ] 2.4/73.0 MB stage1-binutils-misc[# ] 2.5/73.0 MB stage1-binutils-misc[# ] 2.5/73.0 MB ... Change-Id: I0b7a4c8421c3ecdd141fc8323d3001ae4fb44d9b
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/util.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/morphlib/util.py b/morphlib/util.py
index 0ec071e4..94b0f4c4 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -767,13 +767,14 @@ class ProgressBar(object):
self._empty_char = empty_char
def show(self, progress): #pragma: no cover
- blocks = int(progress / self._block_width);
-
- s = self.TEMPLATE % (self._label, self._progress_char * blocks,
- self._empty_char * (self._width - blocks),
- progress, self._expected_size, self._unit)
- sys.stderr.write(s)
- sys.stderr.flush()
+ if sys.stderr.isatty():
+ blocks = int(progress / self._block_width);
+
+ s = self.TEMPLATE % (self._label, self._progress_char * blocks,
+ self._empty_char * (self._width - blocks),
+ progress, self._expected_size, self._unit)
+ sys.stderr.write(s)
+ sys.stderr.flush()
def schemas_directory(): # pragma: no cover