1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!/usr/bin/python
import distutils.sysconfig
import os
import sys
import glob
from rhpl.translate import _, N_, textdomain, utf8
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":
continue
if basename[-3:] == ".py":
modname = basename[:-3]
elif basename[-4:] in [".pyc", ".pyo"]:
modname = basename[:-4]
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}
continue
mods[modname] = blip
except ImportError, e:
# shouldn't this be fatal?
print e
raise
return mods
|