diff options
| author | Seth Vidal <skvidal@fedoraproject.org> | 2007-09-25 10:41:40 -0400 |
|---|---|---|
| committer | Seth Vidal <skvidal@fedoraproject.org> | 2007-09-25 10:41:40 -0400 |
| commit | 4ce41f6eb4bdef401dd767d48ea98a0883090972 (patch) | |
| tree | f116135c24af74d335a16a28babe94215e961321 /server/module_loader.py | |
| parent | 04d9598cef8cd5501acba95040ee46d73c52dbef (diff) | |
| parent | 6bf3d8bee599802c95832cbdae904ffce1053938 (diff) | |
| download | third_party-func-4ce41f6eb4bdef401dd767d48ea98a0883090972.tar.gz third_party-func-4ce41f6eb4bdef401dd767d48ea98a0883090972.tar.xz third_party-func-4ce41f6eb4bdef401dd767d48ea98a0883090972.zip | |
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
* 'master' of ssh://git.fedoraproject.org/git/hosted/func:
Renamed server to minion and client to overlord
Diffstat (limited to 'server/module_loader.py')
| -rwxr-xr-x | server/module_loader.py | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/server/module_loader.py b/server/module_loader.py deleted file mode 100755 index 137625c..0000000 --- a/server/module_loader.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/python - -## func -## -## Copyright 2007, Red Hat, Inc -## See AUTHORS -## -## This software may be freely redistributed under the terms of the GNU -## general public license. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -## -## - - -import distutils.sysconfig -import os -import sys -import glob -from rhpl.translate import _, N_, textdomain, utf8 - - -def module_walker(topdir): - module_files = [] - for root, dirs, files in os.walk(topdir): - # we should get here for each subdir - for filename in files: - # ASSUMPTION: all module files will end with .py, .pyc, .pyo - if filename[-3:] == ".py" or filename[-4:] == ".pyc" or filename[-4:] == ".pyo": - # 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) - module_files.append(os.path.normpath("%s/%s" % (root, filename))) - - - return module_files - -def load_modules(blacklist=None): - - module_file_path="%s/func/server/modules/" % distutils.sysconfig.get_python_lib() - mod_path="%s/func/server/" % distutils.sysconfig.get_python_lib() - - sys.path.insert(0, mod_path) - mods = {} - - filenames = module_walker(module_file_path) - - # FIXME: this is probably more complicated than it needs to be -akl - for fn in filenames: - # 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": - modname = basename[:-3] - elif basename[-4:] in [".pyc", ".pyo"]: - modname = basename[:-4] - - 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"): - errmsg = _("%(module_path)s%(modname)s module not a proper module") - print errmsg % {'module_path': module_file_path, 'modname':mod_imp_name} - 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) - - continue - - return mods - - -if __name__ == "__main__": - - module_file_path = "/usr/lib/python2.5/site-packages/func/server/modules/" - bar = module_walker(module_file_path) - print bar - for f in bar: - print f - print os.path.basename(f) - print os.path.split(f) - g = f[len(module_file_path):] - print g - print os.path.split(g) - - print load_modules() |
