OLD | NEW |
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 It is only enabled when all these conditions are met: | 9 It is only enabled when all these conditions are met: |
10 1. hostname finishes with '.google.com' | 10 1. hostname finishes with '.google.com' |
(...skipping 28 matching lines...) Expand all Loading... |
39 'user': getpass.getuser(), | 39 'user': getpass.getuser(), |
40 'exception': last_tb, | 40 'exception': last_tb, |
41 'host': socket.getfqdn(), | 41 'host': socket.getfqdn(), |
42 'cwd': os.getcwd(), | 42 'cwd': os.getcwd(), |
43 } | 43 } |
44 try: | 44 try: |
45 # That may not always work. | 45 # That may not always work. |
46 params['exception'] = str(last_tb) | 46 params['exception'] = str(last_tb) |
47 except: | 47 except: |
48 pass | 48 pass |
49 print '\n'.join(' %s: %s' % (k, v[0:50]) for k,v in params.iteritems()) | 49 print('\n'.join(' %s: %s' % (k, v[0:50]) for k, v in params.iteritems())) |
50 request = urllib.urlopen(url, urllib.urlencode(params)) | 50 request = urllib.urlopen(url, urllib.urlencode(params)) |
51 print request.read() | 51 print(request.read()) |
52 request.close() | 52 request.close() |
53 except IOError: | 53 except IOError: |
54 print('There was a failure while trying to send the stack trace. Too bad.') | 54 print('There was a failure while trying to send the stack trace. Too bad.') |
55 | 55 |
56 | 56 |
57 def CheckForException(): | 57 def CheckForException(): |
58 """Runs at exit. Look if there was an exception active.""" | 58 """Runs at exit. Look if there was an exception active.""" |
59 last_value = getattr(sys, 'last_value', None) | 59 last_value = getattr(sys, 'last_value', None) |
60 if last_value and not isinstance(last_value, KeyboardInterrupt): | 60 if last_value and not isinstance(last_value, KeyboardInterrupt): |
61 last_tb = getattr(sys, 'last_traceback', None) | 61 last_tb = getattr(sys, 'last_traceback', None) |
(...skipping 12 matching lines...) Expand all Loading... |
74 | 74 |
75 # Skip unit tests and we don't want anything from non-googler. | 75 # Skip unit tests and we don't want anything from non-googler. |
76 if (not 'test' in sys.modules['__main__'].__file__ and | 76 if (not 'test' in sys.modules['__main__'].__file__ and |
77 not 'NO_BREAKPAD' in os.environ and | 77 not 'NO_BREAKPAD' in os.environ and |
78 (socket.getfqdn().endswith('.google.com') or | 78 (socket.getfqdn().endswith('.google.com') or |
79 socket.getfqdn().endswith('.chromium.org'))): | 79 socket.getfqdn().endswith('.chromium.org'))): |
80 Register() | 80 Register() |
81 | 81 |
82 # Uncomment this line if you want to test it out. | 82 # Uncomment this line if you want to test it out. |
83 #Register() | 83 #Register() |
OLD | NEW |