iwla

iwla Commit Details

Date:2014-12-17 20:31:59 (6 years 7 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:ccab40b4e17e54e9f0d33786949184470417d599
Parents: c278ff30f0d83278844b96b087aa61d973042278
Message:Replace g.gettext by iwla._ Add createCurTitle() to factorize code

Changes:
Mconf.py (1 diff)
Mdisplay.py (1 diff)
Miwla.py (7 diffs)
Mplugins/display/all_visits.py (3 diffs)
Mplugins/display/referers.py (7 diffs)
Mplugins/display/top_downloads.py (3 diffs)
Mplugins/display/top_hits.py (3 diffs)
Mplugins/display/top_pages.py (3 diffs)
Mplugins/display/top_visitors.py (3 diffs)

File differences

conf.py
2727
2828
2929
30
31
30
3231
compress_output_files = ['html', 'css', 'js']
# locale = 'fr'
locale = 'fr_FR'
locale = 'fr'
# locale = 'fr_FR.utf8'
display.py
348348
349349
350350
351
352
353
354
355
if not name: name = unicode(url)
if not url.startswith(prefix): url = u'%s://%s' % (prefix, url)
return u'<a href="%s">%s</a>' % (url, name[:max_length])
def createCurTitle(iwla, title):
title = iwla._(title) + time.strftime(u' - %B %Y', iwla.getCurTime())
return title
iwla.py
1010
1111
1212
13
13
1414
1515
1616
......
131131
132132
133133
134
135
136
137
138
139
140
141
142
143
144
145
146
134
135
136
137
138
139
140
147141
148142
149143
......
353347
354348
355349
356
350
357351
358352
359353
360354
361355
362
356
363357
364358
365359
......
396390
397391
398392
399
393
400394
401395
402396
403397
404
398
405399
406400
407401
......
410404
411405
412406
413
414
415
407
408
409
416410
417411
418412
......
422416
423417
424418
425
419
426420
427421
428422
......
439433
440434
441435
442
436
443437
444438
445439
446440
447441
448442
449
443
450444
451445
452446
453447
454448
455449
456
450
457451
458452
459453
import importlib
import argparse
import logging
import gettext as g
import gettext
from calendar import monthrange
from datetime import date
logging.basicConfig(format='%(name)s %(message)s', level=logLevel)
self.logger = logging.getLogger(self.__class__.__name__)
self.logger.info('==> Start')
# print conf.locales_path
# print conf.locale
#print g.find('iwla', localedir=conf.locales_path, all=False)
# print g.find('iwla', localedir=conf.locales_path, languages=[conf.locale], all=True)
#g.install('iwla', localedir=conf.locales_path)
t = g.translation('iwla', localedir=conf.locales_path, languages=[conf.locale])
self._ = t.gettext
#t.install()
# g.install('iwla', localedir=conf.locales_path, names=conf.locale)
print(self._('Statistics'))
# print(_('Statistics'))
try:
t = gettext.translation('iwla', localedir=conf.locales_path, languages=[conf.locale], codeset='utf8')
self.logger.info('\tUsing locale %s' % (conf.locale))
except IOError:
t = gettext.NullTranslations()
self.logger.info('\tUsing default locale en_EN')
self._ = t.ugettext
def getVersion(self):
return IWLA.IWLA_VERSION
def _generateDisplayDaysStats(self):
cur_time = self.meta_infos['last_time']
title = '%s %d/%02d' % (g.gettext('Statistics'), cur_time.tm_year, cur_time.tm_mon)
title = '%s %d/%02d' % (self._('Statistics'), cur_time.tm_year, cur_time.tm_mon)
filename = self.getCurDisplayPath('index.html')
self.logger.info('==> Generate display (%s)' % (filename))
page = self.display.createPage(title, filename, conf.css_path)
_, nb_month_days = monthrange(cur_time.tm_year, cur_time.tm_mon)
days = self.display.createBlock(DisplayHTMLBlockTableWithGraph, g.gettext('By day'), [g.gettext('Day'), g.gettext('Visits'), g.gettext('Pages'), g.gettext('Hits'), g.gettext('Bandwidth'), g.gettext('Not viewed Bandwidth')], None, nb_month_days, range(1,6))
days = self.display.createBlock(DisplayHTMLBlockTableWithGraph, self._('By day'), [self._('Day'), self._('Visits'), self._('Pages'), self._('Hits'), self._('Bandwidth'), self._('Not viewed Bandwidth')], None, nb_month_days, range(1,6))
days.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
nb_visits = 0
nb_days = 0
else:
average_row = map(lambda(v): 0, row)
average_row[0] = g.gettext('Average')
average_row[0] = self._('Average')
average_row[4] = bytesToStr(average_row[4])
average_row[5] = bytesToStr(average_row[5])
days.appendRow(average_row)
row[0] = g.gettext('Total')
row[0] = self._('Total')
row[4] = bytesToStr(row[4])
row[5] = bytesToStr(row[5])
days.appendRow(row)
def _generateDisplayMonthStats(self, page, year, month_stats):
cur_time = time.localtime()
months_name = ['', g.gettext('Jan'), g.gettext('Feb'), g.gettext('Mar'), g.gettext('Apr'), g.gettext('May'), g.gettext('June'), g.gettext('July'), g.gettext('Aug'), g.gettext('Sep'), g.gettext('Oct'), g.gettext('Nov'), g.gettext('Dec')]
title = '%s %d' % (g.gettext('Summary'), year)
cols = [g.gettext('Month'), g.gettext('Visitors'), g.gettext('Visits'), g.gettext('Pages'), g.gettext('Hits'), g.gettext('Bandwidth'), g.gettext('Not viewed Bandwidth'), g.gettext('Details')]
months_name = ['', self._('Jan'), self._('Feb'), self._('Mar'), self._('Apr'), self._('May'), self._('June'), self._('July'), self._('Aug'), self._('Sep'), self._('Oct'), self._('Nov'), self._('Dec')]
title = '%s %d' % (self._('Summary'), year)
cols = [self._('Month'), self._('Visitors'), self._('Visits'), self._('Pages'), self._('Hits'), self._('Bandwidth'), self._('Not viewed Bandwidth'), self._('Details')]
graph_cols=range(1,7)
months = self.display.createBlock(DisplayHTMLBlockTableWithGraph, title, cols, None, 12, graph_cols)
months.setColsCSSClass(['', 'iwla_visitor', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth', ''])
full_month = '%s %d' % (months_name[i], year)
if i in month_stats.keys():
stats = month_stats[i]
link = '<a href="%d/%02d/index.html">%s</a>' % (year, i, g.gettext('Details'))
link = '<a href="%d/%02d/index.html">%s</a>' % (year, i, self._('Details'))
row = [full_month, stats['nb_visitors'], stats['nb_visits'], stats['viewed_pages'], stats['viewed_hits'],
stats['viewed_bandwidth'], stats['not_viewed_bandwidth'], link]
for j in graph_cols:
else: css = 'iwla_curday'
months.setCellCSSClass(i-1, 0, css)
total[0] = g.gettext('Total')
total[0] = self._('Total')
total[5] = bytesToStr(total[5])
total[6] = bytesToStr(total[6])
months.appendRow(total)
page.appendBlock(months)
def _generateDisplayWholeMonthStats(self):
title = '%s %s' % (g.gettext('Statistics for'), conf.domain_name)
title = '%s %s' % (self._('Statistics for'), conf.domain_name)
filename = 'index.html'
self.logger.info('==> Generate main page (%s)' % (filename))
page = self.display.createPage(title, filename, conf.css_path)
last_update = '<b>%s</b> %s<br />' % (g.gettext('Last update'), time.strftime('%02d %b %Y %H:%M', time.localtime()))
last_update = '<b>%s</b> %s<br />' % (self._('Last update'), time.strftime('%02d %b %Y %H:%M', time.localtime()))
page.appendBlock(self.display.createBlock(DisplayHTMLRaw, last_update))
for year in sorted(self.meta_infos['stats'].keys(), reverse=True):
plugins/display/all_visits.py
11
2
32
43
54
......
4241
4342
4443
45
44
4645
4746
4847
4948
5049
51
50
5251
5352
5453
......
7069
7170
7271
73
74
72
73
7574
7675
7776
import time
import gettext as g
from iwla import IWLA
from iplugin import IPlugin
last_access = sorted(hits.values(), key=lambda t: t['last_access'], reverse=True)
title = time.strftime(g.gettext('All visits') + ' - %B %Y', self.iwla.getCurTime())
title = time.strftime(self.iwla._(u'All visits') + u' - %B %Y', self.iwla.getCurTime())
filename = 'all_visits.html'
path = self.iwla.getCurDisplayPath(filename)
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('Last seen'), [g.gettext('Host'), g.gettext('Pages'), g.gettext('Hits'), g.gettext('Bandwidth'), g.gettext('Last seen')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Last seen'), [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', ''])
for super_hit in last_access:
display.addPage(page)
index = self.iwla.getDisplayIndex()
link = '<a href=\'%s\'>%s</a>' % (g.gettext('All visits'), filename)
block = index.getBlock(g.gettext('Top visitors'))
link = '<a href=\'%s\'>%s</a>' % (filename, self.iwla._(u'All visits'))
block = index.getBlock(self.iwla._(u'Top visitors'))
if block:
block.setTitle('%s - %s' % (block.getTitle(), link))
else:
plugins/display/referers.py
1
2
3
41
52
63
......
6966
7067
7168
72
69
7370
7471
7572
7673
7774
78
75
7976
8077
8178
82
79
8380
8481
8582
......
8885
8986
9087
91
88
9289
9390
9491
......
9794
9895
9996
100
97
10198
10299
103100
......
109106
110107
111108
112
109
113110
114
111
115112
116113
117114
118
115
119116
120117
121
118
122119
123120
124121
125122
126123
127124
128
125
129126
130127
131128
132
129
133130
134131
135132
136133
137134
138135
139
136
140137
141138
142139
143
140
144141
145142
146143
147144
148145
149146
150
147
151148
152149
153150
......
155152
156153
157154
158
155
159156
160157
161158
162159
163160
164161
165
162
166163
167164
168165
......
172169
173170
174171
175
172
176173
177
174
178175
179176
180177
181
178
182179
183180
184181
185182
186183
187
184
188185
189186
190187
import time
import gettext as g
from iwla import IWLA
from iplugin import IPlugin
from display import *
# All referers in a file
if self.create_all_referers:
title = time.strftime(g.gettext('Connexion from') + ' - %B %Y', cur_time)
title = createCurTitle(self.iwla, u'Connexion from')
filename = 'referers.html'
path = self.iwla.getCurDisplayPath(filename)
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('Connexion from'), [g.gettext('Origin'), g.gettext('Pages'), g.gettext('Hits')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Connexion from'), [self.iwla._(u'Origin'), self.iwla._(u'Pages'), self.iwla._(u'Hits')])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit'])
total_search = [0]*3
table.appendRow(['<b>%s</b>' % (g.gettext('Search Engine')), '', ''])
table.appendRow(['<b>%s</b>' % (self.iwla._(u'Search Engine')), '', ''])
new_list = self.max_referers and top_search_engine_referers[:self.max_referers] or top_search_engine_referers
for r,_ in new_list:
row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']]
table.appendRow(row)
total_external = [0]*3
table.appendRow(['<b>%s</b>' % (g.gettext('External URL')), '', ''])
table.appendRow(['<b>%s</b>' % (self.iwla._(u'External URL')), '', ''])
new_list = self.max_referers and top_referers[:self.max_referers] or top_referers
for r,_ in new_list:
row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']]
table.appendRow(row)
total_robot = [0]*3
table.appendRow(['<b>%s</b>' % (g.gettext('External URL (robot)')), '', ''])
table.appendRow(['<b>%s</b>' % (self.iwla._(u'External URL (robot)')), '', ''])
new_list = self.max_referers and top_robots_referers[:self.max_referers] or top_robots_referers
for r,_ in new_list:
row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']]
display.addPage(page)
title = g.gettext('Top Referers')
title = self.iwla._(u'Top Referers')
if self.create_all_referers:
link = '<a href=\'%s\'>%s</a>' % (filename, g.gettext('All Referers'))
link = '<a href=\'%s\'>%s</a>' % (filename, self.iwla._(u'All Referers'))
title = '%s - %s' % (title, link)
# Top referers in index
table = display.createBlock(DisplayHTMLBlockTable, title, [g.gettext('Origin'), g.gettext('Pages'), g.gettext('Hits')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Origin'), self.iwla._(u'Pages'), self.iwla._(u'Hits')])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit'])
table.appendRow(['<b>%s</b>' % (g.gettext('Search Engine')), '', ''])
table.appendRow(['<b>%s</b>' % (self.iwla._(u'Search Engine')), '', ''])
for r,_ in top_search_engine_referers[:10]:
row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']]
total_search[1] -= search_engine_referers[r]['pages']
total_search[2] -= search_engine_referers[r]['hits']
table.appendRow(row)
if total_search[1] or total_search[2]:
total_search[0] = g.gettext('Others')
total_search[0] = self.iwla._(u'Others')
table.appendRow(total_search)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
table.appendRow(['<b>%s</b>' % (g.gettext('External URL')), '', ''])
table.appendRow(['<b>%s</b>' % (self.iwla._(u'External URL')), '', ''])
for r,_ in top_referers[:10]:
row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']]
total_external[1] -= referers[r]['pages']
total_external[2] -= referers[r]['hits']
table.appendRow(row)
if total_external[1] or total_external[2]:
total_external[0] = g.gettext('Others')
total_external[0] = self.iwla._(u'Others')
table.appendRow(total_external)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
table.appendRow(['<b>%s</b>' % (g.gettext('External URL (robot)')), '', ''])
table.appendRow(['<b>%s</b>' % (self.iwla._(u'External URL (robot)')), '', ''])
for r,_ in top_robots_referers[:10]:
row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']]
total_robot[1] -= robots_referers[r]['pages']
total_robot[2] -= robots_referers[r]['hits']
table.appendRow(row)
if total_robot[1] or total_robot[2]:
total_robot[0] = g.gettext('Others')
total_robot[0] = self.iwla._(u'Others')
table.appendRow(total_robot)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
# All key phrases in a file
if self.create_all_key_phrases:
title = time.strftime(g.gettext('Key Phrases') + ' - %B %Y', cur_time)
title = createCurTitle(self.iwla, u'Key Phrases')
filename = 'key_phrases.html'
path = self.iwla.getCurDisplayPath(filename)
total_search = [0]*2
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('Top key phrases'), [g.gettext('Key phrase'), g.gettext('Search')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Top key phrases'), [self.iwla._(u'Key phrase'), self.iwla._(u'Search')])
table.setColsCSSClass(['', 'iwla_search'])
new_list = self.max_key_phrases and top_key_phrases[:self.max_key_phrases] or top_key_phrases
for phrase in new_list:
display.addPage(page)
title = g.gettext('Top key phrases')
title = self.iwla._(u'Top key phrases')
if self.create_all_key_phrases:
link = '<a href=\'%s\'>%s</a>' % (filename, g.gettext('All key phrases'))
link = '<a href=\'%s\'>%s</a>' % (filename, self.iwla._(u'All key phrases'))
title = '%s - %s' % (title, link)
# Top key phrases in index
table = display.createBlock(DisplayHTMLBlockTable, title, [g.gettext('Key phrase'), g.gettext('Search')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Key phrase'), self.iwla._(u'Search')])
table.setColsCSSClass(['', 'iwla_search'])
for phrase in top_key_phrases[:10]:
table.appendRow([phrase[0], phrase[1]])
total_search[1] -= phrase[1]
if total_search[1]:
total_search[0] = g.gettext('Others')
total_search[0] = self.iwla._(u'Others')
table.appendRow(total_search)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
plugins/display/top_downloads.py
1
2
3
41
52
63
......
4845
4946
5047
51
48
5249
5350
54
51
5552
5653
5754
......
6360
6461
6562
66
63
6764
68
65
6966
7067
7168
7269
7370
74
71
7572
7673
7774
7875
7976
80
77
8178
8279
8380
import time
import gettext as g
from iwla import IWLA
from iplugin import IPlugin
from display import *
if self.create_all_downloads:
filename = 'top_downloads.html'
path = self.iwla.getCurDisplayPath(filename)
title = time.strftime(g.gettext('All Downloads') + ' - %B %Y', self.iwla.getCurTime())
title = createCurTitle(self.iwla, u'All Downloads')
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('All Downloads'), [g.gettext('URI'), g.gettext('Hit')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All Downloads'), [self.iwla._(u'URI'), self.iwla._(u'Hit')])
table.setColsCSSClass(['', 'iwla_hit'])
total_entrance = [0]*2
display.addPage(page)
title = g.gettext('Top Downloads')
title = self.iwla._(u'Top Downloads')
if self.create_all_downloads:
link = '<a href=\'%s\'>%s</a>' % (filename, g.gettext('All Downloads'))
link = '<a href=\'%s\'>%s</a>' % (filename, self.iwla._(u'All Downloads'))
title = '%s - %s' % (title, link)
# Top in index
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, title, [g.gettext('URI'), g.gettext('Hits')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'URI'), self.iwla._(u'Hits')])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_downloads[:10]:
table.appendRow([generateHTMLLink(uri), entrance])
total_entrance[1] -= entrance
if total_entrance[1]:
total_entrance[0] = g.gettext('Others')
total_entrance[0] = self.iwla._(u'Others')
table.appendRow(total_entrance)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
plugins/display/top_hits.py
1
2
3
41
52
63
......
4643
4744
4845
49
46
5047
5148
5249
5350
54
51
5552
5653
5754
......
6461
6562
6663
67
64
6865
6966
7067
7168
7269
73
70
7471
7572
7673
7774
7875
79
76
8077
8178
8279
import time
import gettext as g
from iwla import IWLA
from iplugin import IPlugin
from display import *
# All in a file
if self.create_all_hits:
title = time.strftime(g.gettext('All Hits') + ' - %B %Y', self.iwla.getCurTime())
title = createCurTitle(self.iwla, u'All Hits')
filename = 'top_hits.html'
path = self.iwla.getCurDisplayPath(filename)
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('All Hits'), [g.gettext('URI'), g.gettext('Entrance')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All Hits'), [self.iwla._(u'URI'), self.iwla._(u'Entrance')])
table.setColsCSSClass(['', 'iwla_hit'])
total_hits = [0]*2
new_list = self.max_hits and top_hits[:self.max_hits] or top_hits
title = 'Top Hits'
if self.create_all_hits:
link = '<a href=\'%s\'>%s</a>' % (filename, g.gettext('All Hits'))
link = '<a href=\'%s\'>%s</a>' % (filename, self.iwla._(u'All Hits'))
title = '%s - %s' % (title, link)
# Top in index
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, title, [g.gettext('URI'), g.gettext('Entrance')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'URI'), self.iwla._(u'Entrance')])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_hits[:10]:
table.appendRow([generateHTMLLink(uri), entrance])
total_hits[1] -= entrance
if total_hits[1]:
total_hits[0] = g.gettext('Others')
total_hits[0] = self.iwla._(u'Others')
table.appendRow(total_hits)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
plugins/display/top_pages.py
1
2
3
41
52
63
......
4643
4744
4845
49
46
5047
5148
5249
5350
54
51
5552
5653
5754
......
6259
6360
6461
65
62
6663
67
64
6865
6966
7067
7168
7269
73
70
7471
7572
7673
7774
7875
79
76
8077
8178
8279
import time
import gettext as g
from iwla import IWLA
from iplugin import IPlugin
from display import *
# All in a page
if self.create_all_pages:
title = time.strftime(g.gettext('All Pages') + ' - %B %Y', self.iwla.getCurTime())
title = createCurTitle(self.iwla, u'All Pages')
filename = 'top_pages.html'
path = self.iwla.getCurDisplayPath(filename)
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('All Pages'), [g.gettext('URI'), g.gettext('Entrance')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All Pages'), [self.iwla._(u'URI'), self.iwla._(u'Entrance')])
table.setColsCSSClass(['', 'iwla_hit'])
total_hits = [0]*2
new_list = self.max_pages and top_pages[:self.max_pages] or top_pages
display.addPage(page)
title = g.gettext('Top Pages')
title = self.iwla._(u'Top Pages')
if self.create_all_pages:
link = '<a href=\'%s\'>%s</a>' % (filename, g.gettext('All Pages'))
link = '<a href=\'%s\'>%s</a>' % (filename, self.iwla._(u'All Pages'))
title = '%s - %s' % (title, link)
# Top in index
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, title, [g.gettext('URI'), g.gettext('Entrance')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'URI'), self.iwla._(u'Entrance')])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_pages[:10]:
table.appendRow([generateHTMLLink(uri), entrance])
total_hits[1] -= entrance
if total_hits[1]:
total_hits[0] = g.gettext('Others')
total_hits[0] = self.iwla._(u'Others')
table.appendRow(total_hits)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
plugins/display/top_visitors.py
11
2
32
43
54
......
5049
5150
5251
53
52
5453
5554
5655
......
7069
7170
7271
73
72
7473
7574
7675
import time
import gettext as g
from iwla import IWLA
from iplugin import IPlugin
top_visitors = [hits[h[0]] for h in top_bandwidth[:10]]
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, g.gettext('Top visitors'), [g.gettext('Host'), g.gettext('Pages'), g.gettext('Hits'), g.gettext('Bandwidth'), g.gettext('Last seen')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Top visitors'), [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', ''])
for super_hit in top_visitors:
address = super_hit['remote_addr']
total[3] -= super_hit['bandwidth']
table.appendRow(row)
if total[1] or total[2] or total[3]:
total[0] = g.gettext('Others')
total[0] = self.iwla._(u'Others')
total[3] = bytesToStr(total[3])
total[4] = ''
table.appendRow(total)

Archive Download the corresponding diff file

Branches

Tags