Try to fix UTC problem
This commit is contained in:
parent
6d62f21373
commit
1a5f65bdc2
|
@ -23,8 +23,7 @@ log_format = '$server_name:$server_port $remote_addr - $remote_user [$time_local
|
||||||
'"$http_referer" "$http_user_agent"'
|
'"$http_referer" "$http_user_agent"'
|
||||||
|
|
||||||
# Time format used in log format
|
# Time format used in log format
|
||||||
# TOFIX UTC
|
time_format = '%d/%b/%Y:%H:%M:%S %z'
|
||||||
time_format = '%d/%b/%Y:%H:%M:%S +0100'
|
|
||||||
|
|
||||||
# Hooks that are loaded at runtime (only set names without path and extensions)
|
# Hooks that are loaded at runtime (only set names without path and extensions)
|
||||||
pre_analysis_hooks = []
|
pre_analysis_hooks = []
|
||||||
|
|
17
iwla.py
17
iwla.py
|
@ -310,7 +310,22 @@ class IWLA(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _decodeTime(self, hit):
|
def _decodeTime(self, hit):
|
||||||
|
try:
|
||||||
hit['time_decoded'] = time.strptime(hit['time_local'], conf.time_format)
|
hit['time_decoded'] = time.strptime(hit['time_local'], conf.time_format)
|
||||||
|
except ValueError, e:
|
||||||
|
if sys.version_info < (3, 2):
|
||||||
|
# Try without UTC value at the end (%z not recognized)
|
||||||
|
gmt_offset_str = hit['time_local'][-5:]
|
||||||
|
gmt_offset_hours = int(gmt_offset_str[1:3])*60*60
|
||||||
|
gmt_offset_minutes = int(gmt_offset_str[3:5])*60
|
||||||
|
gmt_offset = gmt_offset_hours + gmt_offset_minutes
|
||||||
|
hit['time_decoded'] = time.strptime(hit['time_local'][:-6], conf.time_format[:-3])
|
||||||
|
if gmt_offset_str[0] == '+':
|
||||||
|
hit['time_decoded'] = time.localtime(time.mktime(hit['time_decoded'])+gmt_offset)
|
||||||
|
else:
|
||||||
|
hit['time_decoded'] = time.localtime(time.mktime(hit['time_decoded'])-gmt_offset)
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
return hit['time_decoded']
|
return hit['time_decoded']
|
||||||
|
|
||||||
def getDisplayIndex(self):
|
def getDisplayIndex(self):
|
||||||
|
@ -583,7 +598,7 @@ class IWLA(object):
|
||||||
print '==> Load previous database'
|
print '==> Load previous database'
|
||||||
|
|
||||||
self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta()
|
self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta()
|
||||||
if 'last_time' in self.meta_infos.keys():
|
if 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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user