<commit_before>import smtplib
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from alerting import Output, get_png


class EmailOutput(Output):
    def __init__(self, config):
        self.config = config

    def submit(self, result):
        content = [
            "==== %s ====" % result.rule.name(),
            " val_warn: %f" % result.rule.val_warn,
            " val_crit: %f" % result.rule.val_crit,
            "\nResult:\n%s" % "\n".join(result.body),
            "\n\nThis email is sent to %s" % result.rule.dest
        ]
        msg = MIMEMultipart()
        msg["To"] = result.rule.dest
        msg["From"] = self.config.alerting_from
        msg["Subject"] = result.title
        import time

        msgText = MIMEText('%s<br><img src="cid:graph-%s.png">' % ("\n".join(content).replace("\n", "\n<br>"), time.time()), 'html')
        msg.attach(msgText)
        targets = [target for (target, value, status) in result.rule.results]
        img = MIMEImage(get_png(targets, self.config, 400))
        msg.attach(img)

        s = smtplib.SMTP('localhost')
        s.sendmail(self.config.alerting_from, result.rule.dest, msg.as_string())
        s.quit()<commit_msg>alert emails: less is more<commit_after>import smtplib
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from alerting import Output, get_png


class EmailOutput(Output):
    def __init__(self, config):
        self.config = config

    def submit(self, result):
        content = [
            "<b>%s</b>" % result.rule.name(),
            " val_warn: %f" % result.rule.val_warn,
            " val_crit: %f" % result.rule.val_crit,
            "\nResult:\n%s" % "\n".join(result.body)
        ]
        msg = MIMEMultipart()
        msg["To"] = result.rule.dest
        msg["From"] = self.config.alerting_from
        msg["Subject"] = result.title
        import time

        msgText = MIMEText('%s<br><img src="cid:graph-%s.png">' % ("\n".join(content).replace("\n", "\n<br>"), time.time()), 'html')
        msg.attach(msgText)
        targets = [target for (target, value, status) in result.rule.results]
        img = MIMEImage(get_png(targets, self.config, 400))
        msg.attach(img)

        s = smtplib.SMTP('localhost')
        s.sendmail(self.config.alerting_from, result.rule.dest, msg.as_string())
        s.quit()
{'fraction_non_alphanumeric': 0.15343915343915343, 'fraction_numerical': 0.002442002442002442, 'mean_word_length': 2.572674418604651, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4084310', 'n_tokens_mistral': 809, 'n_tokens_neox': 801, 'n_words': 164}