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

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

Issue 6293281981857792: Issue 239 - Move AWStats processing to the stats server (Closed)
Patch Set: Created April 23, 2014, 1:14 p.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
Index: modules/statsmaster/templates/build_static_head.erb
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/statsmaster/templates/build_static_head.erb
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
Felix Dahlke 2014/04/25 04:37:08 Why is this a template? Seems to me like it could
Wladimir Palant 2014/04/25 07:40:55 Sure, it can be a static file - it's merely a temp
Felix Dahlke 2014/04/25 09:42:50 Fair enough.
+
+import subprocess, sys, os, re
Felix Dahlke 2014/04/25 04:37:08 Should be one import per package, according to PEP
+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]
+else:
+ dirtemplate = '/var/www/awstats/%s'
+ additional_params = []

Powered by Google App Engine
This is Rietveld