summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorKrzysztof A. Adamski <krzysztofa@gmail.com>2008-08-02 10:08:13 -0400
committerKrzysztof A. Adamski <krzysztofa@gmail.com>2008-08-07 18:29:22 -0400
commiteedd977b41aa469d42808920e8630b9da629518e (patch)
tree31a428b061f31ecbda186460ee7df373ebf163dc /func
parentd5f6797eadc02012e699d8850d6967d922f92b1f (diff)
downloadfunc-eedd977b41aa469d42808920e8630b9da629518e.tar.gz
func-eedd977b41aa469d42808920e8630b9da629518e.tar.xz
func-eedd977b41aa469d42808920e8630b9da629518e.zip
Change module_loader so it can be used in places other than func/minion/server.py
Diffstat (limited to 'func')
-rwxr-xr-xfunc/minion/module_loader.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/func/minion/module_loader.py b/func/minion/module_loader.py
index 3068ea8..f418f80 100755
--- a/func/minion/module_loader.py
+++ b/func/minion/module_loader.py
@@ -39,10 +39,12 @@ def module_walker(topdir):
return module_files
-def load_modules(blacklist=None):
+def load_modules(path='func/minion/modules/', main_class=func_module.FuncModule, blacklist=None):
- module_file_path="%s/func/minion/modules/" % distutils.sysconfig.get_python_lib()
- mod_path="%s/func/minion/" % distutils.sysconfig.get_python_lib()
+ python_path = distutils.sysconfig.get_python_lib()
+ module_file_path = "%s/%s" % (python_path, path)
+ (mod_path, mod_dir) = os.path.split(os.path.normpath(module_file_path))
+ mod_dir = "func."+module_file_path[len(python_path+'/func/'):].replace("/",".")
sys.path.insert(0, mod_path)
mods = {}
@@ -80,10 +82,10 @@ def load_modules(blacklist=None):
try:
# Auto-detect and load all FuncModules
- blip = __import__("modules.%s" % ( mod_imp_name), globals(), locals(), [mod_imp_name])
+ blip = __import__("%s%s" % ( mod_dir,mod_imp_name), globals(), locals(), [mod_imp_name])
for obj in dir(blip):
attr = getattr(blip, obj)
- if isclass(attr) and issubclass(attr, func_module.FuncModule):
+ if isclass(attr) and issubclass(attr, main_class):
logger.debug("Loading %s module" % attr)
mods[mod_imp_name] = attr()