From 9db2be2b038c674e4b164bf217aa2c2c786a5ed7 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 22 Feb 2016 11:27:45 +0000 Subject: [PATCH] compiler: only use colors in diagnostics on POSIX (fixes #272). --- artiq/compiler/testbench/signature.py | 2 +- artiq/coredevice/core.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/artiq/compiler/testbench/signature.py b/artiq/compiler/testbench/signature.py index d877e2794..5d3ff1aa4 100644 --- a/artiq/compiler/testbench/signature.py +++ b/artiq/compiler/testbench/signature.py @@ -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) diff --git a/artiq/coredevice/core.py b/artiq/coredevice/core.py index 3705e5155..ba03b223b 100644 --- a/artiq/coredevice/core.py +++ b/artiq/coredevice/core.py @@ -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