Multiple python3 bugfixes

This commit is contained in:
2019-03-13 11:58:09 +01:00
parent 49e38e239a
commit 6f26255717
6 changed files with 24 additions and 18 deletions

View File

@@ -14,7 +14,6 @@
import email
import logging
import mailer
import re
from bs4 import BeautifulSoup
@@ -23,6 +22,7 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from pyquarantine import mailer
class BaseNotification(object):
"Notification base class"
@@ -118,7 +118,7 @@ class EMailNotification(BaseNotification):
# read email notification template
try:
self.template = open(self.config["notification_email_template"], "rb").read()
self.template = open(self.config["notification_email_template"], "r").read()
except IOError as e:
raise RuntimeError("error reading template: {}".format(e))
@@ -139,7 +139,7 @@ class EMailNotification(BaseNotification):
if mimetype == EMailNotification._plain_text:
self.logger.debug("{}: content mimetype is {}, converting to {}".format(queueid, mimetype, self._html_text))
text = re.sub(r"^(.*)$", r"\1<br/>\n", text, flags=re.MULTILINE)
text = re.sub(r"^(.*)$", r"\1<br/>\n", text.decode(), flags=re.MULTILINE)
else:
self.logger.debug("{}: content mimetype is {}".format(queueid, mimetype))
@@ -211,7 +211,7 @@ class EMailNotification(BaseNotification):
# extract html text from email
self.logger.debug("{}: extraction email text from original email".format(queueid))
soup = self.get_html_text_part(queueid, email.message_from_file(fp))
soup = self.get_html_text_part(queueid, email.message_from_binary_file(fp))
# replace picture sources
picture_replaced = False