passing all tests on py3
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
#!/srv/venv/bin/python
|
||||
|
||||
""" Process emails """
|
||||
import sys
|
||||
import os
|
||||
PY3K = sys.version_info >= (3, 0)
|
||||
|
||||
import zipfile
|
||||
import re
|
||||
import time
|
||||
from time import strftime
|
||||
|
||||
import io
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django_mailbox.models import Message, MessageAttachment,Mailbox
|
||||
from django.core.urlresolvers import reverse
|
||||
@@ -62,7 +66,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
|
||||
# test if file exists and is not empty
|
||||
try:
|
||||
with open('media/'+filename,'r') as fop:
|
||||
with io.open('media/'+filename,'rb') as fop:
|
||||
line = fop.readline()
|
||||
except (IOError, UnicodeEncodeError):
|
||||
if testing:
|
||||
@@ -164,6 +168,11 @@ def get_from_address(message):
|
||||
except IndexError:
|
||||
first_line = ''
|
||||
|
||||
try:
|
||||
first_line = first_line.decode('utf-8')
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
if "quiske" in first_line:
|
||||
match = re.search(r'[\w\.-]+@[\w\.-]+', first_line)
|
||||
return match.group(0)
|
||||
|
||||
Reference in New Issue
Block a user