Add minimal conf values requirements for main
This commit is contained in:
parent
9c82c61cf8
commit
269b8e54de
19
iplugin.py
19
iplugin.py
|
@ -32,6 +32,14 @@ class IPlugin(object):
|
||||||
def hook(self):
|
def hook(self):
|
||||||
pass
|
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):
|
def preloadPlugins(plugins, iwla):
|
||||||
cache_plugins = {}
|
cache_plugins = {}
|
||||||
|
|
||||||
|
@ -62,15 +70,8 @@ def preloadPlugins(plugins, iwla):
|
||||||
#print 'Load plugin %s' % (plugin_name)
|
#print 'Load plugin %s' % (plugin_name)
|
||||||
|
|
||||||
conf_requirements = plugin.getConfRequirements()
|
conf_requirements = plugin.getConfRequirements()
|
||||||
|
if not validConfRequirements(conf_requirements, iwla, plugin_path):
|
||||||
requirement_validated = True
|
continue
|
||||||
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
|
|
||||||
|
|
||||||
requirements = plugin.getRequirements()
|
requirements = plugin.getRequirements()
|
||||||
|
|
||||||
|
|
4
iwla.py
4
iwla.py
|
@ -497,6 +497,10 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
iwla = IWLA()
|
iwla = IWLA()
|
||||||
|
|
||||||
|
required_conf = ['analyzed_filename', 'domain_name']
|
||||||
|
if not validConfRequirements(required_conf, iwla, 'Main Conf'):
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
if args.stdin:
|
if args.stdin:
|
||||||
iwla.start(sys.stdin)
|
iwla.start(sys.stdin)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user