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

Side by Side Diff: modules/statsmaster/templates/build_static_head.erb

Issue 29464559: #1538 - Remove class statsmaster and associated resources (Closed)
Patch Set: Created June 13, 2017, 9:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 import subprocess
4 import sys
5 import os
6 import re
7 from datetime import datetime, timedelta
8
9 if len(sys.argv) > 1:
10 yearmonth = sys.argv[1]
11 if yearmonth == 'prevmonth':
12 now = datetime.now()
13 yearmonth = (now - timedelta(days=now.day)).strftime('%Y%m')
14 year, month = re.search(r'^(\d{4})(\d{2})$', yearmonth).groups()
15 dirtemplate = os.path.join('/var/www/awstats/archive/%s', yearmonth)
16 additional_params = ['-month=%s' % month, '-year=%s' % year]
17 day = None
18 else:
19 dirtemplate = '/var/www/awstats/%s'
20 additional_params = []
21
22 yesterday = datetime.now() - timedelta(days=1)
23 day = yesterday.strftime('%Y%m%d')
24 daily_params = ['-day=%i' % yesterday.day,
25 '-month=%i' % yesterday.month,
26 '-year=%i' % yesterday.year]
27
28 def build_pages(site, dir, databasebreak):
29 if not os.path.exists(dir):
30 os.mkdir(dir, 0755)
31
32 datadir = {
33 'month': '/var/www/awstatsdata',
34 'day': '/var/www/awstatsdatadaily',
35 }[databasebreak]
36
37 additional = daily_params if databasebreak == 'day' else additional_params
38
39 subprocess.check_output([
40 '/usr/share/awstats/tools/awstats_buildstaticpages.pl',
41 '-configdir=/var/www/awstatsconf',
42 '-config=%s' % site,
43 '-databasebreak=%s' % databasebreak,
44 '-dir=%s' % dir
45 ] + additional, env={'AWSTATSDATA': datadir})
46
47 index = os.path.join(dir, 'index.html')
48 if not os.path.exists(index):
49 os.symlink(os.path.join(dir, 'awstats.%s.html' % site), index)
OLDNEW

Powered by Google App Engine
This is Rietveld