Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #!/usr/bin/env python | 1 #!/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.
| |
2 | 2 |
3 import subprocess, sys, os, re | 3 import subprocess |
Felix Dahlke
2014/04/25 04:37:08
Should be one import per package, according to PEP
| |
4 import sys | |
5 import os | |
6 import re | |
4 from datetime import datetime, timedelta | 7 from datetime import datetime, timedelta |
5 | 8 |
6 if len(sys.argv) > 1: | 9 if len(sys.argv) > 1: |
7 yearmonth = sys.argv[1] | 10 yearmonth = sys.argv[1] |
8 if yearmonth == 'prevmonth': | 11 if yearmonth == 'prevmonth': |
9 now = datetime.now() | 12 now = datetime.now() |
10 yearmonth = (now - timedelta(days=now.day)).strftime('%Y%m') | 13 yearmonth = (now - timedelta(days=now.day)).strftime('%Y%m') |
11 year, month = re.search(r'^(\d{4})(\d{2})$', yearmonth).groups() | 14 year, month = re.search(r'^(\d{4})(\d{2})$', yearmonth).groups() |
12 dirtemplate = os.path.join('/var/www/awstats/archive/%s', yearmonth) | 15 dirtemplate = os.path.join('/var/www/awstats/archive/%s', yearmonth) |
13 additional_params = ['-month=%s' % month, '-year=%s' % year] | 16 additional_params = ['-month=%s' % month, '-year=%s' % year] |
14 else: | 17 else: |
15 dirtemplate = '/var/www/awstats/%s' | 18 dirtemplate = '/var/www/awstats/%s' |
16 additional_params = [] | 19 additional_params = [] |
LEFT | RIGHT |