Skip to content

BatchExecCmdIter

Bases: ABC

Abstract base class defining hooks for executing a batch of shell commands.

Subclasses must implement get_command_context to provide the command to run for each iteration. Optional hooks (pre_callable, post_callable, and end_callable) can be overridden to customize behavior before, after, and at the end of the batch execution.

list[str] | None

If set, the strings in this list are searched (case-insensitive) in stdout and stderr after each run. If any keyword is found, the run is marked as failed — even if the return code is 0. This is useful for executables (e.g. Fortran codes) that print error messages without setting a non-zero return code. Define it as a class attribute in your subclass: out_err_keywords = ["erreur", "error", "fatal"] or set it on an instance after construction.

end_callable(nb_errors)

Called at the end of the complete batch (optional).

get_command_context(index_run) abstractmethod

Returns the shell command context to execute for a given iteration. TODO returns or simply the command

get_nb_runs() abstractmethod

Returns the number of runs to execute.

post_callable(index_run, error)

Called after each command (optional). If it returns a string, that string is treated as an error description and the run is counted as failed.

pre_callable(index_run)

Called before each command (optional).

start_callable()

Called at the start of the complete batch (optional).