Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: breakpad.py

Issue 2109001: Fix KeyboardInterrupt exception filtering. (Closed)
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Breakpad for Python. 5 """Breakpad for Python.
6 6
7 Sends a notification when a process stops on an exception.""" 7 Sends a notification when a process stops on an exception."""
8 8
9 import atexit 9 import atexit
10 import getpass 10 import getpass
11 import urllib 11 import urllib
12 import traceback 12 import traceback
13 import socket 13 import socket
14 import sys 14 import sys
15 15
16 # Configure these values.
17 DEFAULT_URL = 'http://chromium-status.appspot.com/breakpad'
16 18
17 def SendStack(stack, url='http://chromium-status.appspot.com/breakpad'): 19 def SendStack(last_tb, stack, url=None):
20 if not url:
21 url = DEFAULT_URL
18 print 'Sending crash report ...' 22 print 'Sending crash report ...'
19 try: 23 try:
20 params = { 24 params = {
21 'args': sys.argv, 25 'args': sys.argv,
22 'stack': stack, 26 'stack': stack,
23 'user': getpass.getuser(), 27 'user': getpass.getuser(),
28 'exception': last_tb,
24 } 29 }
25 request = urllib.urlopen(url, urllib.urlencode(params)) 30 request = urllib.urlopen(url, urllib.urlencode(params))
26 print request.read() 31 print request.read()
27 request.close() 32 request.close()
28 except IOError: 33 except IOError:
29 print('There was a failure while trying to send the stack trace. Too bad.') 34 print('There was a failure while trying to send the stack trace. Too bad.')
30 35
31 36
32 def CheckForException(): 37 def CheckForException():
33 last_tb = getattr(sys, 'last_traceback', None) 38 last_value = getattr(sys, 'last_value', None)
34 if last_tb and sys.last_type is not KeyboardInterrupt: 39 if last_value and not isinstance(last_value, KeyboardInterrupt):
35 SendStack(''.join(traceback.format_tb(last_tb))) 40 last_tb = getattr(sys, 'last_traceback', None)
41 if last_tb:
42 SendStack(repr(last_value), ''.join(traceback.format_tb(last_tb)))
36 43
37 44
38 if (not 'test' in sys.modules['__main__'].__file__ and 45 if (not 'test' in sys.modules['__main__'].__file__ and
39 socket.gethostname().endswith('.google.com')): 46 socket.gethostname().endswith('.google.com')):
40 # Skip unit tests and we don't want anything from non-googler. 47 # Skip unit tests and we don't want anything from non-googler.
41 atexit.register(CheckForException) 48 atexit.register(CheckForException)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698