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

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

Issue 6293281981857792: Issue 239 - Move AWStats processing to the stats server (Closed)
Patch Set: Added IP address anonymization and addressed review comments Created April 25, 2014, 7:38 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 file = os.path.join('/var/www/awstatsdata', '<%= title %>',
2 'awstats%s%s.%s.txt' % (month, year, '<%= title %>'))
3 if os.path.exists(file):
4 with open(file, 'rb+') as f:
5 mapstarted = False
6 seekpos = None
7 for line in f:
8 if not mapstarted:
9 if line.startswith('BEGIN_MAP '):
10 mapstarted = True
11 else:
12 match = re.search(r'^POS_VISITOR (\d+)', line)
13 if match:
14 seekpos = int(match.group(1))
15 break
16
17 f.seek(seekpos)
18 data = f.readline() # BEGIN_VISITOR line
19 for line in f:
20 if line.startswith("END_VISITOR"):
21 break
22 parts = line.split(' ')
23 parts[0] = re.sub(r'\w', 'x', parts[0])
24 data += ' '.join(parts)
25
26 f.seek(seekpos)
27 f.write(data)
OLDNEW
« no previous file with comments | « modules/statsmaster/templates/anonymize_ips_head.erb ('k') | modules/statsmaster/templates/awstats.conf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld