Externalise conf
This commit is contained in:
parent
f593cc78d9
commit
4cc29487a2
12
conf.py
Normal file
12
conf.py
Normal 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
24
iwla.py
|
@ -10,6 +10,19 @@ import gzip
|
||||||
|
|
||||||
from robots import awstats_robots;
|
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'
|
print '==> Start'
|
||||||
|
|
||||||
meta_visit = {}
|
meta_visit = {}
|
||||||
|
@ -18,16 +31,9 @@ current_visits = {}
|
||||||
cache_plugins = {}
|
cache_plugins = {}
|
||||||
display = {}
|
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])', r'\\\g<1>', log_format);
|
||||||
log_format_extracted = re.sub(r'\$(\w+)', '(?P<\g<1>>.+)', log_format_extracted)
|
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+)')
|
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)
|
log_re = re.compile(log_format_extracted)
|
||||||
uri_re = re.compile(r'(?P<extract_uri>[^\?]*)[\?(?P<extract_parameters>.*)]?')
|
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'
|
PRE_HOOK_DIRECTORY = HOOKS_ROOT + 'pre_analysis/*.py'
|
||||||
POST_HOOK_DIRECTORY = HOOKS_ROOT + 'post_analysis/*.py'
|
POST_HOOK_DIRECTORY = HOOKS_ROOT + 'post_analysis/*.py'
|
||||||
DISPLAY_HOOK_DIRECTORY = HOOKS_ROOT + 'display/*.py'
|
DISPLAY_HOOK_DIRECTORY = HOOKS_ROOT + 'display/*.py'
|
||||||
DB_ROOT = './output/'
|
|
||||||
DISPLAY_ROOT = './output/'
|
|
||||||
META_PATH = DB_ROOT + 'meta.db'
|
META_PATH = DB_ROOT + 'meta.db'
|
||||||
DB_FILENAME = 'iwla.db'
|
DB_FILENAME = 'iwla.db'
|
||||||
|
|
||||||
|
@ -387,7 +391,7 @@ meta_visit = deserialize(META_PATH) or createEmptyMeta()
|
||||||
|
|
||||||
current_visits = createEmptyVisits()
|
current_visits = createEmptyVisits()
|
||||||
|
|
||||||
f = open("access.log")
|
f = open(analyzed_filename)
|
||||||
for l in f:
|
for l in f:
|
||||||
# print "line " + l;
|
# print "line " + l;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user