iwla

iwla Commit Details

Date:2014-11-27 14:11:47 (6 years 7 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:ce4bca056d2143a5ee034561d2b9944c0ae71bdd
Parents: f7bf2e11bad5981f72f9680198e88d7abaa99d23
Message:Store files in month directory

Changes:
Mdisplay.py (2 diffs)
Miwla.py (4 diffs)
Mplugins/display/all_visits.py (1 diff)
Mplugins/display/referers.py (2 diffs)
Mplugins/display/top_downloads.py (1 diff)
Mplugins/display/top_hits.py (1 diff)
Mplugins/display/top_pages.py (1 diff)

File differences

display.py
1
12
23
34
......
5657
5758
5859
59
60
61
62
63
64
65
66
6067
6168
6269
import os
class DisplayHTMLBlock(object):
self.blocks.append(block)
def build(self, root):
f = open(root + self.filename, 'w')
filename = root + self.filename
base = os.path.dirname(filename)
if not os.path.exists(base):
os.makedirs(base)
f = open(filename, 'w')
f.write('<html><title>%s</title><body>' % (self.title))
for block in self.blocks:
block.build(f)
iwla.py
7777
7878
7979
80
80
81
82
8183
8284
8385
8486
87
88
89
90
8591
8692
8793
......
9399
94100
95101
96
102
97103
98104
99105
......
214220
215221
216222
217
223
218224
219225
220226
221227
222228
223229
224
230
225231
226232
227233
......
367373
368374
369375
370
376
371377
372378
373379
def isValidForCurrentAnalysis(self, request):
cur_time = self.meta_infos['start_analysis_time']
return (time.mktime(cur_time) <= time.mktime(request['time_decoded']))
# Analyse not started
if not cur_time: return False
return (time.mktime(cur_time) < time.mktime(request['time_decoded']))
def hasBeenViewed(self, request):
return int(request['status']) in conf.viewed_http_codes
def getCurDisplayRoot(self):
cur_time = self.meta_infos['last_time']
return '%d/%d/' % (cur_time.tm_year, cur_time.tm_mon)
def _clearMeta(self):
self.meta_infos = {
'last_time' : None
return self.display
def getDBFilename(self, time):
return (conf.DB_ROOT + '%d/%d_%s') % (time.tm_year, time.tm_mon, conf.DB_FILENAME)
return (conf.DB_ROOT + '%d/%d/%s') % (time.tm_year, time.tm_mon, conf.DB_FILENAME)
def _serialize(self, obj, filename):
base = os.path.dirname(filename)
def getDisplayIndex(self):
cur_time = self.meta_infos['last_time']
filename = '%d/index_%d.html' % (cur_time.tm_year, cur_time.tm_mon)
filename = '%s/index.html' % (self.getCurDisplayRoot())
return self.display.getPage(filename)
def _generateDisplayDaysStat(self):
cur_time = self.meta_infos['last_time']
title = 'Stats %d/%d' % (cur_time.tm_mon, cur_time.tm_year)
filename = '%d/index_%d.html' % (cur_time.tm_year, cur_time.tm_mon)
filename = '%s/index.html' % (self.getCurDisplayRoot())
print '==> Generate display (%s)' % (filename)
page = DisplayHTMLPage(title, filename)
self.analyse_started = True
else:
if not self.analyse_started:
if not self.isValidForCurrentAnalysis(hit):
if time.mktime(t) < time.mktime(cur_time):
return False
else:
self.analyse_started = True
plugins/display/all_visits.py
1515
1616
1717
18
19
18
2019
21
22
20
21
2322
2423
2524
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)
title = time.strftime('All visits - %B %Y', self.iwla.getCurTime())
filename = 'all_visits_%d.html' % (cur_time.tm_mon)
path = '%d/%s' % (cur_time.tm_year, filename)
filename = 'all_visits.html'
path = '%s/%s' % (self.iwla.getCurDisplayRoot(), filename)
page = DisplayHTMLPage(title, path)
table = DisplayHTMLBlockTable('Last seen', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
plugins/display/referers.py
5454
5555
5656
57
58
57
58
5959
6060
6161
......
9393
9494
9595
96
97
96
97
9898
9999
100100
cur_time = self.iwla.getCurTime()
title = time.strftime('Connexion from - %B %Y', cur_time)
filename = 'referers_%d.html' % (cur_time.tm_mon)
path = '%d/%s' % (cur_time.tm_year, filename)
filename = 'referers.html'
path = '%s/%s' % (self.iwla.getCurDisplayRoot(), filename)
page = DisplayHTMLPage(title, path)
table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits'])
# All key phrases in a file
title = time.strftime('Key Phrases - %B %Y', cur_time)
filename = 'key_phrases_%d.html' % (cur_time.tm_mon)
path = '%d/%s' % (cur_time.tm_year, filename)
filename = 'key_phrases.html'
path = '%s/%s' % (self.iwla.getCurDisplayRoot(), filename)
page = DisplayHTMLPage(title, path)
table = DisplayHTMLBlockTable('Top key phrases', ['Key phrase', 'Search'])
plugins/display/top_downloads.py
2222
2323
2424
25
26
25
2726
28
29
27
28
3029
3130
3231
table.appendRow([uri, entrance])
index.appendBlock(table)
cur_time = self.iwla.getCurTime()
title = time.strftime('Top Downloads - %B %Y', cur_time)
title = time.strftime('Top Downloads - %B %Y', self.iwla.getCurTime())
filename = 'top_downloads_%d.html' % (cur_time.tm_mon)
path = '%d/%s' % (cur_time.tm_year, filename)
filename = 'top_downloads.html'
path = '%s/%s' % (self.iwla.getCurDisplayRoot(), filename)
page = DisplayHTMLPage(title, path)
table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit'])
plugins/display/top_hits.py
2222
2323
2424
25
26
25
2726
28
29
27
28
3029
3130
3231
table.appendRow([uri, entrance])
index.appendBlock(table)
cur_time = self.iwla.getCurTime()
title = time.strftime('All Hits - %B %Y', cur_time)
title = time.strftime('All Hits - %B %Y', self.iwla.getCurTime())
filename = 'top_hits_%d.html' % (cur_time.tm_mon)
path = '%d/%s' % (cur_time.tm_year, filename)
filename = 'top_hits.html'
path = '%s/%s' % (self.iwla.getCurDisplayRoot(), filename)
page = DisplayHTMLPage(title, path)
table = DisplayHTMLBlockTable('Top Hits', ['URI', 'Entrance'])
plugins/display/top_pages.py
2222
2323
2424
25
26
25
2726
28
29
27
28
3029
3130
3231
table.appendRow([uri, entrance])
index.appendBlock(table)
cur_time = self.iwla.getCurTime()
title = time.strftime('All Pages - %B %Y', cur_time)
title = time.strftime('All Pages - %B %Y', self.iwla.getCurTime())
filename = 'top_pages_%d.html' % (cur_time.tm_mon)
path = '%d/%s' % (cur_time.tm_year, filename)
filename = 'top_pages.html'
path = '%s/%s' % (self.iwla.getCurDisplayRoot(), filename)
page = DisplayHTMLPage(title, path)
table = DisplayHTMLBlockTable('Top Pages', ['URI', 'Entrance'])

Archive Download the corresponding diff file

Branches

Tags