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 = [] |