Пример #1
0
    def email_handler_level(self, level=logging.WARNING):
        """Setter: Logging level for email notifications."""

        # find all email handlers (there should be only one)
        eh = [
            x for x in root_logger.handlers if type(x) == logging.handlers.SMTPHandler
        ]

        if len(eh) == 0:
            logger.warning("No email handler could be found.")
        else:
            eh[0].setLevel(level)
        # update conf file
        CONF.set("CustomXepr", "email_handler_level", level)
Пример #2
0
    def notify_address(self, email_list):
        """Setter: Address list for email notifications."""

        # find all email handlers (there should be only one)
        eh = [
            x for x in root_logger.handlers if type(x) == logging.handlers.SMTPHandler
        ]

        if len(eh) == 0:
            logging.warning("No email handler could be found.")
        elif len(eh) > 0:
            for handler in eh:
                handler.toaddrs = email_list

        email_list_str = ", ".join(email_list)
        logger.info("Email notifications will be sent to " + email_list_str + ".")

        # update conf file
        CONF.set("CustomXepr", "notify_address", email_list)