spinetoolbox.headless¶
Contains facilities to open and execute projects without GUI.
| authors: |
|
|---|---|
| date: | 29.4.2020 |
Module Contents¶
Classes¶
HeadlessLogger |
A LoggerInterface compliant logger that uses Python’s standard logging facilities. |
ExecuteProject |
A ‘task’ which opens and executes a Toolbox project when triggered to do so. |
_Status |
Status codes returned from headless execution. |
Functions¶
headless_main(args) |
Executes a project using QCoreApplication. |
open_project(project_dict, project_dir, logger) |
Opens a project. |
_specifications(project_dict, project_dir, specification_factories, app_settings, logger) |
Creates project item specifications. |
-
class
spinetoolbox.headless.HeadlessLogger[source]¶ Bases:
PySide2.QtCore.QObjectA
LoggerInterfacecompliant 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.QObjectA ‘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
-
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
.spinetoolboxdir - logger (LoggerInterface) – a logger
Returns: a list of executable items, a dict of item specifications, and a DagHandler object
Return type: tuple
-
spinetoolbox.headless._specifications(project_dict, project_dir, specification_factories, app_settings, logger)[source]¶ Creates project item specifications.
Parameters: - project_dict (dict) – a serialized project dictionary
- project_dir (str) – path to a directory containing the
.spinetoolboxdir - specification_factories (dict) – a mapping from item type to specification factory
- app_settings (QSettings) – Toolbox settings
- logger (LoggerInterface) – a logger
Returns: a mapping from item type and specification name to specification
Return type: dict