diff options
author | Adrian Likins <alikins@redhat.com> | 2007-09-25 16:18:19 -0400 |
---|---|---|
committer | Adrian Likins <alikins@redhat.com> | 2007-09-25 16:18:19 -0400 |
commit | 35d0caf698d3668f6411587796b1ab22af17179c (patch) | |
tree | 1e46e0f69a0442e26e97c29a3c52fa3d59c09a11 /minion | |
parent | ef559785042189dd5a9a4b58312836de11841f17 (diff) | |
download | third_party-func-35d0caf698d3668f6411587796b1ab22af17179c.tar.gz third_party-func-35d0caf698d3668f6411587796b1ab22af17179c.tar.xz third_party-func-35d0caf698d3668f6411587796b1ab22af17179c.zip |
Fix up some module loading annoyances
server.py:
we really only need to run load_modules once
module_loader.py:
keep track of modules that failed to load so we
don't keep trying
satisfy rnorwoods curiosity
Diffstat (limited to 'minion')
-rwxr-xr-x | minion/module_loader.py | 12 | ||||
-rwxr-xr-x | minion/server.py | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/minion/module_loader.py b/minion/module_loader.py index 7cfcd26..eef7433 100755 --- a/minion/module_loader.py +++ b/minion/module_loader.py @@ -31,7 +31,8 @@ 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 (since we what?! -RN) + # the normpath is important, since we eventually replace /'s with .'s + # in the module name, and foo..bar doesnt work -akl module_files.append(os.path.normpath("%s/%s" % (root, filename))) @@ -44,6 +45,7 @@ def load_modules(blacklist=None): sys.path.insert(0, mod_path) mods = {} + bad_mods = {} filenames = module_walker(module_file_path) @@ -70,17 +72,23 @@ def load_modules(blacklist=None): # If we've already imported mod_imp_name, don't import it again continue + # ignore modules that we've already determined aren't valid modules + if bad_mods.has_key(mod_imp_name): + continue + try: blip = __import__("modules.%s" % ( mod_imp_name), globals(), locals(), [mod_imp_name]) if not hasattr(blip, "register_rpc"): errmsg = _("%(module_path)s%(modname)s module not a proper module") - print errmsg % {'module_path': module_file_path, 'modname':mod_imp_name} + print errmsg % {'module_path': module_file_path, 'modname':mod_imp_name} + bad_mods[mod_imp_name] = True continue mods[mod_imp_name] = blip except ImportError, e: # A module that raises an ImportError is (for now) simply not loaded. errmsg = _("Could not load %s module: %s") print errmsg % (mod_imp_name, e) + bad_mods[mod_imp_name] = True continue diff --git a/minion/server.py b/minion/server.py index cd3c9e7..823d072 100755 --- a/minion/server.py +++ b/minion/server.py @@ -180,8 +180,6 @@ def main(argv): Start things up. """ - modules = module_loader.load_modules() - print "\n\n\n\n\n" print " WARNING WARNING WARNING" print "DANGER DANGER DANGER" |