Do a more generic plugin : page_to_hit

This commit is contained in:
Grégory Soutadé
2014-11-25 16:22:07 +01:00
parent d5db763b48
commit 7405cf237a
5 changed files with 48 additions and 43 deletions

13
iwla.py
View File

@@ -1,11 +1,8 @@
#!/usr/bin/env python
import sys
import os
import re
import time
import glob
import imp
import pickle
import gzip
import importlib
@@ -126,7 +123,7 @@ class IWLA(object):
remote_addr = hit['remote_addr']
if not remote_addr in self.current_analysis['visits'].keys():
self._createUser(hit)
self._createVisitor(hit)
return
super_hit = self.current_analysis['visits'][remote_addr]
@@ -160,7 +157,7 @@ class IWLA(object):
else:
super_hit[hit_key] += 1
def _createUser(self, hit):
def _createVisitor(self, hit):
super_hit = self.current_analysis['visits'][hit['remote_addr']] = {}
super_hit['remote_addr'] = hit['remote_addr']
super_hit['viewed_pages'] = 0
@@ -347,7 +344,7 @@ class IWLA(object):
else:
if not self.analyse_started:
if time.mktime(cur_time) >= time.mktime(t):
return
return False
else:
self.analyse_started = True
if cur_time.tm_mon != t.tm_mon:
@@ -370,7 +367,7 @@ class IWLA(object):
def start(self):
self.cache_plugins = preloadPlugins(self.plugins, self)
print '==> Analysing log'
print '==> Analyse previous database'
self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta()
if self.meta_infos['last_time']:
@@ -378,6 +375,8 @@ class IWLA(object):
else:
self._clearVisits()
print '==> Analysing log'
with open(conf.analyzed_filename) as f:
for l in f:
# print "line " + l