Callbacks
- class yasmon.callbacks.CallbackDict(mapping=(), **kwargs)
A dedicated dictionary for callbacks.
- class yasmon.callbacks.ShellCallback(name: str, cmd: str)
Callback implementing shell command execution.
- __init__(name: str, cmd: str) None
- Parameters:
name – unique identifier
cmd – command to be executed
- classmethod from_yaml(name: str, data: str) Self
ShellCallback
can be also constructed from a YAML snippet.command: ls -lah /path/to/some/dir/
- Parameters:
name – unique identifier
data – YAML snippet
- Returns:
new instance
- Return type:
- class yasmon.callbacks.LoggerCallback(name: str, level: str, message: str)
Callback implementing logger calls
- __init__(name: str, level: str, message: str) None
- Parameters:
name – unique identifier
level – logging level
message – message to pass to logger
- classmethod from_yaml(name: str, data: str) Self
LoggerCallback
can be also constructed from a YAML snippet.level: [error | info | debug | ... (see Loguru docs)] message: message
- Parameters:
name – unique identifier
data – YAML snippet
- Returns:
new instance
- Return type:
- class yasmon.callbacks.MailCallback(name: str, host: str, port: int, login: str, password: str, security: str, toaddr: str, subject: str, fromaddr: str, message: str, attach: list[str], delay: int)
Callback implementing sending simple notification mails with attachments.
- __init__(name: str, host: str, port: int, login: str, password: str, security: str, toaddr: str, subject: str, fromaddr: str, message: str, attach: list[str], delay: int) None
- Parameters:
name – unique callback identifier
host – smtp host
port – smtp port
login – login name
password – password
security –
starttls
orssl
toaddr – to address
subject – mail subject
fromaddr – from address
message – message
- send_message_starttls(message: EmailMessage)
Send message using STARTTLS.
- send_message_ssl(message: EmailMessage)
Send message using SSL.
- process_attachments(message: EmailMessage, attrs: dict[str, str]) None
Process list of attachments from
attach
and attach these tomessage
.- Raises:
CallbackError – if path to file does not exist
- classmethod from_yaml(name: str, data: str) Self
MailCallback
can be also constructed from a YAML snippet.host: [SMTP_HOST] port: [SMTP_PORT] login: [SMTP_LOGIN] password: [SMTP_PASSWORD] security: [starttls | ssl] from: account@host.com to: account@anotherhost.com subject: Some subject with an attribute {subject} message: Some message with attributes {message} {date} attach: - patch/to/file1 - patch/to/file2 delay: 42
- Parameters:
name – unique identifier
data – YAML snippet
- Returns:
new instance
- Return type:
- class yasmon.callbacks.AbstractCallback
Abstract class from which all callback classes are derived.
Derived callbacks are functors and can be used as coroutines for any of
yasmon.tasks.AbstractTasks
.The preferred way to instatiate a callback is from class method
from_yaml()
.- abstract async __call__(task: AbstractTask, attrs: dict[str, str])
Coroutine called by
TaskRunner
.- Parameters:
task – task calling the callback
- Raises:
CallbackError – see documentation
CallbackAttributeError – see documentation
CallbackCircularAttributeError – see documentation
- abstract classmethod from_yaml(name: str, data: str)
A class method for constructing a callback from a YAML document.
- Parameters:
name – unique identifier
data – yaml data
- Returns:
new instance
- class yasmon.callbacks.CallbackAttributeError(attr: str, message='undefined attribute {attr}')
Raised when an undefined task attribute is used by a callback.
- class yasmon.callbacks.CallbackCircularAttributeError(expr: str, message='{expr}\ndetected circular attributes')
Raised when task attributes have circular dependencies.
- class yasmon.callbacks.CallbackSyntaxError(message='callback syntax error')
Raised on callback syntax error.
- yasmon.callbacks.process_attributes(expr: str, attrs: dict[str, str]) str
Performs attribute substitutions in expr.
This is also checking for circular dependencies (max_depth = 42).
- Parameters:
expr – expression to process
attrs – attributes to substitute
- Raises:
CallbackCircularAttributeError – see documentation
CallbackAttributeError – see documentation
- Returns:
processed expression
- Return type:
str