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

Side by Side Diff: breakpad.py

Issue 5608001: Make max len parametrable so it can be modified for users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 10 years 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 | Annotate | Revision Log
« 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 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 # The web page in some urllib exceptions. 48 # The web page in some urllib exceptions.
49 if hasattr(e, 'read') and callable(e.read): 49 if hasattr(e, 'read') and callable(e.read):
50 out += '\nread(): %s' % e.read() 50 out += '\nread(): %s' % e.read()
51 if hasattr(e, 'info') and callable(e.info): 51 if hasattr(e, 'info') and callable(e.info):
52 out += '\ninfo(): %s' % e.info() 52 out += '\ninfo(): %s' % e.info()
53 except Exception: 53 except Exception:
54 pass 54 pass
55 return out 55 return out
56 56
57 57
58 def SendStack(last_tb, stack, url=None): 58 def SendStack(last_tb, stack, url=None, maxlen=50):
59 """Sends the stack trace to the breakpad server.""" 59 """Sends the stack trace to the breakpad server."""
60 if not url: 60 if not url:
61 url = DEFAULT_URL 61 url = DEFAULT_URL
62 print 'Sending crash report ...' 62 print 'Sending crash report ...'
63 try: 63 try:
64 params = { 64 params = {
65 'args': sys.argv, 65 'args': sys.argv,
66 'stack': stack[0:4096], 66 'stack': stack[0:4096],
67 'user': getpass.getuser(), 67 'user': getpass.getuser(),
68 'exception': FormatException(last_tb), 68 'exception': FormatException(last_tb),
69 'host': socket.getfqdn(), 69 'host': socket.getfqdn(),
70 'cwd': os.getcwd(), 70 'cwd': os.getcwd(),
71 'version': sys.version, 71 'version': sys.version,
72 } 72 }
73 # pylint: disable=W0702 73 # pylint: disable=W0702
74 print('\n'.join(' %s: %s' % (k, v[0:50]) for k, v in params.iteritems())) 74 print('\n'.join(' %s: %s' % (k, v[0:maxlen])
75 for k, v in params.iteritems()))
75 request = urllib.urlopen(url, urllib.urlencode(params)) 76 request = urllib.urlopen(url, urllib.urlencode(params))
76 print(request.read()) 77 print(request.read())
77 request.close() 78 request.close()
78 except IOError: 79 except IOError:
79 print('There was a failure while trying to send the stack trace. Too bad.') 80 print('There was a failure while trying to send the stack trace. Too bad.')
80 81
81 82
82 def CheckForException(): 83 def CheckForException():
83 """Runs at exit. Look if there was an exception active.""" 84 """Runs at exit. Look if there was an exception active."""
84 last_value = getattr(sys, 'last_value', None) 85 last_value = getattr(sys, 'last_value', None)
(...skipping 14 matching lines...) Expand all
99 100
100 # Skip unit tests and we don't want anything from non-googler. 101 # Skip unit tests and we don't want anything from non-googler.
101 if (not 'test' in sys.modules['__main__'].__file__ and 102 if (not 'test' in sys.modules['__main__'].__file__ and
102 not 'NO_BREAKPAD' in os.environ and 103 not 'NO_BREAKPAD' in os.environ and
103 (socket.getfqdn().endswith('.google.com') or 104 (socket.getfqdn().endswith('.google.com') or
104 socket.getfqdn().endswith('.chromium.org'))): 105 socket.getfqdn().endswith('.chromium.org'))):
105 Register() 106 Register()
106 107
107 # Uncomment this line if you want to test it out. 108 # Uncomment this line if you want to test it out.
108 #Register() 109 #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