From 7d7c0f4dc299dc342c53341f61ae4643eb134213 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 20 Sep 2007 16:44:02 -0400 Subject: Remove yaml libraries (configparser is good enough) plus remove references to virt-factory. --- server/module_loader.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'server/module_loader.py') diff --git a/server/module_loader.py b/server/module_loader.py index 10631fe..eaf0725 100755 --- a/server/module_loader.py +++ b/server/module_loader.py @@ -1,5 +1,19 @@ #!/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 -- cgit 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 From 50250e45f0c225198e08097a525cc5ff1b91474d Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Thu, 20 Sep 2007 17:40:59 -0400 Subject: debug spew cleanup to protect the unwashed masses from foo poisoning --- server/module_loader.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'server/module_loader.py') diff --git a/server/module_loader.py b/server/module_loader.py index eed91b4..a54c2e9 100755 --- a/server/module_loader.py +++ b/server/module_loader.py @@ -26,7 +26,6 @@ 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() @@ -38,16 +37,16 @@ def load_modules(module_path=None, sys.path.insert(0, mod_path) mods = {} - print sys.path - print mod_path - print module_file_path +# 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 +# print "filenames", filenames for fn in filenames: basename = os.path.basename(fn) if basename == "__init__.py": -- cgit From a847a423257a863c18f20b003820f74dcd5259af Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Thu, 20 Sep 2007 17:57:52 -0400 Subject: remove all the --debug "try to run from the src tree" crap 3rd party modules wont be here anyway, so remove all that weird noise --- server/module_loader.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'server/module_loader.py') diff --git a/server/module_loader.py b/server/module_loader.py index a54c2e9..a18da35 100755 --- a/server/module_loader.py +++ b/server/module_loader.py @@ -22,31 +22,18 @@ import glob from rhpl.translate import _, N_, textdomain, utf8 -def load_modules(module_path=None, - blacklist=None): +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() - 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": @@ -58,14 +45,10 @@ def load_modules(module_path=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") - print errmsg % {'module_path': module_path, 'modname':modname} + print errmsg % {'module_path': module_file_path, 'modname':modname} continue mods[modname] = blip except ImportError, e: -- cgit From fcf925c36f22d2eee1de1f7815915cf5ba17fbb3 Mon Sep 17 00:00:00 2001 From: James Bowes Date: Thu, 20 Sep 2007 18:45:13 -0400 Subject: Get rid of extra / in module loading error --- server/module_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/module_loader.py') diff --git a/server/module_loader.py b/server/module_loader.py index a18da35..f189623 100755 --- a/server/module_loader.py +++ b/server/module_loader.py @@ -47,7 +47,7 @@ def load_modules(blacklist=None): try: 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") + errmsg = _("%(module_path)s%(modname)s module not a proper module") print errmsg % {'module_path': module_file_path, 'modname':modname} continue mods[modname] = blip -- cgit