Skip to content

Commit

Permalink
compiler: only use colors in diagnostics on POSIX (fixes #272).
Browse files Browse the repository at this point in the history
whitequark committed Feb 22, 2016
1 parent 4946a53 commit 9db2be2
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion artiq/compiler/testbench/signature.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ def process_diagnostic(diag):
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)

5 changes: 3 additions & 2 deletions artiq/coredevice/core.py
Original file line number Diff line number Diff line change
@@ -22,9 +22,10 @@ def shorten_path(path):
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 @@ def __init__(self, diagnostic):
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

0 comments on commit 9db2be2

Please sign in to comment.