Merge branch 'master' of soutade.fr:iwla

This commit is contained in:
Gregory Soutade 2014-12-14 15:47:19 +01:00
commit 2ef7cdf01b
3 changed files with 15 additions and 14 deletions

7
TODO
View File

@ -1,14 +1,9 @@
reverse analysis
-f option to read a file instead of the one in conf
Other when pages truncated Other when pages truncated
translations translations
doc auto generation doc auto generation
doc enhancement doc enhancement
Limit hits/pages/downloads by rate Limit hits/pages/downloads by rate
Automatic tests Automatic tests
Test separate directory for DB and display
quiet mode quiet mode
Add 0 before month when < 10
Add Licence Add Licence
Free memory as soon as possible Free memory as soon as possible
Bug in bandwidth account (x10)

View File

@ -312,6 +312,8 @@ class DisplayHTMLBuild(object):
def build(self, root): def build(self, root):
display_root = self.iwla.getConfValue('DISPLAY_ROOT', '') display_root = self.iwla.getConfValue('DISPLAY_ROOT', '')
if not os.path.exists(display_root):
os.makedirs(display_root)
for res_path in self.iwla.getResourcesPath(): for res_path in self.iwla.getResourcesPath():
target = os.path.abspath(res_path) target = os.path.abspath(res_path)
link_name = os.path.join(display_root, res_path) link_name = os.path.join(display_root, res_path)

20
iwla.py
View File

@ -551,10 +551,9 @@ class IWLA(object):
self.current_analysis = self._deserialize(self.getDBFilename(t)) or self._clearVisits() self.current_analysis = self._deserialize(self.getDBFilename(t)) or self._clearVisits()
self.analyse_started = True self.analyse_started = True
else: else:
if time.mktime(t) < time.mktime(cur_time): if time.mktime(t) <= time.mktime(cur_time):
return False return False
if not self.analyse_started: self.analyse_started = True
self.analyse_started = True
if cur_time.tm_mon != t.tm_mon: if cur_time.tm_mon != t.tm_mon:
self._generateMonthStats() self._generateMonthStats()
self.current_analysis = self._deserialize(self.getDBFilename(t)) or self._clearVisits() self.current_analysis = self._deserialize(self.getDBFilename(t)) or self._clearVisits()
@ -581,6 +580,8 @@ class IWLA(object):
self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta() self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta()
if self.meta_infos['last_time']: if self.meta_infos['last_time']:
print 'Last time'
print self.meta_infos['last_time']
self.current_analysis = self._deserialize(self.getDBFilename(self.meta_infos['last_time'])) or self._clearVisits() self.current_analysis = self._deserialize(self.getDBFilename(self.meta_infos['last_time'])) or self._clearVisits()
else: else:
self._clearVisits() self._clearVisits()
@ -609,8 +610,7 @@ class IWLA(object):
del self.meta_infos['start_analysis_time'] del self.meta_infos['start_analysis_time']
self._serialize(self.meta_infos, conf.META_PATH) self._serialize(self.meta_infos, conf.META_PATH)
else: else:
print '==> Analyse not started : nothing to do' print '==> Analyse not started : nothing new'
self._generateMonthStats()
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Intelligent Web Log Analyzer') parser = argparse.ArgumentParser(description='Intelligent Web Log Analyzer')
@ -623,6 +623,9 @@ if __name__ == '__main__':
default=False, default=False,
help='Read data from stdin instead of conf.analyzed_filename') help='Read data from stdin instead of conf.analyzed_filename')
parser.add_argument('-f', '--file', dest='file',
help='Analyse this log file')
args = parser.parse_args() args = parser.parse_args()
if args.clean_output: if args.clean_output:
@ -638,8 +641,9 @@ if __name__ == '__main__':
if args.stdin: if args.stdin:
iwla.start(sys.stdin) iwla.start(sys.stdin)
else: else:
if not os.path.exists(conf.analyzed_filename): filename = args.file or conf.analyzed_filename
print 'No such file \'%s\'' % (conf.analyzed_filename) if not os.path.exists(filename):
print 'No such file \'%s\'' % (filename)
sys.exit(-1) sys.exit(-1)
with open(conf.analyzed_filename) as f: with open(filename) as f:
iwla.start(f) iwla.start(f)