iwla

iwla Commit Details

Date:2014-12-03 10:55:32 (6 years 8 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:9c82c61cf8acb63e387a6b2513e1b3554eb765b2
Parents: 95023a5db3d2e90a20dff62fcf9944cb6bce4d67
Message:Add some arguments

Changes:
Miwla.py (4 diffs)

File differences

iwla.py
11
22
33
4
5
46
57
68
79
810
11
912
1013
1114
......
439442
440443
441444
442
445
443446
444447
445448
......
454457
455458
456459
457
458
459
460
461
460462
461
463
462464
463
464
465
466
467
465
466
467
468
469
468470
469471
470472
......
477479
478480
479481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
480498
481
499
500
501
502
503
504
505
506
507
#!/usr/bin/env python
import os
import shutil
import sys
import re
import time
import pickle
import gzip
import importlib
import argparse
from calendar import monthrange
from datetime import date
return True
def start(self):
def start(self, _file):
print '==> Load previous database'
self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta()
print '==> Analysing log'
with open(conf.analyzed_filename) as f:
for l in f:
# print "line " + l
for l in _file:
# print "line " + l
groups = self.log_re.match(l)
groups = self.log_re.match(l)
if groups:
if not self._newHit(groups.groupdict()):
break
else:
print "No match for " + l
if groups:
if not self._newHit(groups.groupdict()):
break
else:
print "No match for " + l
#break
if self.analyse_started:
self._generateMonthStats()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Intelligent Web Log Analyzer')
parser.add_argument('-c', '--clean-output', dest='clean_output', action='store_true',
default=False,
help='Clean output before starting')
parser.add_argument('-i', '--stdin', dest='stdin', action='store_true',
default=False,
help='Read data from stdin instead of conf.analyzed_filename')
args = parser.parse_args()
if args.clean_output:
if os.path.exists(conf.DB_ROOT): shutil.rmtree(conf.DB_ROOT)
if os.path.exists(conf.DISPLAY_ROOT): shutil.rmtree(conf.DISPLAY_ROOT)
iwla = IWLA()
iwla.start()
if args.stdin:
iwla.start(sys.stdin)
else:
if not os.path.exists(conf.analyzed_filename):
print 'No such file \'%s\'' % (conf.analyzed_filename)
sys.exit(-1)
with open(conf.analyzed_filename) as f:
iwla.start(f)

Archive Download the corresponding diff file

Branches

Tags