summaryrefslogtreecommitdiffstats
path: root/wallace
diff options
context:
space:
mode:
Diffstat (limited to 'wallace')
-rw-r--r--wallace/__init__.py9
-rw-r--r--wallace/module_footer.py2
-rw-r--r--wallace/module_gpgencrypt.py6
-rw-r--r--wallace/module_invitationpolicy.py10
-rw-r--r--wallace/module_optout.py7
-rw-r--r--wallace/module_resources.py2
-rw-r--r--wallace/module_signature.py2
-rw-r--r--wallace/modules.py7
8 files changed, 28 insertions, 17 deletions
diff --git a/wallace/__init__.py b/wallace/__init__.py
index 4a22e3e..6f11b01 100644
--- a/wallace/__init__.py
+++ b/wallace/__init__.py
@@ -31,7 +31,10 @@ import socket
import struct
import sys
import tempfile
-from threading import _Timer
+try:
+ from threading import _Timer
+except:
+ from threading import Timer as _Timer
import time
import pykolab
@@ -39,8 +42,8 @@ from pykolab import utils
from pykolab.logger import StderrToLogger
from pykolab.translate import _ as _l
-import modules
-from modules import cb_action_ACCEPT
+from . import modules
+from .modules import cb_action_ACCEPT
# pylint: disable=invalid-name
log = pykolab.getLogger('pykolab.wallace')
diff --git a/wallace/module_footer.py b/wallace/module_footer.py
index 2833a59..96e8cf6 100644
--- a/wallace/module_footer.py
+++ b/wallace/module_footer.py
@@ -25,7 +25,7 @@ import time
from email import message_from_file
from email.encoders import encode_quopri
-import modules
+from . import modules
import pykolab
from pykolab.translate import _
diff --git a/wallace/module_gpgencrypt.py b/wallace/module_gpgencrypt.py
index 9083055..a0ddc2e 100644
--- a/wallace/module_gpgencrypt.py
+++ b/wallace/module_gpgencrypt.py
@@ -22,8 +22,8 @@ import tempfile
import time
from email import message_from_string
-from email.MIMEBase import MIMEBase
-from email.MIMEText import MIMEText
+from email.mime.base import MIMEBase
+from email.mime.text import MIMEText
from email.parser import Parser
from email.utils import formataddr
from email.utils import getaddresses
@@ -34,7 +34,7 @@ import email.mime.text
import email.encoders
import gnupg
-import modules
+from . import modules
import pykolab
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py
index 63d8879..da6eec9 100644
--- a/wallace/module_invitationpolicy.py
+++ b/wallace/module_invitationpolicy.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+from six import string_types
import datetime
import os
@@ -23,7 +24,10 @@ import random
import signal
import tempfile
import time
-from urlparse import urlparse
+try:
+ from urlparse import urlparse
+except ImportError:
+ from urllib.parse import urlparse
import urllib
import hashlib
import traceback
@@ -34,7 +38,7 @@ from email.parser import Parser
from email.utils import formataddr
from email.utils import getaddresses
-import modules
+from . import modules
import pykolab
import kolabformat
@@ -709,7 +713,7 @@ def user_dn_from_email_address(email_address):
user_dn = auth.find_user_dn(email_address, True)
- if isinstance(user_dn, basestring):
+ if isinstance(user_dn, string_types):
log.debug(_("User DN: %r") % (user_dn), level=8)
else:
log.debug(_("No user record(s) found for %r") % (email_address), level=8)
diff --git a/wallace/module_optout.py b/wallace/module_optout.py
index c710180..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
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index e29f193..afaf384 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -36,7 +36,7 @@ import uuid
from dateutil.tz import tzlocal
-import modules
+from . import modules
import kolabformat
diff --git a/wallace/module_signature.py b/wallace/module_signature.py
index c483d93..cfebcb5 100644
--- a/wallace/module_signature.py
+++ b/wallace/module_signature.py
@@ -26,7 +26,7 @@ from email.encoders import encode_quopri
from email.parser import Parser
from email.utils import getaddresses
-import modules
+from . import modules
import pykolab
from pykolab.auth import Auth
diff --git a/wallace/modules.py b/wallace/modules.py
index aed60b6..a1eaa7a 100644
--- a/wallace/modules.py
+++ b/wallace/modules.py
@@ -18,6 +18,7 @@
#
from __future__ import print_function
+from six import string_types
import os
import sys
@@ -64,7 +65,7 @@ def initialize():
module_name = filename.replace('.py', '')
name = module_name.replace('module_', '')
# print("exec(\"from %s import __init__ as %s_register\")" % (module_name,name))
- exec("from %s import __init__ as %s_register" % (module_name, name))
+ exec("from .%s import __init__ as %s_register" % (module_name, name))
exec("%s_register()" % (name))
for dirname in dirnames:
@@ -407,7 +408,7 @@ def register_group(dirname, module):
name = module_name.replace('module_', '')
# TODO: Error recovery from incomplete / incorrect modules.
exec(
- "from %s.%s import __init__ as %s_%s_register" % (
+ "from .%s.%s import __init__ as %s_%s_register" % (
module,
module_name,
module,
@@ -423,7 +424,7 @@ def register(name, func, group=None, description=None, aliases=[], heartbeat=Non
else:
module = name
- if isinstance(aliases, basestring):
+ if isinstance(aliases, string_types):
aliases = [aliases]
if module in modules: