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

5
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
translations
doc auto generation
doc enhancement
Limit hits/pages/downloads by rate
Automatic tests
Test separate directory for DB and display
quiet mode
Add 0 before month when < 10
Add Licence
Free memory as soon as possible
Bug in bandwidth account (x10)

View File

@ -312,6 +312,8 @@ class DisplayHTMLBuild(object):
def build(self, 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():
target = os.path.abspath(res_path)
link_name = os.path.join(display_root, res_path)

18
iwla.py
View File

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