Externalise conf

This commit is contained in:
Gregory Soutade 2014-11-20 15:25:43 +01:00
parent f593cc78d9
commit 4cc29487a2
2 changed files with 26 additions and 10 deletions

12
conf.py Normal file
View File

@ -0,0 +1,12 @@
log_format = '$server_name:$server_port $remote_addr - $remote_user [$time_local] ' +\
'"$request" $status $body_bytes_sent ' +\
'"$http_referer" "$http_user_agent"';
#09/Nov/2014:06:35:16 +0100
time_format = '%d/%b/%Y:%H:%M:%S +0100'
analyzed_filename = 'access.log'
DB_ROOT = './output/'
DISPLAY_ROOT = './output/'

24
iwla.py
View File

@ -10,6 +10,19 @@ import gzip
from robots import awstats_robots;
# Default configuration
DB_ROOT = './output/'
DISPLAY_ROOT = './output/'
log_format = '$server_name:$server_port $remote_addr - $remote_user [$time_local] ' +\
'"$request" $status $body_bytes_sent ' +\
'"$http_referer" "$http_user_agent"';
time_format = '%d/%b/%Y:%H:%M:%S +0100'
from conf import *
print '==> Start'
meta_visit = {}
@ -18,16 +31,9 @@ current_visits = {}
cache_plugins = {}
display = {}
log_format = '$server_name:$server_port $remote_addr - $remote_user [$time_local] ' +\
'"$request" $status $body_bytes_sent ' +\
'"$http_referer" "$http_user_agent"';
log_format_extracted = re.sub(r'([^\$\w])', r'\\\g<1>', log_format);
log_format_extracted = re.sub(r'\$(\w+)', '(?P<\g<1>>.+)', log_format_extracted)
http_request_extracted = re.compile(r'(?P<http_method>\S+) (?P<http_uri>\S+) (?P<http_version>\S+)')
#09/Nov/2014:06:35:16 +0100
time_format = '%d/%b/%Y:%H:%M:%S +0100'
#print "Log format : " + log_format_extracted
log_re = re.compile(log_format_extracted)
uri_re = re.compile(r'(?P<extract_uri>[^\?]*)[\?(?P<extract_parameters>.*)]?')
@ -38,8 +44,6 @@ HOOKS_ROOT = './hooks/'
PRE_HOOK_DIRECTORY = HOOKS_ROOT + 'pre_analysis/*.py'
POST_HOOK_DIRECTORY = HOOKS_ROOT + 'post_analysis/*.py'
DISPLAY_HOOK_DIRECTORY = HOOKS_ROOT + 'display/*.py'
DB_ROOT = './output/'
DISPLAY_ROOT = './output/'
META_PATH = DB_ROOT + 'meta.db'
DB_FILENAME = 'iwla.db'
@ -387,7 +391,7 @@ meta_visit = deserialize(META_PATH) or createEmptyMeta()
current_visits = createEmptyVisits()
f = open("access.log")
f = open(analyzed_filename)
for l in f:
# print "line " + l;