summaryrefslogtreecommitdiffstats
path: root/wallace/modules.py
diff options
context:
space:
mode:
Diffstat (limited to 'wallace/modules.py')
-rw-r--r--wallace/modules.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/wallace/modules.py b/wallace/modules.py
index 3f27bbd..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:
@@ -78,7 +79,7 @@ def list_modules(*args, **kw):
__modules = {}
- for module in modules.keys():
+ for module in modules:
if isinstance(module, tuple):
module_group, module = module
__modules[module_group] = {
@@ -133,10 +134,10 @@ def execute(name, *args, **kw):
log.exception(_("Module %r - Unknown error occurred; %r") % (name, errmsg))
def heartbeat(name, *args, **kw):
- if not modules.has_key(name):
+ if name not in modules:
log.warning(_("No such module %r in modules %r (1).") % (name, modules))
- if modules[name].has_key('heartbeat'):
+ if 'heartbeat' in modules[name]:
return modules[name]['heartbeat'](*args, **kw)
def _sendmail(sender, recipients, msg):
@@ -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,10 +424,10 @@ 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 modules.has_key(module):
+ if module in modules:
log.fatal(_("Module '%s' already registered") % (module))
sys.exit(1)