# Path: doorman/extensions.py
# class LogTee(object):
# class RuleManager(object):
#     class ContextTask(TaskBase):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def handle_status(self, data, **kwargs):
#     def handle_result(self, data, **kwargs):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def load_alerters(self):
#     def should_reload_rules(self):
#     def load_rules(self):
#     def handle_log_entry(self, entry, node):
# def make_celery(app, celery):
#         def __call__(self, *args, **kwargs):
# 
# Path: doorman/plugins/alerters/base.py
# class AbstractAlerterPlugin(with_metaclass(ABCMeta)):
#     """
#     AbstractAlerterPlugin is the base class for all alerters in Doorman. It
#     defines the interface that an alerter should implement in order to support
#     sending an alert.
#     """
#     @abstractmethod
#     def handle_alert(self, node, match):
#         raise NotImplementedError()


import datetime as dt
import string
from flask import render_template
from flask_mail import Message
from doorman.extensions import mail
from .base import AbstractAlerterPlugin
        params.update(node)
        params.update(node.get('node_info', {}))
        params.update(match.result['columns'])

        subject = string.Template(
            render_template(
                subject_template,
                prefix=subject_prefix,
                match=match,
                timestamp=dt.datetime.utcnow(),
                node=node
            )
        ).safe_substitute(**params)

        body = string.Template(
            render_template(
                message_template,
                match=match,
                timestamp=dt.datetime.utcnow(),
                node=node
            )
        ).safe_substitute(**params)

        message = Message(
            subject.strip(),
            recipients=self.recipients,
            body=body,
            charset='utf-8',
        )


# Path: doorman/extensions.py
# class LogTee(object):
# class RuleManager(object):
#     class ContextTask(TaskBase):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def handle_status(self, data, **kwargs):
#     def handle_result(self, data, **kwargs):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def load_alerters(self):
#     def should_reload_rules(self):
#     def load_rules(self):
#     def handle_log_entry(self, entry, node):
# def make_celery(app, celery):
#         def __call__(self, *args, **kwargs):
# 
# Path: doorman/plugins/alerters/base.py
# class AbstractAlerterPlugin(with_metaclass(ABCMeta)):
#     """
#     AbstractAlerterPlugin is the base class for all alerters in Doorman. It
#     defines the interface that an alerter should implement in order to support
#     sending an alert.
#     """
#     @abstractmethod
#     def handle_alert(self, node, match):
#         raise NotImplementedError()


# Path: doorman/plugins/alerters/emailer.py
import datetime as dt
import string
from flask import render_template
from flask_mail import Message
from doorman.extensions import mail
from .base import AbstractAlerterPlugin

        params.update(node)
        params.update(node.get('node_info', {}))
        params.update(match.result['columns'])

        subject = string.Template(
            render_template(
                subject_template,
                prefix=subject_prefix,
                match=match,
                timestamp=dt.datetime.utcnow(),
                node=node
            )
        ).safe_substitute(**params)

        body = string.Template(
            render_template(
                message_template,
                match=match,
                timestamp=dt.datetime.utcnow(),
                node=node
            )
        ).safe_substitute(**params)

        message = Message(
            subject.strip(),
            recipients=self.recipients,
            body=body,
            charset='utf-8',
        )


        return mail.send(message)