iwla

iwla Commit Details

Date:2014-11-26 20:31:13 (6 years 8 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:fec5e375e44310887e644dffcf440d9a22b98deb
Parents: 9571bf09b650f7a7b12ecf731a9d418e77992ea7
Message:Remove iwla parameter in hook functions

Changes:
Miplugin.py (1 diff)
Miwla.py (3 diffs)
Mplugins/display/all_visits.py (2 diffs)
Mplugins/display/referers.py (1 diff)
Mplugins/display/top_visitors.py (1 diff)
Mplugins/post_analysis/reverse_dns.py (1 diff)
Mplugins/post_analysis/top_visitors.py (1 diff)
Mplugins/pre_analysis/page_to_hit.py (1 diff)
Mplugins/pre_analysis/robots.py (1 diff)

File differences

iplugin.py
2525
2626
2727
28
28
2929
3030
3131
def load(self):
return True
def hook(self, iwla):
def hook(self):
pass
def preloadPlugins(plugins, iwla):
iwla.py
253253
254254
255255
256
256
257257
258258
259259
......
300300
301301
302302
303
303
304304
305305
306306
......
315315
316316
317317
318
318
319319
320320
321321
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):
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):
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)
plugins/display/all_visits.py
99
1010
1111
12
13
12
13
1414
1515
1616
......
4040
4141
4242
43
43
4444
4545
4646
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()
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)
plugins/display/referers.py
7070
7171
7272
73
74
73
74
7575
7676
7777
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 = {}
plugins/display/top_visitors.py
1010
1111
1212
13
14
13
14
1515
16
16
1717
1818
1919
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']
plugins/post_analysis/reverse_dns.py
1313
1414
1515
16
17
16
17
1818
1919
2020
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:
plugins/post_analysis/top_visitors.py
66
77
88
9
10
11
9
10
11
1212
1313
1414
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]]
plugins/pre_analysis/page_to_hit.py
2020
2121
2222
23
23
2424
2525
2626
27
27
2828
2929
3030
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
plugins/pre_analysis/robots.py
1616
1717
1818
19
20
19
20
2121
2222
2323
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]

Archive Download the corresponding diff file

Branches

Tags