Use a clear conf file

This commit is contained in:
Grégory Soutadé 2014-12-19 18:06:02 +01:00
parent a14600ccda
commit 046c1d8983
3 changed files with 14 additions and 11 deletions

13
conf.py
View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Web server log # Web server log
analyzed_filename = 'access.log' analyzed_filename = '/var/log/apache2/access.log'
# Domain name to analyze # Domain name to analyze
domain_name = 'soutade.fr' domain_name = 'soutade.fr'
@ -10,22 +11,24 @@ display_visitor_ip = True
# Hooks used # Hooks used
pre_analysis_hooks = ['page_to_hit', 'robots'] pre_analysis_hooks = ['page_to_hit', 'robots']
post_analysis_hooks = ['referers', 'top_pages', 'top_downloads', 'top_hits'] #, 'reverse_dns'] post_analysis_hooks = ['referers', 'top_pages', 'top_downloads', 'top_hits', 'reverse_dns']
display_hooks = ['top_visitors', 'all_visits', 'referers', 'top_pages', 'top_downloads', 'top_hits'] display_hooks = ['top_visitors', 'all_visits', 'referers', 'top_pages', 'top_downloads', 'top_hits']
# Reverse DNS timeout # Reverse DNS timeout
reverse_dns_timeout = 0.2 reverse_dns_timeout = 0.2
# Count this addresses as hit # Count this addresses as hit
page_to_hit_conf = [r'^.+/logo[/]?$'] #page_to_hit_conf = [r'^.+/logo[/]?$']
# Count this addresses as page ## Count this addresses as page
hit_to_page_conf = [r'^.+/category/.+$', r'^.+/tag/.+$', r'^.+/archive/.+$', r'^.+/ljdc[/]?$'] #hit_to_page_conf = [r'^.+/category/.+$', r'^.+/tag/.+$', r'^.+/archive/.+$', r'^.+/ljdc[/]?$']
# Because it's too long to build HTML when there is too much entries # Because it's too long to build HTML when there is too much entries
max_hits_displayed = 100 max_hits_displayed = 100
max_downloads_displayed = 100 max_downloads_displayed = 100
# Compress these files after generation
compress_output_files = ['html', 'css', 'js'] compress_output_files = ['html', 'css', 'js']
# Display result in French
locale = 'fr' locale = 'fr'

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
import os import os
# Default configuration # Default configuration

10
iwla.py
View File

@ -240,11 +240,10 @@ class IWLA(object):
# TODO : remove return # TODO : remove return
#return #return
with open(filename + '.tmp', 'wb+') as f: with open(filename + '.tmp', 'wb+') as f, gzip.open(filename, 'w') as fzip:
pickle.dump(obj, f) pickle.dump(obj, f)
f.seek(0) f.seek(0)
with gzip.open(filename, 'w') as fzip: fzip.write(f.read())
fzip.write(f.read())
os.remove(filename + '.tmp') os.remove(filename + '.tmp')
def _deserialize(self, filename): def _deserialize(self, filename):
@ -485,9 +484,8 @@ class IWLA(object):
if not os.path.exists(gz_path) or\ if not os.path.exists(gz_path) or\
os.stat(path).st_mtime > build_time: os.stat(path).st_mtime > build_time:
with open(path, 'rb') as f_in: with open(path, 'rb') as f_in, gzip.open(gz_path, 'wb') as f_out:
with gzip.open(gz_path, 'wb') as f_out: f_out.write(f_in.read())
f_out.write(f_in.read())
def _compressFiles(self, build_time, root): def _compressFiles(self, build_time, root):
if not conf.compress_output_files: return if not conf.compress_output_files: return