From 8ba8c99b3c86864153cd5acfad37abb021d2bdfc Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Thu, 20 Nov 2014 09:37:54 +0100 Subject: [PATCH] WIP --- hooks/pre_analysis/H002_robot.py | 6 +++--- iwla.py | 17 ++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/hooks/pre_analysis/H002_robot.py b/hooks/pre_analysis/H002_robot.py index 9ec45cb..2e59ad5 100644 --- a/hooks/pre_analysis/H002_robot.py +++ b/hooks/pre_analysis/H002_robot.py @@ -11,9 +11,9 @@ def hook(hits): referers = 0 # 1) no pages view --> robot - if not super_hit['viewed_pages']: - super_hit['robot'] = 1 - continue + # if not super_hit['viewed_pages']: + # super_hit['robot'] = 1 + # continue # 2) pages without hit --> robot if not super_hit['viewed_hits']: diff --git a/iwla.py b/iwla.py index 9ad49d2..36a8f8f 100755 --- a/iwla.py +++ b/iwla.py @@ -12,7 +12,7 @@ from robots import awstats_robots; print '==> Start' -meta_visit = {'last_time':None} +meta_visit = {} analyse_started = False current_visits = {} cache_plugins = {} @@ -123,7 +123,7 @@ def appendHit(hit): if status >= 300 and status < 400: return if super_hit['robot'] or\ - not int(hit['status']) in viewed_http_codes: + not status in viewed_http_codes: page_key = 'not_viewed_pages' hit_key = 'not_viewed_hits' else: @@ -271,8 +271,7 @@ def newHit(hit): cur_time = meta_visit['last_time'] if cur_time == None: - current_visits = deserialize(getDBFilename(t)) - if not current_visits: current_visits = createEmptyVisits() + current_visits = deserialize(getDBFilename(t)) or createEmptyVisits() analyse_started = True else: if not analyse_started: @@ -280,12 +279,10 @@ def newHit(hit): return else: analyse_started = True - current_visits = deserialize(getDBFilename(t)) - if not current_visits: current_visits = createEmptyVisits() + current_visits = deserialize(getDBFilename(t)) or createEmptyVisits() if cur_time.tm_mon != t.tm_mon: generateMonthStats() - current_visits = deserialize(getDBFilename(t)) - if not current_visits: current_visits = createEmptyVisits() + current_visits = deserialize(getDBFilename(t)) or createEmptyVisits() elif cur_time.tm_mday != t.tm_mday: generateDayStats() @@ -302,9 +299,7 @@ def newHit(hit): print '==> Analysing log' -meta_visit = deserialize(META_PATH) -if not meta_visit: - meta_visit = createEmptyMeta() +meta_visit = deserialize(META_PATH) or createEmptyMeta() current_visits = createEmptyVisits()