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

Side by Side Diff: breakpad.py

Issue 2327003: Use https for stack trace upload. (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
16 # Configure these values. 17 # Configure these values.
17 DEFAULT_URL = 'http://chromium-status.appspot.com/breakpad' 18 DEFAULT_URL = 'https://chromium-status.appspot.com/breakpad'
19
20 _REGISTERED = False
21
18 22
19 def SendStack(last_tb, stack, url=None): 23 def SendStack(last_tb, stack, url=None):
24 """Sends the stack trace to the breakpad server."""
20 if not url: 25 if not url:
21 url = DEFAULT_URL 26 url = DEFAULT_URL
22 print 'Sending crash report ...' 27 print 'Sending crash report ...'
23 try: 28 try:
24 params = { 29 params = {
25 'args': sys.argv, 30 'args': sys.argv,
26 'stack': stack, 31 'stack': stack,
27 'user': getpass.getuser(), 32 'user': getpass.getuser(),
28 'exception': last_tb, 33 'exception': last_tb,
34 'host': socket.getfqdn(),
29 } 35 }
30 request = urllib.urlopen(url, urllib.urlencode(params)) 36 request = urllib.urlopen(url, urllib.urlencode(params))
31 print request.read() 37 print request.read()
32 request.close() 38 request.close()
33 except IOError: 39 except IOError:
34 print('There was a failure while trying to send the stack trace. Too bad.') 40 print('There was a failure while trying to send the stack trace. Too bad.')
35 41
36 42
37 def CheckForException(): 43 def CheckForException():
44 """Runs at exit. Look if there was an exception active."""
38 last_value = getattr(sys, 'last_value', None) 45 last_value = getattr(sys, 'last_value', None)
39 if last_value and not isinstance(last_value, KeyboardInterrupt): 46 if last_value and not isinstance(last_value, KeyboardInterrupt):
40 last_tb = getattr(sys, 'last_traceback', None) 47 last_tb = getattr(sys, 'last_traceback', None)
41 if last_tb: 48 if last_tb:
42 SendStack(repr(last_value), ''.join(traceback.format_tb(last_tb))) 49 SendStack(repr(last_value), ''.join(traceback.format_tb(last_tb)))
43 50
44 51
52 def Register():
53 """Registers the callback at exit. Calling it multiple times is no-op."""
54 global _REGISTERED
55 if _REGISTERED:
56 return
57 _REGISTERED = True
58 atexit.register(CheckForException)
59
60
61 # Skip unit tests and we don't want anything from non-googler.
45 if (not 'test' in sys.modules['__main__'].__file__ and 62 if (not 'test' in sys.modules['__main__'].__file__ and
46 socket.getfqdn().endswith('.google.com')): 63 socket.getfqdn().endswith('.google.com')):
47 # Skip unit tests and we don't want anything from non-googler. 64 Register()
48 atexit.register(CheckForException) 65
66 # Uncomment this line if you want to test it out.
67 #Register()
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