From 04905ba6d973a57c9d37bb75ee376c896a47ac5d Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sat, 30 Apr 2022 10:34:53 -0700 Subject: Migrate to python3 --- emailcanary/canary.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'emailcanary/canary.py') diff --git a/emailcanary/canary.py b/emailcanary/canary.py index aac6418..cfac01b 100644 --- a/emailcanary/canary.py +++ b/emailcanary/canary.py @@ -1,6 +1,7 @@ import uuid, datetime, time -import email.message, emailutils +import email.message import re +from . import emailutils class Canary: def __init__(self, db, smtp, fromaddress): @@ -30,13 +31,13 @@ class Canary: these_subjects = [] for uid in emailutils.get_mail_uids(mail): message = emailutils.get_message(mail, uid) - if self.processMessage(address, message): + if message is not None and self.processMessage(address, message): emailutils.delete_message(mail, uid) emailutils.close(mail) return self.db.get_missing_pongs(listAddress) def processMessage(self, receipient, msg): - match = re.match('.*Canary Email (.+)', msg['Subject']) + match = re.match('.*Canary Email (.+)', str(msg['Subject'])) if match: chirpUUID = match.group(1) now = datetime.datetime.now() -- cgit v1.2.3