Ejemplo n.º 1
0
    def write_report(self, attr='username'):
        """Send an email to everyone."""
        send = self.smtpprovider(CONFIG.get('email', 'smtp_server'),
                                 CONFIG.get('email', 'smtp_port'))

        send.starttls()
        send.login(self.email, self.passwd)
        allfiles = self.chkr.db.get_files_by_attribute(self.chkr.path, attr)

        env = self._get_env(_EMAIL_TEMPLATE_NAME)

        for user in allfiles:
            prettylist = self._prettify_problems(allfiles[user])

            if prettylist:
                msgcontent = env.get_template(_EMAIL_TEMPLATE_NAME).render(
                    filelist=prettylist)

                msg = MIMEText(msgcontent)
                msg['To'] = _get_user_email_address(user)
                msg['From'] = self.email
                msg['Subject'] = _EMAIL_SUBJECT_LINE
                send.send_message(msg)

        send.quit()
Ejemplo n.º 2
0
    def write_report(self, attr='username'):
        """Send an email to everyone."""
        send = self.smtpprovider(CONFIG.get('email', 'smtp_server'),
                                 CONFIG.get('email', 'smtp_port'))

        send.starttls()
        send.login(self.email, self.passwd)
        allfiles = self.chkr.db.get_files_by_attribute(self.chkr.path, attr)

        env = self._get_env(_EMAIL_TEMPLATE_NAME)

        for user in allfiles:
            prettylist = self._prettify_problems(allfiles[user])

            if prettylist:
                msgcontent = env.get_template(_EMAIL_TEMPLATE_NAME).render(filelist=prettylist)

                msg = MIMEText(msgcontent)
                msg['To'] = _get_user_email_address(user)
                msg['From'] = self.email
                msg['Subject'] = _EMAIL_SUBJECT_LINE
                send.send_message(msg)

        send.quit()
Ejemplo n.º 3
0
 def __init__(self, chkr, smtpprovider=smtplib.SMTP):
     super().__init__(chkr)
     self.email = CONFIG.get('email', 'email') # TODO: Add this to the config
     self.passwd = CONFIG.get('email', 'password')
     self.smtpprovider = smtpprovider # Object that sends emails (can be test dummy)
Ejemplo n.º 4
0
def _get_user_email_address(username):
    """Construct an email address from an MSI username"""
    domain = CONFIG.get('email', 'domain')
    email = '{}@{}'.format(str(username), str(domain))
    return email
Ejemplo n.º 5
0
 def __init__(self, chkr, smtpprovider=smtplib.SMTP):
     super().__init__(chkr)
     self.email = CONFIG.get('email',
                             'email')  # TODO: Add this to the config
     self.passwd = CONFIG.get('email', 'password')
     self.smtpprovider = smtpprovider  # Object that sends emails (can be test dummy)
Ejemplo n.º 6
0
def _get_user_email_address(username):
    """Construct an email address from an MSI username"""
    domain = CONFIG.get('email', 'domain')
    email = '{}@{}'.format(str(username), str(domain))
    return email