iwla

iwla Commit Details

Date:2014-11-25 16:59:29 (6 years 8 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:6505ca3ee5d90fcad377ca89c1abc435cbc08095
Parents: 7405cf237acfbc4fa6d4a7d5a5e3f1d6ae05b368
Message:Add all_visits plugin

Changes:
Aplugins/display/all_visits.py (full)
Mconf.py (1 diff)
Mdisplay.py (1 diff)
Miwla.py (1 diff)

File differences

conf.py
1313
1414
1515
16
16
1717
1818
1919
pre_analysis_hooks = ['page_to_hit', 'robots']
post_analysis_hooks = ['top_visitors', 'reverse_dns']
display_hooks = ['top_visitors']
display_hooks = ['top_visitors', 'all_visits']
reverse_dns_timeout = 0.2
page_to_hit_conf = [r'^.+/logo/$']
display.py
11
22
33
4
4
55
66
77
88
99
10
11
12
13
14
15
16
17
18
19
20
21
1022
1123
1224
class DisplayHTMLBlock(object):
def __init__(self, title):
def __init__(self, title=''):
self.title = title
def build(self, f):
pass
class DisplayHTMLRawBlock(DisplayHTMLBlock):
def __init__(self, title=''):
super(DisplayHTMLRawBlock, self).__init__(title)
self.html = ''
def setRawHTML(self, html):
self.html = html
def build(self, f):
f.write(self.html)
class DisplayHTMLBlockTable(DisplayHTMLBlock):
def __init__(self, title, cols):
iwla.py
6969
7070
7171
72
73
74
7275
7376
7477
def getDisplay(self):
return self.display
def getCurTime(self):
return self.meta_infos['last_time']
def _clearMeta(self):
self.meta_infos = {
'last_time' : None
plugins/display/all_visits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import time
from iwla import IWLA
from iplugin import IPlugin
from display import *
class IWLADisplayAllVisits(IPlugin):
def __init__(self, iwla):
super(IWLADisplayAllVisits, self).__init__(iwla)
self.API_VERSION = 1
def hook(self, iwla):
hits = iwla.getValidVisitors()
last_access = sorted(hits.values(), key=lambda t: t['last_access'], reverse=True)
cur_time = self.iwla.getCurTime()
title = time.strftime('All visits %B %Y', cur_time)
filename = 'all_visits_%d.html' % (cur_time.tm_mon)
path = '%d/%s' % (cur_time.tm_year, filename)
page = DisplayHTMLPage(title, path)
table = DisplayHTMLBlockTable('Last seen', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
for super_hit in last_access:
row = [
super_hit['remote_addr'],
super_hit['viewed_pages'],
super_hit['viewed_hits'],
bytesToStr(super_hit['bandwidth']),
time.asctime(super_hit['last_access'])
]
table.appendRow(row)
page.appendBlock(table)
display = self.iwla.getDisplay()
display.addPage(page)
index = iwla.getDisplayIndex()
block = DisplayHTMLRawBlock()
block.setRawHTML('<a href=\'%s\'>All visits</a>' % (filename))
index.appendBlock(block)

Archive Download the corresponding diff file

Branches

Tags