From 8d04809a4db0b6c4d57eb8f6455239409255b5ea Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Thu, 20 Sep 2007 17:21:51 -0400 Subject: attempts at letting us run from a installed, or local modules there are smarter ways to do this I'm sure --- server/module_loader.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'server/module_loader.py') diff --git a/server/module_loader.py b/server/module_loader.py index 10631fe..3f73500 100755 --- a/server/module_loader.py +++ b/server/module_loader.py @@ -7,19 +7,33 @@ import sys import glob from rhpl.translate import _, N_, textdomain, utf8 -module_file_path="modules/" -mod_path="server/" -sys.path.insert(0, mod_path) -def load_modules(module_path=module_file_path, blacklist=None): - filenames = glob.glob("%s/*.py" % module_file_path) - filenames = filenames + glob.glob("%s/*.pyc" % module_file_path) - filesnames = filenames + glob.glob("%s/*.pyo" % module_file_path) +def load_modules(module_path=None, + blacklist=None): + + print "\n\n\n\n\n why the heck is this getting called twice? \n\n\n" + + module_file_path="%s/func/server/modules/" % distutils.sysconfig.get_python_lib() + mod_path="%s/func/server/" % distutils.sysconfig.get_python_lib() + + if module_path is not None: + module_file_path="%s/modules" % module_path + mod_path = module_path + + sys.path.insert(0, mod_path) mods = {} print sys.path + print mod_path + print module_file_path + filenames = glob.glob("%s/*.py" % module_file_path) + filenames = filenames + glob.glob("%s/*.pyc" % module_file_path) + filesnames = filenames + glob.glob("%s/*.pyo" % module_file_path) + + + print "filenames", filenames for fn in filenames: basename = os.path.basename(fn) if basename == "__init__.py": @@ -31,6 +45,10 @@ def load_modules(module_path=module_file_path, blacklist=None): try: + path = "server.module.%s" % modname + if module_path is None: + path = "module.%s" % modname + blip = __import__("modules.%s" % ( modname), globals(), locals(), [modname]) if not hasattr(blip, "register_rpc"): errmsg = _("%(module_path)s/%(modname)s module not a proper module") @@ -46,8 +64,4 @@ def load_modules(module_path=module_file_path, blacklist=None): - -if __name__ == "__main__": - print load_modules(module_path) - -- cgit