devctrl.task.tasks.SendEmailTask#

class SendEmailTask(subject: str = 'Subject', message: str = '', recipients: list[str] = <factory>)[source]#

Bases: Task

Task that sends an email to a list of recipients.

This task is intended to be used to notify users that a measurement has finished, or that a sample needs to be changed.

The sender is not part of the task and should be configured at the app-level.

Methods

as_dict

Convenience wrapper for dataclasses.asdict(self)

copy

Convenience method for copy.deepcopy(self)

estimate_runtime_s

fields

Return a tuple describing the fields of this dataclass.

from_dict

Recursively construct a SettingsClass from a dictionary.

get_dict

Return the settings as a dictionary.

get_icon_name

Get the icon name of the task.

get_name

Get formatted task name with settings

get_settings_name

Return relevant settings as a formatted string for GUI display

get_type_name

Return the human-readable name of the task.

load_yaml

save_yaml

Attributes

__abstractmethods__ = frozenset({})#
__annotations__ = {'message': <class 'str'>, 'recipients': list[str], 'subject': <class 'str'>}#
__dataclass_fields__ = {'message': Field(name='message',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'The message to send.'}),kw_only=False,_field_type=_FIELD), 'recipients': Field(name='recipients',type=list[str],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'list'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'List of recipient email addresses.'}),kw_only=False,_field_type=_FIELD), 'subject': Field(name='subject',type=<class 'str'>,default='Subject',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'The subject of the message.'}),kw_only=False,_field_type=_FIELD)}#
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)#
__dict__ = mappingproxy({'__module__': 'devctrl.task.tasks', '__firstlineno__': 73, '__annotations__': {'subject': <class 'str'>, 'message': <class 'str'>, 'recipients': list[str]}, '__doc__': 'Task that sends an email to a list of recipients.\n\nThis task is intended to be used to notify users that a measurement has finished,\nor that a sample needs to be changed.\n\nThe sender is not part of the task and should be configured at the app-level.\n', 'subject': 'Subject', 'message': '', 'get_settings_name': <function SendEmailTask.get_settings_name>, 'estimate_runtime_s': <function SendEmailTask.estimate_runtime_s>, 'get_icon_name': <function SendEmailTask.get_icon_name>, '__static_attributes__': (), '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False), '__dataclass_fields__': {'subject': Field(name='subject',type=<class 'str'>,default='Subject',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'The subject of the message.'}),kw_only=False,_field_type=_FIELD), 'message': Field(name='message',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'The message to send.'}),kw_only=False,_field_type=_FIELD), 'recipients': Field(name='recipients',type=list[str],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'list'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'List of recipient email addresses.'}),kw_only=False,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function SendEmailTask.__init__>, '__repr__': <function SendEmailTask.__repr__>, '__eq__': <function SendEmailTask.__eq__>, '__match_args__': ('subject', 'message', 'recipients')})#
__eq__(other)#

Return self==value.

__firstlineno__ = 73#
__hash__ = None#
__init__(subject: str = 'Subject', message: str = '', recipients: list[str] = <factory>) → None#
__match_args__ = ('subject', 'message', 'recipients')#
__module__ = 'devctrl.task.tasks'#
__or__(other)#

Merge with another settings class or a dictionary. Unknown keys in a dictionary are ignored.

__replace__(**changes)#
__repr__()#

Get formatted task name with settings

Returns:

Formatted string as ‘typename (settings_name)’

__slots__ = ()#
__static_attributes__ = ()#
__weakref__#

list of weak references to the object

_abc_impl = <_abc._abc_data object>#
_children: Dict[str, Type[Task]] = {'DebugTask': <class 'devctrl.task.tasks.DebugTask'>, 'DeviceActionTask': <class 'devctrl.task.tasks.DeviceActionTask'>, 'DummyMessageTask': <class 'devctrl.dummy_gui.task.DummyMessageTask'>, 'SendEmailTask': <class 'devctrl.task.tasks.SendEmailTask'>, 'UserConfirmTask': <class 'devctrl.task.tasks.UserConfirmTask'>, 'WaitTask': <class 'devctrl.task.tasks.WaitTask'>}#
_get_dict(remove_empty_containers: bool = False, remove_None: bool = False, remove_if_None: list[str] | None = None) → dict#

Return the settings as a dictionary, optionally cleaning up the output.

Base implementation for get_dict(). Subclasses may call it with different arguments to configure the output.

Parameters:
  • remove_empty_containers – If True, remove empty dict, list, tuple or set values.

  • remove_None – If True, remove all keys with a None value.

  • remove_if_None – If given, remove these keys only if their value is None (absent keys are ignored).

Returns:

Instance converted to dictionary, see as_dict().

as_dict() → dict#

Convenience wrapper for dataclasses.asdict(self)

Returns all fields of the settings class. For a dictionary where certain fields may be skipped, see get_dict().

copy() → Self#

Convenience method for copy.deepcopy(self)

estimate_runtime_s() → int[source]#
fields()#

Return a tuple describing the fields of this dataclass.

Adapted version of dataclass.fields that applies additional sorting of the fields according to the field’s metadata[“order”] parameter.

Accepts a dataclass or an instance of one. Tuple elements are of type Field.

classmethod from_dict(data: dict, strict: bool = False) → Self#

Recursively construct a SettingsClass from a dictionary.

If the value of a field is another SettingsClass, from_dict() will be called for that field as well. Handled are:

  • SettingsClass

  • list[SettingsClass]

  • dict[<any>, SettingsClass]

  • all of the above as Optional (Union with None)

  • a Union with any handled types

Parameters:

strict – If True, raise a KeyError on keys in data that are not field names of cls. Unknown keys are ignored otherwise.

Raises:
  • ValueError – If data contains a value that has the wrong type for the field of cls (ONLY if the type is a subclass of SettingsClass! Other types are not enforced)

  • KeyError – If strict is True and data contains a key that is not a field name of cls

get_dict() → dict#

Return the settings as a dictionary.

as_dict() returns the settings class with all fields, while get_dict() may be configured by subclasses to skip certain fields in the output. The default implementation returns all fields, like as_dict(). :return: Instance converted to dictionary.

get_icon_name() → str[source]#

Get the icon name of the task. Defaults to “square”.”

Returns:

Icon name.

get_name() → str#

Get formatted task name with settings

Returns:

Formatted task name including settings

get_settings_name() → str[source]#

Return relevant settings as a formatted string for GUI display

Iterates through task fields and returns a string representation of non-default values that can be used for displaying the task in the GUI.

Returns:

Formatted string of settings, or empty string if no settings differ from defaults

classmethod get_type_name() → str#

Return the human-readable name of the task.

classmethod load_yaml(yaml_path: str, loader=<class 'yaml.loader.Loader'>)#
message: str = ''#
recipients: list[str]#
save_yaml(yaml_path: str)#
subject: str = 'Subject'#