Remove iwla parameter in hook functions

This commit is contained in:
Grégory Soutadé 2014-11-26 20:31:13 +01:00
parent 9571bf09b6
commit fec5e375e4
9 changed files with 21 additions and 21 deletions

View File

@ -25,7 +25,7 @@ class IPlugin(object):
def load(self):
return True
def hook(self, iwla):
def hook(self):
pass
def preloadPlugins(plugins, iwla):

View File

@ -253,7 +253,7 @@ class IWLA(object):
def _generateDisplay(self):
self._generateDisplayDaysStat()
self._callPlugins(conf.DISPLAY_HOOK_DIRECTORY, self)
self._callPlugins(conf.DISPLAY_HOOK_DIRECTORY)
self.display.build(conf.DISPLAY_ROOT)
def _generateStats(self, visits):
@ -300,7 +300,7 @@ class IWLA(object):
self.current_analysis['month_stats'] = stats
self.valid_visitors = {k: v for (k,v) in visits.items() if not visits[k]['robot']}
self._callPlugins(conf.POST_HOOK_DIRECTORY, self)
self._callPlugins(conf.POST_HOOK_DIRECTORY)
path = self.getDBFilename(cur_time)
if os.path.exists(path):
@ -315,7 +315,7 @@ class IWLA(object):
def _generateDayStats(self):
visits = self.current_analysis['visits']
self._callPlugins(conf.PRE_HOOK_DIRECTORY, self)
self._callPlugins(conf.PRE_HOOK_DIRECTORY)
stats = self._generateStats(visits)

View File

@ -9,8 +9,8 @@ class IWLADisplayAllVisits(IPlugin):
super(IWLADisplayAllVisits, self).__init__(iwla)
self.API_VERSION = 1
def hook(self, iwla):
hits = iwla.getValidVisitors()
def hook(self):
hits = self.iwla.getValidVisitors()
last_access = sorted(hits.values(), key=lambda t: t['last_access'], reverse=True)
cur_time = self.iwla.getCurTime()
@ -40,7 +40,7 @@ class IWLADisplayAllVisits(IPlugin):
display = self.iwla.getDisplay()
display.addPage(page)
index = iwla.getDisplayIndex()
index = self.iwla.getDisplayIndex()
block = DisplayHTMLRawBlock()
block.setRawHTML('<a href=\'%s\'>All visits</a>' % (filename))
index.appendBlock(block)

View File

@ -70,8 +70,8 @@ class IWLADisplayReferers(IPlugin):
key_phrases[key_phrase] += 1
break
def hook(self, iwla):
stats = iwla.getCurrentVisists()
def hook(self):
stats = self.iwla.getCurrentVisists()
referers = {}
robots_referers = {}
search_engine_referers = {}

View File

@ -10,10 +10,10 @@ class IWLADisplayTopVisitors(IPlugin):
self.API_VERSION = 1
self.requires = ['IWLAPostAnalysisTopVisitors']
def hook(self, iwla):
stats = iwla.getMonthStats()
def hook(self):
stats = self.iwla.getMonthStats()
index = iwla.getDisplayIndex()
index = self.iwla.getDisplayIndex()
table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
for super_hit in stats['top_visitors']:
address = super_hit['remote_addr']

View File

@ -13,8 +13,8 @@ class IWLAPostAnalysisReverseDNS(IPlugin):
socket.setdefaulttimeout(timeout)
return True
def hook(self, iwla):
hits = iwla.getValidVisitors()
def hook(self):
hits = self.iwla.getValidVisitors()
for (k, hit) in hits.items():
if hit.get('dns_analysed', False): continue
try:

View File

@ -6,9 +6,9 @@ class IWLAPostAnalysisTopVisitors(IPlugin):
super(IWLAPostAnalysisTopVisitors, self).__init__(iwla)
self.API_VERSION = 1
def hook(self, iwla):
hits = iwla.getValidVisitors()
stats = iwla.getMonthStats()
def hook(self):
hits = self.iwla.getValidVisitors()
stats = self.iwla.getMonthStats()
top_bandwidth = [(k,hits[k]['bandwidth']) for k in hits.keys()]
top_bandwidth = sorted(top_bandwidth, key=lambda t: t[1], reverse=True)
stats['top_visitors'] = [hits[h[0]] for h in top_bandwidth[:10]]

View File

@ -20,11 +20,11 @@ class IWLAPreAnalysisPageToHit(IPlugin):
return True
def hook(self, iwla):
def hook(self):
start_time = self.iwla.getStartAnalysisTime()
start_time = time.mktime(start_time)
hits = iwla.getCurrentVisists()
hits = self.iwla.getCurrentVisists()
viewed_http_codes = self.iwla.getConfValue('viewed_http_codes', [200, 304])
for (k, super_hit) in hits.items():
if super_hit['robot']: continue

View File

@ -16,8 +16,8 @@ class IWLAPreAnalysisRobots(IPlugin):
return True
# Basic rule to detect robots
def hook(self, iwla):
hits = iwla.getCurrentVisists()
def hook(self):
hits = self.iwla.getCurrentVisists()
for k in hits.keys():
super_hit = hits[k]