iwla

iwla Commit Details

Date:2014-11-20 08:18:31 (6 years 8 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:8c7f135741324ab7e1b0da15b1c3a50755a2a044
Parents: b8027fe509f673f13df40268b9bf50815f0afab2
Message:WIP

Changes:
Miwla.py (6 diffs)

File differences

iwla.py
5959
6060
6161
62
63
64
6265
6366
6467
......
9598
9699
97100
98
101
102
103
104
105
106
107
99108
100109
101
110
111
102112
103113
104114
......
132142
133143
134144
145
135146
136147
137148
......
240251
241252
242253
254
255
256
257
258
243259
244260
245261
......
280296
281297
282298
283
284
285
286
287
299
288300
289301
290302
......
310322
311323
312324
325
313326
314327
315328
if not os.path.exists(base):
os.makedirs(base)
# TODO : remove return
return
with open(filename + '.tmp', 'wb+') as f:
pickle.dump(obj, f)
f.seek(0)
return False
def appendHit(hit):
super_hit = current_visits['visits'][hit['remote_addr']]
remote_addr = hit['remote_addr']
if not remote_addr in current_visits['visits'].keys():
createUser(hit)
return
super_hit = current_visits['visits'][remote_addr]
super_hit['pages'].append(hit)
super_hit['bandwith'] += int(hit['body_bytes_sent'])
super_hit['last_access'] = meta_visit['last_time']
request = hit['extract_request']
if 'extract_uri' in request.keys():
super_hit['not_viewed_pages'] = 0;
super_hit['not_viewed_hits'] = 0;
super_hit['bandwith'] = 0;
super_hit['last_access'] = meta_visit['last_time']
super_hit['pages'] = [];
super_hit['robot'] = isRobot(hit);
appendHit(hit)
if last_day:
for k in stats.keys():
stats[k] -= current_visits['days_stats'][last_day][k]
stats['nb_visitors'] = 0
for k in visits.keys():
if visits[k]['robot']: continue
if visits[k]['last_access'].tm_mday == cur_time.tm_mday:
stats['nb_visitors'] += 1
print stats
current_visits['days_stats'][cur_time.tm_mday] = stats
for k in hit.keys():
if hit[k] == '-': hit[k] = ''
remote_addr = hit['remote_addr']
if remote_addr in current_visits['visits'].keys():
appendHit(hit)
else:
createUser(hit)
appendHit(hit)
return True
f.close();
if analyse_started:
generateDayStats()
generateMonthStats()
serialize(meta_visit, META_PATH)
else:

Archive Download the corresponding diff file

Branches

Tags