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

Side by Side Diff: sitescripts/reports/web/submitReport.py

Issue 29350318: Issue 4382 - Use new syntax to catch exceptions in sitescripts (Closed)
Patch Set: Created Aug. 30, 2016, 1:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sitescripts/reports/bin/parseNewReports.py ('k') | sitescripts/stats/bin/logprocessor.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 Eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 os.makedirs(dir) 55 os.makedirs(dir)
56 try: 56 try:
57 file = open(path + '.tmp', 'wb') 57 file = open(path + '.tmp', 'wb')
58 data = environ['wsgi.input'].read(request_size) 58 data = environ['wsgi.input'].read(request_size)
59 file.write(data) 59 file.write(data)
60 file.close() 60 file.close()
61 61
62 knownIssues = knownIssuesParser.findMatches(data.splitlines(), params.ge t('lang', ['en-US'])[0]) 62 knownIssues = knownIssuesParser.findMatches(data.splitlines(), params.ge t('lang', ['en-US'])[0])
63 63
64 os.rename(path + '.tmp', path) 64 os.rename(path + '.tmp', path)
65 except Exception, e: 65 except Exception as e:
66 if os.path.isfile(path + '.tmp'): 66 if os.path.isfile(path + '.tmp'):
67 os.remove(path + '.tmp') 67 os.remove(path + '.tmp')
68 raise e 68 raise e
69 69
70 template = get_template(get_config().get('reports', 'submitResponseTemplate' )) 70 template = get_template(get_config().get('reports', 'submitResponseTemplate' ))
71 start_response('200 OK', [('Content-Type', 'application/xhtml+xml; charset=u tf-8')]) 71 start_response('200 OK', [('Content-Type', 'application/xhtml+xml; charset=u tf-8')])
72 return [template.render({'url': get_config().get('reports', 'urlRoot') + gui d, 'knownIssues': knownIssues}).encode('utf-8')] 72 return [template.render({'url': get_config().get('reports', 'urlRoot') + gui d, 'knownIssues': knownIssues}).encode('utf-8')]
73 73
74 74
75 def showError(message, start_response, response_code='400 Processing Error'): 75 def showError(message, start_response, response_code='400 Processing Error'):
76 template = get_template(get_config().get('reports', 'errorTemplate')) 76 template = get_template(get_config().get('reports', 'errorTemplate'))
77 start_response(response_code, [('Content-Type', 'application/xhtml+xml; char set=utf-8')]) 77 start_response(response_code, [('Content-Type', 'application/xhtml+xml; char set=utf-8')])
78 return [template.render({'message': message}).encode('utf-8')] 78 return [template.render({'message': message}).encode('utf-8')]
OLDNEW
« no previous file with comments | « sitescripts/reports/bin/parseNewReports.py ('k') | sitescripts/stats/bin/logprocessor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld