| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 import subprocess, sys, os, re | 3 import subprocess |
| 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 = [] |
| OLD | NEW |