fix bug #244 by printing an error when some non-unique directory names are

used in the custom_services_dir setting
(Boeing r1841)
This commit is contained in:
ahrenholz 2014-04-30 21:27:41 +00:00
parent 422ecab341
commit 1ab6be9625
2 changed files with 13 additions and 3 deletions

View file

@ -46,6 +46,9 @@ class CoreServices(ConfigurableManager):
'''
_name = "services"
_type = coreapi.CORE_TLV_REG_UTILITY
_invalid_custom_names = ('core', 'addons', 'api', 'bsd', 'emane', 'misc',
'netns', 'phys', 'services', 'xen')
def __init__(self, session):
ConfigurableManager.__init__(self, session)
@ -72,10 +75,11 @@ class CoreServices(ConfigurableManager):
return
try:
parentdir, childdir = os.path.split(path)
if childdir == "services":
if childdir in self._invalid_custom_names:
raise ValueError, "use a unique custom services dir name, " \
"not 'services'"
sys.path.append(parentdir)
"not '%s'" % childdir
if not parentdir in sys.path:
sys.path.append(parentdir)
exec("from %s import *" % childdir)
except Exception, e:
self.session.warn("error importing custom services from " \