Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/statsmaster/templates/build_static_head.erb

Issue 5667089633247232: Issue 479 - Make AWStats produce daily reports as well (Closed)
Patch Set: Created June 24, 2014, 6:08 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « modules/statsmaster/templates/awstats.conf ('k') | modules/statsmaster/templates/build_static_item.erb » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/statsmaster/templates/build_static_head.erb
===================================================================
--- a/modules/statsmaster/templates/build_static_head.erb
+++ b/modules/statsmaster/templates/build_static_head.erb
@@ -9,11 +9,41 @@ from datetime import datetime, timedelta
if len(sys.argv) > 1:
yearmonth = sys.argv[1]
if yearmonth == 'prevmonth':
now = datetime.now()
yearmonth = (now - timedelta(days=now.day)).strftime('%Y%m')
year, month = re.search(r'^(\d{4})(\d{2})$', yearmonth).groups()
dirtemplate = os.path.join('/var/www/awstats/archive/%s', yearmonth)
additional_params = ['-month=%s' % month, '-year=%s' % year]
+ day = None
else:
dirtemplate = '/var/www/awstats/%s'
additional_params = []
+
+ yesterday = datetime.now() - timedelta(days=1)
+ day = yesterday.strftime('%Y%m%d')
+ daily_params = ['-day=%i' % yesterday.day,
+ '-month=%i' % yesterday.month,
+ '-year=%i' % yesterday.year]
+
+def build_pages(site, dir, databasebreak):
+ if not os.path.exists(dir):
+ os.mkdir(dir, 0755)
+
+ datadir = {
+ 'month': '/var/www/awstatsdata',
+ 'day': '/var/www/awstatsdatadaily',
+ }[databasebreak]
+
+ additional = daily_params if databasebreak == 'day' else additional_params
+
+ subprocess.check_output([
+ '/usr/share/awstats/tools/awstats_buildstaticpages.pl',
+ '-configdir=/var/www/awstatsconf',
+ '-config=%s' % site,
+ '-databasebreak=%s' % databasebreak,
+ '-dir=%s' % dir
+ ] + additional, env={'AWSTATSDATA': datadir})
+
+ index = os.path.join(dir, 'index.html')
+ if not os.path.exists(index):
+ os.symlink(os.path.join(dir, 'awstats.%s.html' % site), index)
« no previous file with comments | « modules/statsmaster/templates/awstats.conf ('k') | modules/statsmaster/templates/build_static_item.erb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld