Stop sending terminal escape sequences if we're redirecting output to a file.

pull/2331/head
vjpai 10 years ago
parent c6964b1d98
commit b461145b79
  1. 7
      tools/run_tests/jobset.py

@ -101,6 +101,7 @@ def message(tag, msg, explanatory_text=None, do_newline=False):
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,
@ -110,6 +111,12 @@ def message(tag, msg, explanatory_text=None, do_newline=False):
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

Loading…
Cancel
Save