forked from M-Labs/artiq
1
0
Fork 0

Refactor the logic of printing diagnostics to solely rely on Engine.

This commit is contained in:
whitequark 2016-01-04 22:11:54 +08:00
parent 05fa80818a
commit 03dd1c3a43
4 changed files with 2 additions and 3 deletions

View File

@ -20,7 +20,7 @@ def _render_diagnostic(diagnostic):
return "\n".join(lines)
class _DiagnosticEngine(diagnostic.Engine):
def print_diagnostic(self, diagnostic):
def render_diagnostic(self, diagnostic):
sys.stderr.write(_render_diagnostic(diagnostic) + "\n")
class CompileError(Exception):

View File

@ -54,7 +54,6 @@ def main():
core.compile(exp.run, [exp_inst], {},
with_attr_writeback=False)
except CompileError as error:
print(error.render_string(colored=True), file=sys.stderr)
return
finally:
device_mgr.close_devices()

View File

@ -129,7 +129,6 @@ def run(with_file=False):
exp_inst.run()
exp_inst.analyze()
except CompileError as error:
print(error.render_string(colored=True), file=sys.stderr)
return
except Exception as exn:
if hasattr(exn, 'artiq_exception'):

View File

@ -230,6 +230,7 @@ def main():
elif action == "terminate":
break
except CompileError as exc:
# TODO: This should be replaced with a proper DiagnosticEngine.
message = "Cannot compile {}\n".format(experiment_file) + exc.render_string()
if repository_path is not None:
message = message.replace(repository_path, "<repository>")