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

Delta Between Two Patch Sets: modules/statsmaster/templates/anonymize_ips_item.erb

Issue 6293281981857792: Issue 239 - Move AWStats processing to the stats server (Closed)
Left Patch Set: Created April 23, 2014, 1:14 p.m.
Right 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:
Right: Side by side diff | Download
« no previous file with change/comment | « modules/statsmaster/templates/anonymize_ips_head.erb ('k') | modules/statsmaster/templates/awstats.conf » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld