summaryrefslogtreecommitdiffstats
path: root/wallace/module_optout.py
diff options
context:
space:
mode:
Diffstat (limited to 'wallace/module_optout.py')
-rw-r--r--wallace/module_optout.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/wallace/module_optout.py b/wallace/module_optout.py
index 632753f..9220ebe 100644
--- a/wallace/module_optout.py
+++ b/wallace/module_optout.py
@@ -22,14 +22,17 @@ import os
import random
import tempfile
import time
-from urlparse import urlparse
+try:
+ from urlparse import urlparse
+except ImportError:
+ from urllib.parse import urlparse
import urllib
from email import message_from_file
from email.utils import formataddr
from email.utils import getaddresses
-import modules
+from . import modules
import pykolab
@@ -57,7 +60,7 @@ def execute(*args, **kw):
# TODO: Test for correct call.
filepath = args[0]
- if kw.has_key('stage'):
+ if 'stage' in kw:
log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8)
log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8)
if hasattr(modules, 'cb_action_%s' % (kw['stage'])):
@@ -90,7 +93,7 @@ def execute(*args, **kw):
"Cc": []
}
- for recipient_type in recipients.keys():
+ for recipient_type in recipients:
for recipient in recipients[recipient_type]:
log.debug(
_("Running opt-out consult from envelope sender '%s " + \
@@ -136,7 +139,7 @@ def execute(*args, **kw):
use_this = False
- for recipient_type in _recipients[answer].keys():
+ for recipient_type in _recipients[answer]:
_message.__delitem__(recipient_type)
if not len(_recipients[answer][recipient_type]) == 0:
_message.__setitem__(
@@ -177,7 +180,7 @@ def request(params=None):
try:
f = urllib.urlopen(optout_url, params)
- except Exception, e:
+ except Exception:
log.error(_("Could not send request to optout_url %s") % (optout_url))
return "DEFER"
@@ -185,8 +188,8 @@ def request(params=None):
try:
response_data = json.loads(response)
- except ValueError, e:
+ except ValueError:
# Some data is not JSON
- print "Response data is not JSON"
+ print("Response data is not JSON")
return response_data['result']