forked from M-Labs/artiq
Refactor the logic of printing diagnostics to solely rely on Engine.
This commit is contained in:
parent
05fa80818a
commit
03dd1c3a43
|
@ -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):
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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'):
|
||||
|
|
|
@ -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>")
|
||||
|
|
Loading…
Reference in New Issue