spinetoolbox.headless
¶
Contains facilities to open and execute projects without GUI.
- authors
Soininen (VTT)
- date
29.4.2020
Module Contents¶
Classes¶
A |
|
A ‘task’ which opens and executes a Toolbox project when triggered to do so. |
|
Status codes returned from headless execution. |
Functions¶
|
Executes a project using |
|
Opens a project. |
|
Loads project item specification dictionaries. |
- class spinetoolbox.headless.HeadlessLogger[source]¶
Bases:
PySide2.QtCore.QObject
A
LoggerInterface
compliant logger that uses Python’s standard logging facilities.- msg_proc[source]¶
Emits a message originating from a subprocess (usually something printed to stdout).
- msg_proc_error[source]¶
Emits an error message originating from a subprocess (usually something printed to stderr).
- information_box[source]¶
Requests an ‘information message box’ (e.g. a message window) to be opened with a given title and message.
- class spinetoolbox.headless.ExecuteProject(args, startup_event_type, parent)[source]¶
Bases:
PySide2.QtCore.QObject
A ‘task’ which opens and executes a Toolbox project when triggered to do so.
The execution of this task is triggered by sending it a ‘startup’ QEvent using e.g. QCoreApplication.postEvent()
- Parameters
args (argparse.Namespace) – parsed command line arguments
startup_event_type (int) – expected type id for the event that starts this task
parent (QObject) – a parent object
- _start[source]¶
A private signal to actually start execution. Not to be used directly. Post a startup event instead.
- _open_and_execute_project(self)[source]¶
Opens a project and executes all DAGs in that project.
- Returns
status code
- Return type
- _handle_node_execution_started(self, data)[source]¶
Starts collecting messages from given node.
- Parameters
data (dict) – execution start data
- _handle_node_execution_finished(self, data)[source]¶
Prints messages for finished nodes.
- Parameters
data (dict) – execution end data
- _handle_event_msg(self, data)[source]¶
Stores event messages for later printing.
- Parameters
data (dict) – event message data
- _handle_process_msg(self, data)[source]¶
Stores process messages for later printing.
- Parameters
data (dict) – process message data
- spinetoolbox.headless.headless_main(args)[source]¶
Executes a project using
QCoreApplication
.- Parameters
args (argparser.Namespace) – parsed command line arguments.
- Returns
exit status code; 0 for success, everything else for failure
- Return type
int
- spinetoolbox.headless.open_project(project_dict, project_dir, logger)[source]¶
Opens a project.
- Parameters
project_dict (dict) – a serialized project dictionary
project_dir (str) – path to a directory containing the
.spinetoolbox
dirlogger (LoggerInterface) – a logger
- Returns
item dicts, specification dicts, connection dicts and a DagHandler object
- Return type
tuple
- spinetoolbox.headless._specification_dicts(project_dict, project_dir, logger)[source]¶
Loads project item specification dictionaries.
- Parameters
project_dict (dict) – a serialized project dictionary
project_dir (str) – path to a directory containing the
.spinetoolbox
dirlogger (LoggerInterface) – a logger
- Returns
a mapping from item type to a list of specification dicts
- Return type
dict