From d41361640058514ce4c99d9df93e33f5787e4ef2 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Thu, 23 Jan 2014 22:22:15 +0100 Subject: [PATCH] The progress bar should always appear on stderr --- waflib/Build.py | 2 +- waflib/Logs.py | 11 +++++++---- waflib/Task.py | 10 +++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/waflib/Build.py b/waflib/Build.py index 58d57eb6..c29434d9 100644 --- a/waflib/Build.py +++ b/waflib/Build.py @@ -265,7 +265,7 @@ class BuildContext(Context.Context): try: self.compile() finally: - if self.progress_bar == 1: + if self.progress_bar == 1 and sys.stderr.isatty(): c = len(self.returned_tasks) or 1 m = self.progress_line(c, c, Logs.colors.BLUE, Logs.colors.NORMAL) Logs.info(m, extra={'stream': sys.stderr, 'c1': Logs.colors.cursor_off, 'c2' : Logs.colors.cursor_on}) diff --git a/waflib/Logs.py b/waflib/Logs.py index aed2f43c..96ae92dd 100644 --- a/waflib/Logs.py +++ b/waflib/Logs.py @@ -132,10 +132,13 @@ class log_handler(logging.StreamHandler): def emit(self, record): # default implementation try: - if record.levelno >= logging.WARNING: - record.stream = self.stream = sys.stderr - else: - record.stream = self.stream = sys.stdout + try: + self.stream = record.stream + except AttributeError: + if record.levelno >= logging.WARNING: + record.stream = self.stream = sys.stderr + else: + record.stream = self.stream = sys.stdout self.emit_override(record) self.flush() except (KeyboardInterrupt, SystemExit): diff --git a/waflib/Task.py b/waflib/Task.py index 1d527d33..56ca89bd 100644 --- a/waflib/Task.py +++ b/waflib/Task.py @@ -252,10 +252,14 @@ class TaskBase(evil): c1 = Logs.colors.cursor_off c2 = Logs.colors.cursor_on if bld.logger: - fun = bld.logger.info + logger = bld.logger else: - fun = Logs.info - fun(self.display(), extra={'stream': sys.stderr, 'terminator':'', 'c1': c1, 'c2' : c2}) + logger = Logs + + if stderr: + logger.info(self.display(), extra={'stream': sys.stderr, 'terminator':'', 'c1': c1, 'c2' : c2}) + else: + logger.info(self.display(), extra={'terminator':'', 'c1': c1, 'c2' : c2}) def display(self): """