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

Side by Side Diff: sitescripts/crashes/web/submitCrash.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 | « no previous file | sitescripts/extensions/bin/createNightlies.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if not os.path.exists(dir): 47 if not os.path.exists(dir):
48 os.makedirs(dir) 48 os.makedirs(dir)
49 49
50 filename = None 50 filename = None
51 try: 51 try:
52 fd, filename = mkstemp('.xml.tmp', 'crash_', dir) 52 fd, filename = mkstemp('.xml.tmp', 'crash_', dir)
53 file = os.fdopen(fd, 'wb') 53 file = os.fdopen(fd, 'wb')
54 file.write(environ['wsgi.input'].read(request_body_size)) 54 file.write(environ['wsgi.input'].read(request_body_size))
55 file.close() 55 file.close()
56 os.rename(filename, os.path.splitext(filename)[0]) 56 os.rename(filename, os.path.splitext(filename)[0])
57 except Exception, e: 57 except Exception as e:
58 if filename != None and os.path.isfile(filename): 58 if filename != None and os.path.isfile(filename):
59 os.remove(filename) 59 os.remove(filename)
60 raise e 60 raise e
61 61
62 start_response('200 Ok', [('Content-Type', 'text/plain; charset=utf-8')]) 62 start_response('200 Ok', [('Content-Type', 'text/plain; charset=utf-8')])
63 return ['saved'.encode('utf-8')] 63 return ['saved'.encode('utf-8')]
64 64
65 65
66 def showError(message, start_response): 66 def showError(message, start_response):
67 start_response('400 Processing Error', [('Content-Type', 'text/plain; charse t=utf-8')]) 67 start_response('400 Processing Error', [('Content-Type', 'text/plain; charse t=utf-8')])
68 return [message.encode('utf-8')] 68 return [message.encode('utf-8')]
OLDNEW
« no previous file with comments | « no previous file | sitescripts/extensions/bin/createNightlies.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld