selinon.system module¶
Core Selinon logic for system representation, parsing and handling actions.
-
class
selinon.system.
System
(tasks=None, flows=None, storages=None, task_classes=None)[source]¶ Bases:
object
The representation of the whole system.
-
add_flow
(flow)[source]¶ Register a flow in the system.
Parameters: flow (flow) – a flow to be registered
-
add_storage
(storage)[source]¶ Add storage to system.
Parameters: storage – storage that should be added
-
add_task
(task)[source]¶ Register a task in the system.
Parameters: task (selinon.selinon_task.Task) – a task to be registered
-
class_of_task
(task)[source]¶ Return task class of a task.
Parameters: task – task to look task class for Returns: TaskClass or None if a task class for task is not available
-
dispatcher_queue_names
()[source]¶ Get information about queue names per dispatcher/flow.
Returns: dispatcher queue names based on flow names
-
dump2file
(output_file)[source]¶ Perform system dump to a Python source code.
Parameters: output_file – an output file to write to
-
dump2stream
(stream)[source]¶ Perform system dump to a Python source code to an output stream.
Parameters: stream – an output stream to write to
-
flow_by_name
(name, graceful=False)[source]¶ Find a flow by its name.
Parameters: - name – a flow name
- graceful – if True, no exception is raised if flow couldn’t be found
Returns: flow with name ‘name’
Return type: Raises: ConfigurationError – on non-existing flow name
-
classmethod
from_dict
(nodes_definition, flow_definitions, no_check=False)[source]¶ Construct System from dictionaries.
Parameters: - nodes_definition (list) – parsed nodes definition
- flow_definitions – a list of parsed flow definitions
- no_check – True if system shouldn’t be checked for consistency (recommended to check)
Returns: System instance
Return type:
-
classmethod
from_files
(nodes_definition_file, flow_definition_files, no_check=False)[source]¶ Construct System from files.
Parameters: Returns: System instance
Return type:
-
node_by_name
(name, graceful=False)[source]¶ Find a node (flow or task) by its name.
Parameters: - name – a node name
- graceful – if True, no exception is raised if node couldn’t be found
Returns: flow with name ‘name’
Return type: Raises: KeyError
-
plot_graph
(output_dir, image_format=None)[source]¶ Plot system flows to graphs - each flow in a separate file.
Parameters: - output_dir – output directory to write graphs of flows to
- image_format – image format, the default is svg if None
Returns: list of file names to which the graph was rendered
Return type: List[str]
-
storage_by_name
(name, graceful=False)[source]¶ Retrieve storage by its name.
Parameters: - name – name of the storage
- graceful – if true, exception is raised if no such storage with name name is found
Returns: storage
-
task_by_name
(name, graceful=False)[source]¶ Find a task by its name.
Parameters: - name – a task name
- graceful – if True, no exception is raised if task couldn’t be found
Returns: task with name ‘name’
Return type: selinon.selinon_task.Task
Raises: ConfigurationError – on non-existing task name
-