mirror of https://github.com/m-labs/artiq.git
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)
|
return "\n".join(lines)
|
||||||
|
|
||||||
class _DiagnosticEngine(diagnostic.Engine):
|
class _DiagnosticEngine(diagnostic.Engine):
|
||||||
def print_diagnostic(self, diagnostic):
|
def render_diagnostic(self, diagnostic):
|
||||||
sys.stderr.write(_render_diagnostic(diagnostic) + "\n")
|
sys.stderr.write(_render_diagnostic(diagnostic) + "\n")
|
||||||
|
|
||||||
class CompileError(Exception):
|
class CompileError(Exception):
|
||||||
|
|
|
@ -54,7 +54,6 @@ def main():
|
||||||
core.compile(exp.run, [exp_inst], {},
|
core.compile(exp.run, [exp_inst], {},
|
||||||
with_attr_writeback=False)
|
with_attr_writeback=False)
|
||||||
except CompileError as error:
|
except CompileError as error:
|
||||||
print(error.render_string(colored=True), file=sys.stderr)
|
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
device_mgr.close_devices()
|
device_mgr.close_devices()
|
||||||
|
|
|
@ -129,7 +129,6 @@ def run(with_file=False):
|
||||||
exp_inst.run()
|
exp_inst.run()
|
||||||
exp_inst.analyze()
|
exp_inst.analyze()
|
||||||
except CompileError as error:
|
except CompileError as error:
|
||||||
print(error.render_string(colored=True), file=sys.stderr)
|
|
||||||
return
|
return
|
||||||
except Exception as exn:
|
except Exception as exn:
|
||||||
if hasattr(exn, 'artiq_exception'):
|
if hasattr(exn, 'artiq_exception'):
|
||||||
|
|
|
@ -230,6 +230,7 @@ def main():
|
||||||
elif action == "terminate":
|
elif action == "terminate":
|
||||||
break
|
break
|
||||||
except CompileError as exc:
|
except CompileError as exc:
|
||||||
|
# TODO: This should be replaced with a proper DiagnosticEngine.
|
||||||
message = "Cannot compile {}\n".format(experiment_file) + exc.render_string()
|
message = "Cannot compile {}\n".format(experiment_file) + exc.render_string()
|
||||||
if repository_path is not None:
|
if repository_path is not None:
|
||||||
message = message.replace(repository_path, "<repository>")
|
message = message.replace(repository_path, "<repository>")
|
||||||
|
|
Loading…
Reference in New Issue