Skip to content
Snippets Groups Projects
Commit b461145b authored by vjpai's avatar vjpai
Browse files

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

parent c6964b1d
Branches
Tags
No related merge requests found
...@@ -101,6 +101,7 @@ def message(tag, msg, explanatory_text=None, do_newline=False): ...@@ -101,6 +101,7 @@ def message(tag, msg, explanatory_text=None, do_newline=False):
print '%s: %s' % (tag, msg) print '%s: %s' % (tag, msg)
return return
try: try:
if sys.stdout.isatty():
sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % ( sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % (
_BEGINNING_OF_LINE, _BEGINNING_OF_LINE,
_CLEAR_LINE, _CLEAR_LINE,
...@@ -110,6 +111,12 @@ def message(tag, msg, explanatory_text=None, do_newline=False): ...@@ -110,6 +111,12 @@ def message(tag, msg, explanatory_text=None, do_newline=False):
tag, tag,
msg, msg,
'\n' if do_newline or explanatory_text is not None else '')) '\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() sys.stdout.flush()
except: except:
pass pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment