Remove iwla parameter in hook functions
This commit is contained in:
		| @@ -25,7 +25,7 @@ class IPlugin(object): | ||||
|     def load(self): | ||||
|         return True | ||||
|  | ||||
|     def hook(self, iwla): | ||||
|     def hook(self): | ||||
|         pass | ||||
|  | ||||
| def preloadPlugins(plugins, iwla): | ||||
|   | ||||
							
								
								
									
										6
									
								
								iwla.py
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								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) | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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 = {} | ||||
|   | ||||
| @@ -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'] | ||||
|   | ||||
| @@ -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: | ||||
|   | ||||
| @@ -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]] | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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] | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user