leapp.actors package¶
Module contents¶
-
class
leapp.actors.
Actor
(messaging=None, logger=None, config_model=None, skip_dialogs=False)¶ Bases:
object
The Actor class represents the smallest step in the workflow. It defines what kind of data it expects, it consumes (processes) the given data, and it produces data for other actors in the workflow.
-
class
ErrorSeverity
¶ Bases:
object
Convenience forward for the
leapp.models.error_severity.ErrorSeverity
constants.-
ALLOWED_VALUES
= ('fatal', 'error', 'warning')¶
-
ERROR
= 'error'¶
-
FATAL
= 'fatal'¶
-
WARNING
= 'warning'¶
-
classmethod
validate
(value)¶
-
-
actor_files_paths
¶ Returns the file paths that are bundled with the actor. (Path to the content of the actor’s file directory).
-
actor_tools_paths
¶ Returns the tool paths that are bundled with the actor. (Path to the content of the actor’s tools directory).
-
apis
= ()¶ Tuple of
leapp.workflow.api.WorkflowAPI
derived classes that implement Workflow APIs that are used by an actor. Any models the apis produce or consume will be considered by the framework as if the actor defined them.
-
common_files_paths
¶ Returns all common repository file paths.
-
common_tools_paths
¶ Returns all common repository tool paths.
-
configuration
¶ Returns the config model generated by specific workflow configuration actor
-
consume
(*models)¶ Retrieve messages specified in the actors
consumes
attribute, and filter message types by models.Parameters: models (Variable number of the derived classes from leapp.models.Model
) – Models to use as a filter for the messages to returnReturns: All messages of the specified model(s) produced by other actors Return type: Iterable with messages or an empty tuple
-
consumes
= ()¶ Tuple of
leapp.models.Model
derived classes defined in the repositories that define messages the actor consumes.
-
current_instance
= None¶ Instance of the currently executed actor. Within a process only exist one Actor instance. This will allow convenience functions for library developers to be available.
-
description
= None¶ Deprecated since version 0.5.0: Write the actor’s description as a docstring.
-
dialogs
= ()¶ Tuple of
leapp.dialogs.dialog.Dialog
derived classes that define questions to ask the user. Dialogs that are added to this list allow for persisting answers the user has given in the answer file storage.
-
files_paths
¶ Returns all actor file paths related to the actor and common actors file paths.
-
get_actor_file_path
(name)¶ Finds the first matching file path within
actor_files_paths
.Parameters: name (str) – Name of the file Returns: Found file path Return type: str or None
-
get_actor_folder_path
(name)¶ Finds the first matching folder path within
actor_files_paths
.Parameters: name (str) – Name of the folder Returns: Found folder path Return type: str or None
-
get_actor_tool_path
(name)¶ Finds the first matching executable file path within
actor_tools_paths
.Parameters: name (str) – Name of the file Returns: Found file path Return type: str or None
-
get_answers
(dialog)¶ Gets the answers for a dialog. The dialog needs be predefined in
dialogs
.Parameters: dialog – Dialog instance to show Returns: dictionary with the requested answers, None if not a defined dialog
-
get_common_file_path
(name)¶ Finds the first matching file path within
common_files_paths
.Parameters: name (str) – Name of the file Returns: Found file path Return type: str or None
-
get_common_folder_path
(name)¶ Finds the first matching folder path within
common_files_paths
.Parameters: name (str) – Name of the folder Returns: Found folder path Return type: str or None
-
get_common_tool_path
(name)¶ Finds the first matching executable file path within
common_tools_paths
.Parameters: name (str) – Name of the file Returns: Found file path Return type: str or None
-
get_file_path
(name)¶ Finds the first matching file path within
files_paths
.Parameters: name (str) – Name of the file Returns: Found file path Return type: str or None
-
get_folder_path
(name)¶ Finds the first matching folder path within
files_paths
.Parameters: name (str) – Name of the folder Returns: Found folder path Return type: str or None
-
get_tool_path
(name)¶ Finds the first matching executable file path within
tools_paths
.Parameters: name (str) – Name of the file Returns: Found file path Return type: str or None
-
name
= None¶ Name of the actor that is used to identify data or messages created by the actor.
-
process
(*args, **kwargs)¶ Main processing method. In inherited actors, the function needs to be defined to be able to be processed.
-
produce
(*models)¶ By calling produce, model instances are stored as messages. Those messages can be then consumed by other actors.
Parameters: models (Variable number of the derived classes from leapp.models.Model
) – Messages to be sent (those model types have to be specified inproduces
-
produces
= ()¶ Tuple of
leapp.models.Model
derived classes defined in the repositories that define messages the actor produces.
-
report_error
(message, severity='error', details=None)¶ Reports an execution error
Parameters: - message (str) – A message to print the possible error
- severity (str with defined values from
leapp.messaging.errors.ErrorSeverity.ERROR
) – Severity of the error defaultleapp.messaging.errors.ErrorSeverity.ERROR
- details (dict) – A dictionary where additional context information is passed along with the error
Returns: None
-
serialize
()¶ Returns: Serialized information for the actor
-
show_message
(message)¶ Display a message in user interterface currently in use (CLI, GUI).
It uses one of the dialog renderers in
leapp.dialogs.renderer
.Parameters: message (str) – Message to show
-
skip_dialogs
= None¶ A configured logger instance for the current actor.
Tuple of
leapp.tags.Tag
derived classes by which workflow phases select actors for execution.
-
text_domain
= None¶ Using text domain allows to override the default gettext text domain, for custom localization support. The default locale installation location is used which usually is /usr/share/locale
-
tools_paths
¶ Returns all actor tools paths related to the actor and common actors tools paths.
-
class
-
leapp.actors.
get_actor_metadata
(actor)¶ Creates Actor’s metadata dictionary
Parameters: actor (derived class from leapp.actors.Actor
) – Actor whose metadata are neededReturns: Dictionary with the name, tags, consumes, produces, and description of the actor
-
leapp.actors.
get_actors
()¶ Returns: All registered actors with their metadata