From fec5e375e44310887e644dffcf440d9a22b98deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 26 Nov 2014 20:31:13 +0100 Subject: [PATCH] Remove iwla parameter in hook functions --- iplugin.py | 2 +- iwla.py | 6 +++--- plugins/display/all_visits.py | 6 +++--- plugins/display/referers.py | 4 ++-- plugins/display/top_visitors.py | 6 +++--- plugins/post_analysis/reverse_dns.py | 4 ++-- plugins/post_analysis/top_visitors.py | 6 +++--- plugins/pre_analysis/page_to_hit.py | 4 ++-- plugins/pre_analysis/robots.py | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/iplugin.py b/iplugin.py index d13e62a..b1801af 100644 --- a/iplugin.py +++ b/iplugin.py @@ -25,7 +25,7 @@ class IPlugin(object): def load(self): return True - def hook(self, iwla): + def hook(self): pass def preloadPlugins(plugins, iwla): diff --git a/iwla.py b/iwla.py index 9201baa..a11016b 100755 --- a/iwla.py +++ b/iwla.py @@ -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) diff --git a/plugins/display/all_visits.py b/plugins/display/all_visits.py index 131c754..a0d7152 100644 --- a/plugins/display/all_visits.py +++ b/plugins/display/all_visits.py @@ -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('All visits' % (filename)) index.appendBlock(block) diff --git a/plugins/display/referers.py b/plugins/display/referers.py index 8c5d23d..a8bd891 100644 --- a/plugins/display/referers.py +++ b/plugins/display/referers.py @@ -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 = {} diff --git a/plugins/display/top_visitors.py b/plugins/display/top_visitors.py index 1959545..0da035b 100644 --- a/plugins/display/top_visitors.py +++ b/plugins/display/top_visitors.py @@ -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'] diff --git a/plugins/post_analysis/reverse_dns.py b/plugins/post_analysis/reverse_dns.py index 8898115..e638a45 100644 --- a/plugins/post_analysis/reverse_dns.py +++ b/plugins/post_analysis/reverse_dns.py @@ -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: diff --git a/plugins/post_analysis/top_visitors.py b/plugins/post_analysis/top_visitors.py index 714ca66..d20d5ca 100644 --- a/plugins/post_analysis/top_visitors.py +++ b/plugins/post_analysis/top_visitors.py @@ -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]] diff --git a/plugins/pre_analysis/page_to_hit.py b/plugins/pre_analysis/page_to_hit.py index d704b36..7ad8454 100644 --- a/plugins/pre_analysis/page_to_hit.py +++ b/plugins/pre_analysis/page_to_hit.py @@ -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 diff --git a/plugins/pre_analysis/robots.py b/plugins/pre_analysis/robots.py index 78ba2ff..2d120c5 100644 --- a/plugins/pre_analysis/robots.py +++ b/plugins/pre_analysis/robots.py @@ -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]