:py:mod:`eelib.utils.notification` ================================== .. py:module:: eelib.utils.notification .. autoapi-nested-parse:: Sends notifications for the status of simulations. | Author: elenia@TUBS | Copyright 2024 elenia | This file is part of eELib, which is free software under the terms of the GNU GPL Version 3. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: eelib.utils.notification.Notifier eelib.utils.notification.EmailNotifier eelib.utils.notification.WebexNotifier eelib.utils.notification.StatusMonitor eelib.utils.notification.StatusMonitorEmail eelib.utils.notification.StatusMonitorWebex Attributes ~~~~~~~~~~ .. autoapisummary:: eelib.utils.notification._logger .. py:data:: _logger .. py:class:: Notifier Bases: :py:obj:`abc.ABC` Abstract parent class for notifier objects. .. py:method:: send_message(sim_identifier: str, success: bool, message: str = None, recipient_email: str = None) :abstractmethod: Abstract method for sending a message. :param sim_identifier: an identifier for the simulation. :type sim_identifier: str :param success: whether or not the simulation was successful. :type success: bool :param message: An additional message. Defaults to None. :type message: str :param recipient_email: the recipient email. Defaults to None. :type recipient_email: str .. py:method:: construct_message(sim_identifier: str, success: bool, message: str = None) Method to construct a message depending on success or failure of a simulation. :param sim_identifier: an identifier for the simulation. :type sim_identifier: str :param success: whether or not the simulation was successful. :type success: bool :param message: An additional message. Defaults to None. :type message: str :returns: the subject and content of the constructed message. :rtype: str, str .. py:class:: EmailNotifier(smtp_server: str = None, smtp_port: int = None, sender_email: str = None, sender_password: str = None) Bases: :py:obj:`Notifier` Class for sending notifications through email. Extends Notifier. .. py:method:: send_message(sim_identifier: str, success: bool, message: str = None, recipient_email: str = None) Sends email as a status update for a simulation. :param sim_identifier: an identifier for the simulation. :type sim_identifier: str :param success: whether or not the simulation was successful. :type success: bool :param message: An additional message. Defaults to None. :type message: str :param recipient_email: the recipient email. Defaults to None. :type recipient_email: str .. py:class:: WebexNotifier(api_url: str = None, access_token: str = None) Bases: :py:obj:`Notifier` Class for sending notifications through Webex App. Extends Notifier. .. py:method:: send_message(sim_identifier: str, success: bool, message: str = None, recipient_email: str = None) Sends webex message as a status update for a simulation. :param sim_identifier: an identifier for the simulation. :type sim_identifier: str :param success: whether or not the simulation was successful. :type success: bool :param message: An additional message. Defaults to None. :type message: str :param recipient_email: the recipient's email. Defaults to None. :type recipient_email: str :returns: json-encoded content of response or None. :rtype: Any .. py:class:: StatusMonitor(notifier, sim_identifier, recipient_email=None) Bases: :py:obj:`abc.ABC` Abstract parent class for a group of context manager classes. Monitors the status of simulation and informs the user about success or failure. Use in the following format: `with StatusMonitor(...):` `execute_simulation()` .. py:method:: __enter__() Called at the beginning of a with statement. Performs setup actions. .. py:method:: __exit__(exc_type, exc_val, exc_tb) Called at the end of a with statement. Performs teardown actions and handles exceptions. :param exc_type: The type of the exception if any. :type exc_type: Any :param exc_val: The value of the exception (e.g., the exception instance) if any. :type exc_val: Any :param exc_tb: A traceback object encapsulating the call stack at the point where the exception occurred. :type exc_tb: Any :returns: returns False to propogate the exception. :rtype: bool .. py:class:: StatusMonitorEmail(sim_identifier, recipient_email=None, **kwargs) Bases: :py:obj:`StatusMonitor` context manager class used to notify user of a simulation's status through email. Extends StatusMonitor. Use in the following format: `with StatusMonitor(...):` `execute_simulation()` .. py:class:: StatusMonitorWebex(sim_identifier, recipient_email=None, **kwargs) Bases: :py:obj:`StatusMonitor` context manager class used to notify user of a simulation's status through Webex. Extends StatusMonitor. Use in the following format: `with StatusMonitor(...):` `execute_simulation()`