spinetoolbox.execution_managers

Classes to manage tool instance execution in various forms.

author:
  1. Savolainen (VTT)
date:

1.2.2018

Module Contents

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

Bases: PySide2.QtCore.QObject

Base class for all tool instance execution managers.

Class constructor.

Parameters:logger (LoggerInterface) – a logger instance
execution_finished[source]
start_execution(self, workdir=None)[source]

Starts the execution.

Parameters:workdir (str) – Work directory
stop_execution(self)[source]

Stops the execution.

class spinetoolbox.execution_managers.ConsoleExecutionManager(console, commands, logger)[source]

Bases: spinetoolbox.execution_managers.ExecutionManager

Class to manage tool instance execution using a SpineConsoleWidget.

Class constructor.

Parameters:
  • console (SpineConsoleWidget) – Console widget where execution happens
  • commands (list) – List of commands to execute in the console
  • logger (LoggerInterface) – a logger instance
start_execution(self, workdir=None)[source]

See base class.

_start_execution(self)[source]

Starts execution.

_execute_next_command(self)[source]

Executes next command in the buffer.

stop_execution(self)[source]

See base class.

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

Bases: spinetoolbox.execution_managers.ExecutionManager

Class to manage tool instance execution using a PySide2 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) – List of argument for the program (e.g. path to script file)
  • silent (bool) – Whether or not to emit logger msg signals
program(self)[source]

Program getter method.

args(self)[source]

Program argument getter method.

start_execution(self, workdir=None)[source]

Starts the execution of a command in a QProcess.

Parameters:workdir (str) – Work directory
inject_data_to_write_channel(self)[source]

Writes data to process write channel and closes it afterwards.

wait_for_process_finished(self, msecs=30000)[source]

Wait for subprocess to finish.

Returns:True if process finished successfully, False otherwise
process_started(self)[source]

Run when subprocess has started.

on_state_changed(self, new_state)[source]

Runs when QProcess state changes.

Parameters:new_state (QProcess::ProcessState) – Process state number
on_process_error(self, process_error)[source]

Run if there is an error in the running QProcess.

Parameters:process_error (QProcess::ProcessError) – Process error number
stop_execution(self)[source]

See base class.

on_process_finished(self, exit_code, exit_status)[source]

Runs when subprocess has finished.

Parameters:exit_code (int) – Return code from external program (only valid for normal exits)
on_ready_stdout(self)[source]

Emit data from stdout.

on_ready_stderr(self)[source]

Emit data from stderr.