Set two digits for month numbers

This commit is contained in:
Grégory Soutadé 2014-12-12 13:24:47 +01:00
parent 2c3d8d22f8
commit f116eacbcc
2 changed files with 7 additions and 7 deletions

View File

@ -10,7 +10,7 @@ display_visitor_ip = True
# Hooks used
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']
# Reverse DNS timeout

12
iwla.py
View File

@ -174,7 +174,7 @@ class IWLA(object):
def getCurDisplayPath(self, filename):
cur_time = self.meta_infos['last_time']
return os.path.join(str(cur_time.tm_year), str(cur_time.tm_mon), filename)
return os.path.join(str(cur_time.tm_year), '%02d' % (cur_time.tm_mon), filename)
def getResourcesPath(self):
return conf.resources_path
@ -194,7 +194,7 @@ class IWLA(object):
return self.display
def getDBFilename(self, time):
return os.path.join(conf.DB_ROOT, str(time.tm_year), '%02d' % time.tm_mon, conf.DB_FILENAME)
return os.path.join(conf.DB_ROOT, str(time.tm_year), '%02d' % (time.tm_mon), conf.DB_FILENAME)
def _serialize(self, obj, filename):
base = os.path.dirname(filename)
@ -336,7 +336,7 @@ class IWLA(object):
def _generateDisplayDaysStats(self):
cur_time = self.meta_infos['last_time']
title = 'Stats %d/%d' % (cur_time.tm_mon, cur_time.tm_year)
title = 'Stats %d/%02d' % (cur_time.tm_year, cur_time.tm_mon)
filename = self.getCurDisplayPath('index.html')
print '==> Generate display (%s)' % (filename)
page = self.display.createPage(title, filename, conf.css_path)
@ -405,7 +405,7 @@ class IWLA(object):
full_month = '%s %d' % (months_name[i], year)
if i in month_stats.keys():
stats = month_stats[i]
link = '<a href="%d/%d/index.html">Details</a>' % (year, i)
link = '<a href="%d/%02d/index.html">Details</a>' % (year, i)
row = [full_month, stats['nb_visitors'], stats['viewed_pages'], stats['viewed_hits'],
stats['viewed_bandwidth'], stats['not_viewed_bandwidth'], link]
for j in graph_cols:
@ -488,7 +488,7 @@ class IWLA(object):
duplicated_stats = {k:v for (k,v) in stats.items()}
cur_time = self.meta_infos['last_time']
print "== Stats for %d/%d ==" % (cur_time.tm_year, cur_time.tm_mon)
print "== Stats for %d/%02d ==" % (cur_time.tm_year, cur_time.tm_mon)
print stats
if not 'month_stats' in self.current_analysis.keys():
@ -535,7 +535,7 @@ class IWLA(object):
stats = self._generateStats(visits)
cur_time = self.meta_infos['last_time']
print "== Stats for %d/%d/%d ==" % (cur_time.tm_year, cur_time.tm_mon, cur_time.tm_mday)
print "== Stats for %d/%02d/%d ==" % (cur_time.tm_year, cur_time.tm_mon, cur_time.tm_mday)
if cur_time.tm_mday > 1:
last_day = cur_time.tm_mday - 1