From b461145b7949d2cb4eab79d0f1955ddd4ce23dbb Mon Sep 17 00:00:00 2001 From: vjpai Date: Wed, 8 Jul 2015 09:53:46 -0700 Subject: Stop sending terminal escape sequences if we're redirecting output to a file. --- tools/run_tests/jobset.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'tools/run_tests/jobset.py') diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py index 8694b8f6bd..e262d00bb6 100755 --- a/tools/run_tests/jobset.py +++ b/tools/run_tests/jobset.py @@ -101,15 +101,22 @@ def message(tag, msg, explanatory_text=None, do_newline=False): print '%s: %s' % (tag, msg) return try: - sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % ( - _BEGINNING_OF_LINE, - _CLEAR_LINE, - '\n%s' % explanatory_text if explanatory_text is not None else '', - _COLORS[_TAG_COLOR[tag]][1], - _COLORS[_TAG_COLOR[tag]][0], - tag, - msg, - '\n' if do_newline or explanatory_text is not None else '')) + if sys.stdout.isatty(): + sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % ( + _BEGINNING_OF_LINE, + _CLEAR_LINE, + '\n%s' % explanatory_text if explanatory_text is not None else '', + _COLORS[_TAG_COLOR[tag]][1], + _COLORS[_TAG_COLOR[tag]][0], + tag, + msg, + '\n' if do_newline or explanatory_text is not None else '')) + else: + sys.stdout.write('%s%s: %s%s' % ( + '\n%s' % explanatory_text if explanatory_text is not None else '', + tag, + msg, + '\n')) sys.stdout.flush() except: pass -- cgit v1.2.3 From a29d2d7c33c4dce9a566f1acd190bbea56a1ad13 Mon Sep 17 00:00:00 2001 From: vjpai Date: Wed, 8 Jul 2015 10:31:15 -0700 Subject: Merge non-tty path with Windows path since they do the same thing --- tools/run_tests/jobset.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'tools/run_tests/jobset.py') diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py index e262d00bb6..baa126ba5f 100755 --- a/tools/run_tests/jobset.py +++ b/tools/run_tests/jobset.py @@ -95,28 +95,21 @@ def message(tag, msg, explanatory_text=None, do_newline=False): return message.old_tag = tag message.old_msg = msg - if platform.system() == 'Windows': + if platform.system() == 'Windows' or not sys.stdout.isatty(): if explanatory_text: print explanatory_text print '%s: %s' % (tag, msg) return try: - if sys.stdout.isatty(): - sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % ( - _BEGINNING_OF_LINE, - _CLEAR_LINE, - '\n%s' % explanatory_text if explanatory_text is not None else '', - _COLORS[_TAG_COLOR[tag]][1], - _COLORS[_TAG_COLOR[tag]][0], - tag, - msg, - '\n' if do_newline or explanatory_text is not None else '')) - else: - sys.stdout.write('%s%s: %s%s' % ( - '\n%s' % explanatory_text if explanatory_text is not None else '', - tag, - msg, - '\n')) + sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % ( + _BEGINNING_OF_LINE, + _CLEAR_LINE, + '\n%s' % explanatory_text if explanatory_text is not None else '', + _COLORS[_TAG_COLOR[tag]][1], + _COLORS[_TAG_COLOR[tag]][0], + tag, + msg, + '\n' if do_newline or explanatory_text is not None else '')) sys.stdout.flush() except: pass -- cgit v1.2.3