2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 11:18:27 +08:00

compiler: only use colors in diagnostics on POSIX (fixes #272).

This commit is contained in:
whitequark 2016-02-22 11:27:45 +00:00
parent 4946a53456
commit 9db2be2b03
2 changed files with 4 additions and 3 deletions

View File

@ -14,7 +14,7 @@ def main():
else:
diag = False
def process_diagnostic(diag):
print("\n".join(diag.render(colored=True)))
print("\n".join(diag.render(colored=False)))
if diag.level in ("fatal", "error"):
exit(1)

View File

@ -22,9 +22,10 @@ def _render_diagnostic(diagnostic, colored):
lines = [shorten_path(path) for path in diagnostic.render(colored=colored)]
return "\n".join(lines)
colors_supported = (os.name == 'posix')
class _DiagnosticEngine(diagnostic.Engine):
def render_diagnostic(self, diagnostic):
sys.stderr.write(_render_diagnostic(diagnostic, colored=True) + "\n")
sys.stderr.write(_render_diagnostic(diagnostic, colored=colors_supported) + "\n")
class CompileError(Exception):
def __init__(self, diagnostic):
@ -33,7 +34,7 @@ class CompileError(Exception):
def __str__(self):
# Prepend a newline so that the message shows up on after
# exception class name printed by Python.
return "\n" + _render_diagnostic(self.diagnostic, colored=True)
return "\n" + _render_diagnostic(self.diagnostic, colored=colors_supported)
@syscall