From: Jannis Harder Date: Wed, 15 Jun 2022 10:10:52 +0000 (+0200) Subject: SbyProc: New error_callback instead of exit_callback for failing procs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e99884e319e7482c442e519cee4e059f6abd7a21;p=SymbiYosys.git SbyProc: New error_callback instead of exit_callback for failing procs --- diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index ab10614..55b582e 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -87,6 +87,7 @@ class SbyProc: self.output_callback = None self.exit_callback = None + self.error_callback = None def register_dep(self, next_proc): if self.finished: @@ -115,6 +116,14 @@ class SbyProc: if self.exit_callback is not None: self.exit_callback(retcode) + def handle_error(self, retcode): + if self.terminated: + return + if self.logfile is not None: + self.logfile.close() + if self.error_callback is not None: + self.error_callback(retcode) + def terminate(self, timeout=False): if self.task.opt_wait and not timeout: return @@ -185,20 +194,22 @@ class SbyProc: self.task.status = "ERROR" if not self.silent: self.task.log(f"{self.info}: COMMAND NOT FOUND. ERROR.") + self.handle_error(self.p.returncode) self.terminated = True self.task.terminate() return - self.handle_exit(self.p.returncode) - if self.checkretcode and self.p.returncode != 0: self.task.status = "ERROR" if not self.silent: self.task.log(f"{self.info}: task failed. ERROR.") + self.handle_error(self.p.returncode) self.terminated = True self.task.terminate() return + self.handle_exit(self.p.returncode) + self.finished = True for next_proc in self.notify: next_proc.poll() @@ -503,14 +514,15 @@ class SbyTask(SbyConfig): proc.checkretcode = True def instance_hierarchy_callback(retcode): - if retcode != 0: - self.precise_prop_status = False - return if self.design_hierarchy == None: with open(f"{self.workdir}/model/design.json") as f: self.design_hierarchy = design_hierarchy(f) + def instance_hierarchy_error_callback(retcode): + self.precise_prop_status = False + proc.exit_callback = instance_hierarchy_callback + proc.error_callback = instance_hierarchy_error_callback return [proc]