summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Norwood <rnorwood@redhat.com>2007-09-24 20:29:19 -0400
committerRobin Norwood <rnorwood@redhat.com>2007-09-24 20:29:19 -0400
commit7d543b6cf1d721c2e9f7ed88a230172870a9f558 (patch)
tree40a82a07f029cc08bb305a9887a933c22a2cc4de
parent3a78963db6e4747be51935bdd1928e220945b49b (diff)
downloadfunc-7d543b6cf1d721c2e9f7ed88a230172870a9f558.tar.gz
func-7d543b6cf1d721c2e9f7ed88a230172870a9f558.tar.xz
func-7d543b6cf1d721c2e9f7ed88a230172870a9f558.zip
Change module loader to only try to load each module once.
Also, fix module import failure error message.
-rwxr-xr-xserver/module_loader.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/server/module_loader.py b/server/module_loader.py
index a2a00c5..137625c 100755
--- a/server/module_loader.py
+++ b/server/module_loader.py
@@ -32,7 +32,7 @@ def module_walker(topdir):
# we don't really care about __init__ files, though we do requure them
if filename[:8] == "__init__":
continue
- # the normpath is important, since we
+ # the normpath is important, since we (since we what?! -RN)
module_files.append(os.path.normpath("%s/%s" % (root, filename)))
@@ -53,7 +53,7 @@ def load_modules(blacklist=None):
# aka, everything after the module_file_path
module_name_part = fn[len(module_file_path):]
dirname, basename = os.path.split(module_name_part)
-
+
if basename == "__init__.py":
continue
if basename[-3:] == ".py":
@@ -64,9 +64,13 @@ def load_modules(blacklist=None):
pathname = modname
if dirname != "":
pathname = "%s/%s" % (dirname, modname)
-
+
mod_imp_name = pathname.replace("/", ".")
+ if mods.has_key(mod_imp_name):
+ # If we've already imported mod_imp_name, don't import it again
+ continue
+
try:
blip = __import__("modules.%s" % ( mod_imp_name), globals(), locals(), [mod_imp_name])
if not hasattr(blip, "register_rpc"):
@@ -76,7 +80,10 @@ def load_modules(blacklist=None):
mods[mod_imp_name] = blip
except ImportError, e:
# A module that raises an ImportError is (for now) simply not loaded.
- print e
+ errmsg = _("Could not load %s module: %s")
+ print errmsg % (mod_imp_name, e)
+
+ continue
return mods