Commit 3423cf0f authored by Jonas Kaufmann's avatar Jonas Kaufmann
Browse files

symphony/runtime/simulation_executor.py: add separate callbacks for simulator prepare commands

parent c2a47003
......@@ -207,7 +207,23 @@ class CommandExecutorFactory:
async def exec_simulator_prepare_cmds(self, sim: sim_base.Simulator, cmds: list[str]) -> None:
for cmd in cmds:
executor = await self.start_simulator(sim, cmd)
async def started_cb() -> None:
await self._sim_exec_cbs.simulator_prepare_started(sim, cmd)
async def exited_cb(exit_code: int) -> None:
await self._sim_exec_cbs.simulator_prepare_exited(sim, exit_code)
async def stdout_cb(lines: list[str]) -> None:
await self._sim_exec_cbs.simulator_prepare_stdout(sim, lines)
async def stderr_cb(lines: list[str]) -> None:
await self._sim_exec_cbs.simulator_prepare_stderr(sim, lines)
executor = CommandExecutor(
cmd, sim.full_name(), started_cb, exited_cb, stdout_cb, stderr_cb
)
await executor.start()
await executor.wait()
async def start_simulator(self, sim: sim_base.Simulator, cmd) -> CommandExecutor:
......
......@@ -67,6 +67,29 @@ class LocalSimulationExecutorCallbacks(sim_exec.SimulationExecutorCallbacks):
# Simulator-related callbacks -
# -----------------------------
async def simulator_prepare_started(self, sim: sim_base.Simulator, cmd: str) -> None:
await super().simulator_prepare_started(sim, cmd)
self._output.set_simulator_cmd(sim, cmd)
if self._verbose:
print(f"+ [{sim.full_name()}] {cmd}")
async def simulator_prepare_exited(self, sim: sim_base.Simulator, exit_code: int) -> None:
await super().simulator_prepare_exited(sim, exit_code)
if self._verbose:
print(f"- [{sim.full_name()}] exited with code {exit_code}")
async def simulator_prepare_stdout(self, sim: sim_base.Simulator, lines: list[str]) -> None:
await super().simulator_prepare_stdout(sim, lines)
if self._verbose:
for line in lines:
print(f"[{sim.full_name()}] {line}")
async def simulator_prepare_stderr(self, sim: sim_base.Simulator, lines: list[str]) -> None:
await super().simulator_prepare_stderr(sim, lines)
if self._verbose:
for line in lines:
print(f"[{sim.full_name()}] {line}")
async def simulator_started(self, sim: sim_base.Simulator, cmd: str) -> None:
await super().simulator_started(sim, cmd)
if self._verbose:
......
......@@ -74,6 +74,18 @@ class SimulationExecutorCallbacks:
# Simulator-related callbacks -
# -----------------------------
async def simulator_prepare_started(self, sim: sim_base.Simulator, cmd: str) -> None:
self._output.set_simulator_cmd(sim, cmd)
async def simulator_prepare_exited(self, sim: sim_base.Simulator, exit_code: int) -> None:
pass
async def simulator_prepare_stdout(self, sim: sim_base.Simulator, lines: list[str]) -> None:
self._output.append_simulator_stdout(sim, lines)
async def simulator_prepare_stderr(self, sim: sim_base.Simulator, lines: list[str]) -> None:
self._output.append_simulator_stderr(sim, lines)
async def simulator_started(self, sim: sim_base.Simulator, cmd: str) -> None:
self._output.set_simulator_cmd(sim, cmd)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment