Add bytesToStr()

Automatically convert list into strings in appendRow()
Add package information
This commit is contained in:
Gregory Soutade
2014-11-24 13:44:04 +01:00
parent 38c041126d
commit 670f024905
8 changed files with 48 additions and 14 deletions

View File

@@ -0,0 +1 @@
#

View File

@@ -18,15 +18,20 @@ def load():
def hook(iwla):
stats = iwla.getMonthStats()
if not 'top_visitors' in stats.keys():
top_visitors = stats.get('top_visitors', None)
if not top_visitors:
print 'Top visitors post analysis plugin not installed'
return
index = iwla.getDisplayIndex()
table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
for super_hit in stats['top_visitors']:
row = [super_hit['remote_addr'], super_hit['viewed_pages'], super_hit['viewed_hits'], super_hit['bandwidth'], 0]
row = map(lambda(v): str(v), row)
row[4] = time.asctime(super_hit['last_access'])
for super_hit in top_visitors:
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)
index.appendBlock(table)