iwla

iwla Commit Details

Date:2014-11-26 19:53:00 (6 years 7 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:9571bf09b650f7a7b12ecf731a9d418e77992ea7
Parents: 92533cc244e05caa7a608308ac81f53e540b8378
Message:Work with time

Changes:
Miwla.py (7 diffs)
Mplugins/pre_analysis/page_to_hit.py (2 diffs)

File differences

iwla.py
7272
7373
7474
75
76
77
7578
7679
7780
......
200203
201204
202205
206
203207
204208
205209
......
337341
338342
339343
340
341
342
344
343345
344346
345347
......
360362
361363
362364
365
366
367
363368
364369
365370
......
370375
371376
372377
373
374
375378
376379
377380
......
380383
381384
382385
386
387
388
389
383390
384391
385392
......
398405
399406
400407
408
401409
402410
403411
def getCurTime(self):
return self.meta_infos['last_time']
def getStartAnalysisTime(self):
return self.meta_infos['start_analysis_time']
def _clearMeta(self):
self.meta_infos = {
'last_time' : None
def _decodeTime(self, hit):
hit['time_decoded'] = time.strptime(hit['time_local'], conf.time_format)
return hit['time_decoded']
def getDisplayIndex(self):
cur_time = self.meta_infos['last_time']
self.current_analysis['days_stats'][cur_time.tm_mday] = stats
def _newHit(self, hit):
self._decodeTime(hit)
t = hit['time_decoded']
t = self._decodeTime(hit)
cur_time = self.meta_infos['last_time']
self.meta_infos['last_time'] = t
if not self.meta_infos['start_analysis_time']:
self.meta_infos['start_analysis_time'] = t
if not self._decodeHTTPRequest(hit): return False
for k in hit.keys():
return True
def start(self):
self.cache_plugins = preloadPlugins(self.plugins, self)
print '==> Analyse previous database'
self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta()
else:
self._clearVisits()
self.meta_infos['start_analysis_time'] = None
self.cache_plugins = preloadPlugins(self.plugins, self)
print '==> Analysing log'
with open(conf.analyzed_filename) as f:
if self.analyse_started:
self._generateDayStats()
self._generateMonthStats()
del self.meta_infos['start_analysis_time']
self._serialize(self.meta_infos, conf.META_PATH)
else:
print '==> Analyse not started : nothing to do'
plugins/pre_analysis/page_to_hit.py
11
2
23
34
45
......
2021
2122
2223
23
24
25
2426
27
28
2529
2630
2731
2832
2933
30
31
34
35
3236
3337
3438
import re
import time
from iwla import IWLA
from iplugin import IPlugin
return True
def hook(self, iwla):
hits = iwla.getCurrentVisists()
start_time = self.iwla.getStartAnalysisTime()
start_time = time.mktime(start_time)
hits = iwla.getCurrentVisists()
viewed_http_codes = self.iwla.getConfValue('viewed_http_codes', [200, 304])
for (k, super_hit) in hits.items():
if super_hit['robot']: continue
for p in super_hit['requests']:
if not p['is_page']: continue
if int(p['status']) != 200: continue
if p['time_decoded'].tm_mday != super_hit['last_access'].tm_mday: continue
if int(p['status']) not in viewed_http_codes: continue
if time.mktime(p['time_decoded']) < start_time: continue
uri = p['extract_request']['extract_uri']
for r in self.regexps:
if r.match(uri):

Archive Download the corresponding diff file

Branches

Tags