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