iwla

iwla Commit Details

Date:2014-12-03 21:58:55 (6 years 7 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:897f96232c2671a86bb8034031e467963a258408
Parents: 269b8e54de98ad9811be7ad4b2257d022a10f169
Message:Work on index (not finished)

Changes:
Mdisplay.py (1 diff)
Miwla.py (5 diffs)

File differences

display.py
146146
147147
148148
149
149
150150
151
151
152152
153153
154154
class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable):
def __init__(self, title, cols, short_titles=[], nb_valid_rows=0):
def __init__(self, title, cols, short_titles=None, nb_valid_rows=0):
super(DisplayHTMLBlockTableWithGraph, self).__init__(title=title, cols=cols)
self.short_titles = short_titles
self.short_titles = short_titles or []
self.nb_valid_rows = nb_valid_rows
# TOFIX
self.icon_path = 'resources/icon'
iwla.py
237237
238238
239239
240
240
241241
242242
243243
......
245245
246246
247247
248
249
248
249
250250
251251
252252
......
294294
295295
296296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
297347
298
348
299349
350
300351
301352
302353
......
355406
356407
357408
409
410
358411
359412
360413
......
365418
366419
367420
368
369
370421
371
372
422
423
373424
374425
375426
376427
377428
378429
430
431
379432
380433
381434
return self.display.getPage(filename)
def _generateDisplayDaysStat(self):
def _generateDisplayDaysStats(self):
cur_time = self.meta_infos['last_time']
title = 'Stats %d/%d' % (cur_time.tm_mon, cur_time.tm_year)
filename = self.getCurDisplayPath('index.html')
page = DisplayHTMLPage(title, filename, conf.css_path)
_, nb_month_days = monthrange(cur_time.tm_year, cur_time.tm_mon)
days = DisplayHTMLBlockTableWithGraph('By day', ['Day', 'Visits', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth'], nb_valid_rows=nb_month_days)
days.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
days = DisplayHTMLBlockTableWithGraph('By day', ['Day', 'Visitors', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth'], nb_valid_rows=nb_month_days)
days.setColsCSSClass(['', 'iwla_visitor', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
nb_visits = 0
nb_days = 0
for i in range(0, nb_month_days):
page.appendBlock(days)
self.display.addPage(page)
def _generateDisplayMonthStats(self, page, year, month_stats):
title = 'Summary %d' % (year)
cols = ['Month', 'Visitors', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth']
months = DisplayHTMLBlockTableWithGraph(title, cols, nb_valid_rows=12)
months.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
total = [0] * len(cols)
for i in range(0, 12):
month = '%s<br/>%d' % ('Jan', year)
full_month = '%s %d' % ('Jan', year)
if i in month_stats.keys():
stats = month_stats[i]
row = [full_month, stats['nb_visitors'], stats['viewed_pages'], stats['viewed_hits'],
stats['viewed_bandwidth'], stats['not_viewed_bandwidth']]
for i in range(1, len(row[1:])):
total[i] += row[i]
else:
row = [full_month, 0, 0, 0, 0, 0]
months.appendRow(row)
months.setCellValue(i, 4, bytesToStr(row[4]))
months.setCellValue(i, 5, bytesToStr(row[5]))
months.appendShortTitle(month)
# adate = date(cur_time.tm_year, cur_time.tm_mon, i+1)
# week_day = adate.weekday()
# if week_day == 5 or week_day == 6:
# months.setRowCSSClass(i, 'iwla_weekend')
# if adate == date.today():
# css = months.getCellCSSClass(i, 0)
# if css: css = '%s %s' % (css, 'iwla_curday')
# else: css = 'iwla_curday'
# months.setCellCSSClass(i, 0, css)
total[0] = 'Total'
total[4] = bytesToStr(total[4])
total[5] = bytesToStr(total[5])
months.appendRow(total)
page.appendBlock(months)
def _generateDisplayWholeMonthStats(self):
title = 'Stats for %s' % (conf.domain_name)
filename = 'index.html'
print '==> Generate main page (%s)' % (filename)
page = DisplayHTMLPage(title, filename, conf.css_path)
for year in self.meta_infos['stats'].keys():
self._generateDisplayMonthStats(page, year, self.meta_infos['stats'][year])
self.display.addPage(page)
def _generateDisplay(self):
self._generateDisplayDaysStat()
self._generateDisplayDaysStats()
self._callPlugins(conf.DISPLAY_HOOK_DIRECTORY)
self._generateDisplayWholeMonthStats()
self.display.build(conf.DISPLAY_ROOT)
def _generateStats(self, visits):
continue
self.valid_visitors[k] = v
duplicated_stats['visitors'] = stats['visitors'] = len(self.valid_visitors.keys())
self._callPlugins(conf.POST_HOOK_DIRECTORY)
path = self.getDBFilename(cur_time)
self._serialize(self.current_analysis, path)
self._generateDisplay()
# Save month stats
year = '%d' % (cur_time.tm_year)
month = '%d' % (cur_time.tm_mon)
year = cur_time.tm_year
month = cur_time.tm_mon
if not 'stats' in self.meta_infos.keys():
self.meta_infos['stats'] = {}
if not year in self.meta_infos['stats'].keys():
self.meta_infos['stats'][year] = {}
self.meta_infos['stats'][year][month] = duplicated_stats
self._generateDisplay()
def _generateDayStats(self):
visits = self.current_analysis['visits']

Archive Download the corresponding diff file

Branches

Tags