Rework conf in plugins
This commit is contained in:
parent
549c0e5d97
commit
d5db763b48
16
iplugin.py
16
iplugin.py
|
@ -2,16 +2,10 @@ import importlib
|
|||
import inspect
|
||||
import traceback
|
||||
|
||||
import default_conf as conf
|
||||
import conf as _
|
||||
conf.__dict__.update(_.__dict__)
|
||||
del _
|
||||
|
||||
class IPlugin(object):
|
||||
|
||||
def __init__(self, iwla, conf):
|
||||
def __init__(self, iwla):
|
||||
self.iwla = iwla
|
||||
self.conf = conf
|
||||
self.requires = []
|
||||
self.API_VERSION = 1
|
||||
self.ANALYSIS_CLASS = 'HTTP'
|
||||
|
@ -24,12 +18,6 @@ class IPlugin(object):
|
|||
return False
|
||||
|
||||
return True
|
||||
|
||||
def getConfValue(self, key, default):
|
||||
if not key in dir(self.conf):
|
||||
return default
|
||||
else:
|
||||
return self.conf.__dict__[key]
|
||||
|
||||
def getRequirements(self):
|
||||
return self.requires
|
||||
|
@ -58,7 +46,7 @@ def preloadPlugins(plugins, iwla):
|
|||
print 'No plugin defined in %s' % (plugin_path)
|
||||
continue
|
||||
|
||||
plugin = classes[0](iwla, conf)
|
||||
plugin = classes[0](iwla)
|
||||
plugin_name = plugin.__class__.__name__
|
||||
|
||||
if not plugin.isValid(iwla.ANALYSIS_CLASS, iwla.API_VERSION):
|
||||
|
|
6
iwla.py
6
iwla.py
|
@ -42,6 +42,12 @@ class IWLA(object):
|
|||
conf.POST_HOOK_DIRECTORY : conf.post_analysis_hooks,
|
||||
conf.DISPLAY_HOOK_DIRECTORY : conf.display_hooks}
|
||||
|
||||
def getConfValue(self, key, default):
|
||||
if not key in dir(conf):
|
||||
return default
|
||||
else:
|
||||
return conf.__dict__[key]
|
||||
|
||||
def _clearVisits(self):
|
||||
self.current_analysis = {
|
||||
'days_stats' : {},
|
||||
|
|
|
@ -5,8 +5,8 @@ from iplugin import IPlugin
|
|||
from display import *
|
||||
|
||||
class IWLADisplayTopVisitors(IPlugin):
|
||||
def __init__(self, iwla, conf):
|
||||
super(IWLADisplayTopVisitors, self).__init__(iwla, conf)
|
||||
def __init__(self, iwla):
|
||||
super(IWLADisplayTopVisitors, self).__init__(iwla)
|
||||
self.API_VERSION = 1
|
||||
self.requires = ['IWLAPostAnalysisTopVisitors']
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@ from iwla import IWLA
|
|||
from iplugin import IPlugin
|
||||
|
||||
class IWLAPostAnalysisReverseDNS(IPlugin):
|
||||
def __init__(self, iwla, conf):
|
||||
super(IWLAPostAnalysisReverseDNS, self).__init__(iwla, conf)
|
||||
def __init__(self, iwla):
|
||||
super(IWLAPostAnalysisReverseDNS, self).__init__(iwla)
|
||||
self.API_VERSION = 1
|
||||
|
||||
def load(self):
|
||||
timeout = self.getConfValue('reverse_dns_timeout', 0.5)
|
||||
timeout = self.iwla.getConfValue('reverse_dns_timeout', 0.5)
|
||||
socket.setdefaulttimeout(timeout)
|
||||
return True
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ from iwla import IWLA
|
|||
from iplugin import IPlugin
|
||||
|
||||
class IWLAPostAnalysisTopVisitors(IPlugin):
|
||||
def __init__(self, iwla, conf):
|
||||
super(IWLAPostAnalysisTopVisitors, self).__init__(iwla, conf)
|
||||
def __init__(self, iwla):
|
||||
super(IWLAPostAnalysisTopVisitors, self).__init__(iwla)
|
||||
self.API_VERSION = 1
|
||||
|
||||
def hook(self, iwla):
|
||||
|
|
|
@ -6,8 +6,8 @@ from iplugin import IPlugin
|
|||
from awstats_robots_data import awstats_robots
|
||||
|
||||
class IWLAPreAnalysisRobots(IPlugin):
|
||||
def __init__(self, iwla, conf):
|
||||
super(IWLAPreAnalysisRobots, self).__init__(iwla, conf)
|
||||
def __init__(self, iwla):
|
||||
super(IWLAPreAnalysisRobots, self).__init__(iwla)
|
||||
self.API_VERSION = 1
|
||||
|
||||
def load(self):
|
||||
|
|
|
@ -7,8 +7,8 @@ from iplugin import IPlugin
|
|||
|
||||
class IWLAPreAnalysisSoutade(IPlugin):
|
||||
|
||||
def __init__(self, iwla, conf):
|
||||
super(IWLAPreAnalysisSoutade, self).__init__(iwla, conf)
|
||||
def __init__(self, iwla):
|
||||
super(IWLAPreAnalysisSoutade, self).__init__(iwla)
|
||||
self.API_VERSION = 1
|
||||
|
||||
def load(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user