spinetoolbox.execution_managers

Classes to manage tool instance execution in various forms.

Module Contents

Classes

ExecutionManager

Base class for all tool instance execution managers.

QProcessExecutionManager

Class to manage tool instance execution using a PySide6 QProcess.

class spinetoolbox.execution_managers.ExecutionManager(logger)[source]

Bases: PySide6.QtCore.QObject

Base class for all tool instance execution managers.

Class constructor.

Parameters

logger (LoggerInterface) – a logger instance

execution_finished[source]
abstract start_execution(workdir=None)[source]

Starts the execution.

Parameters

workdir (str) – Work directory

abstract stop_execution()[source]

Stops the execution.

class spinetoolbox.execution_managers.QProcessExecutionManager(logger, program='', args=None, silent=False, semisilent=False)[source]

Bases: ExecutionManager

Class to manage tool instance execution using a PySide6 QProcess.

Class constructor.

Parameters
  • logger (LoggerInterface) – a logger instance

  • program (str) – Path to program to run in the subprocess (e.g. julia.exe)

  • args (list, optional) – List of argument for the program (e.g. path to script file)

  • silent (bool) – Whether or not to emit logger msg signals

  • semisilent (bool) – If True, show Process Log messages

program()[source]

Program getter method.

args()[source]

Program argument getter method.

start_execution(workdir=None)[source]

Starts the execution of a command in a QProcess.

Parameters

workdir (str, optional) – Work directory

wait_for_process_finished(msecs=30000)[source]

Wait for subprocess to finish.

Parameters

msecs (int) – Timeout in milliseconds

Returns

True if process finished successfully, False otherwise

process_started()[source]

Run when subprocess has started.

on_state_changed(new_state)[source]

Runs when QProcess state changes.

Parameters

new_state (int) – Process state number (QProcess::ProcessState)

on_process_error(process_error)[source]

Runs if there is an error in the running QProcess.

Parameters

process_error (int) – Process error number (QProcess::ProcessError)

teardown_process()[source]

Tears down the QProcess in case a QProcess.ProcessError occurred. Emits execution_finished signal.

stop_execution()[source]

See base class.

on_process_finished(exit_code, exit_status)[source]

Runs when subprocess has finished.

Parameters
  • exit_code (int) – Return code from external program (only valid for normal exits)

  • exit_status (int) – Crash or normal exit (QProcess::ExitStatus)

on_ready_stdout()[source]

Emit data from stdout.

on_ready_stderr()[source]

Emit data from stderr.