Add minimal conf values requirements for main

This commit is contained in:
Grégory Soutadé 2014-12-03 11:29:05 +01:00
parent 9c82c61cf8
commit 269b8e54de
2 changed files with 14 additions and 9 deletions

View File

@ -32,6 +32,14 @@ class IPlugin(object):
def hook(self):
pass
def validConfRequirements(conf_requirements, iwla, plugin_path):
for r in conf_requirements:
if iwla.getConfValue(r, None) is None:
print '\'%s\' conf value required for %s' % (r, plugin_path)
return False
return True
def preloadPlugins(plugins, iwla):
cache_plugins = {}
@ -62,15 +70,8 @@ def preloadPlugins(plugins, iwla):
#print 'Load plugin %s' % (plugin_name)
conf_requirements = plugin.getConfRequirements()
requirement_validated = True
for r in conf_requirements:
conf_value = iwla.getConfValue(r, None)
if conf_value is None:
print '\'%s\' conf value required for %s' % (r, plugin_path)
requirement_validated = False
break
if not requirement_validated: continue
if not validConfRequirements(conf_requirements, iwla, plugin_path):
continue
requirements = plugin.getRequirements()

View File

@ -497,6 +497,10 @@ if __name__ == '__main__':
iwla = IWLA()
required_conf = ['analyzed_filename', 'domain_name']
if not validConfRequirements(required_conf, iwla, 'Main Conf'):
sys.exit(0)
if args.stdin:
iwla.start(sys.stdin)
else: