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

Unified Diff: breakpad.py

Issue 9178019: Overhaul breakpad to optionally disable output. Add git-cl dcommit unit test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gcl.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: breakpad.py
diff --git a/breakpad.py b/breakpad.py
index 6ae5b2361f33ef83b217299299cec37e3a726c6c..3540b261fece88665b19f2ff07249d314abd8403 100644
--- a/breakpad.py
+++ b/breakpad.py
@@ -42,13 +42,19 @@ IS_ENABLED = (
def post(url, params):
"""HTTP POST with timeout when it's supported."""
+ if not IS_ENABLED:
+ # Make sure to not send anything for non googler.
+ return
kwargs = {}
if (sys.version_info[0] * 10 + sys.version_info[1]) >= 26:
kwargs['timeout'] = 4
- request = urllib2.urlopen(url, urllib.urlencode(params), **kwargs)
- out = request.read()
- request.close()
- return out
+ try:
+ request = urllib2.urlopen(url, urllib.urlencode(params), **kwargs)
+ out = request.read()
+ request.close()
+ return out
+ except IOError:
+ return 'There was a failure while trying to send the stack trace. Too bad.'
def FormatException(e):
@@ -79,46 +85,36 @@ def FormatException(e):
return out
-def SendStack(last_tb, stack, url=None, maxlen=50):
+def SendStack(last_tb, stack, url=None, maxlen=50, verbose=True):
"""Sends the stack trace to the breakpad server."""
if not IS_ENABLED:
- # Make sure to not send anything for non googler.
return
- if not url:
- url = DEFAULT_URL + '/breakpad'
- print 'Sending crash report ...'
- try:
- params = {
- 'args': sys.argv,
- 'stack': stack[0:4096],
- 'user': getpass.getuser(),
- 'exception': FormatException(last_tb),
- 'host': _HOST_NAME,
- 'cwd': os.getcwd(),
- 'version': sys.version,
- }
- # pylint: disable=W0702
- print('\n'.join(' %s: %s' % (k, params[k][0:maxlen])
- for k in sorted(params)))
- print(post(url, params))
- except IOError:
- print('There was a failure while trying to send the stack trace. Too bad.')
+ def p(o):
+ if verbose:
+ print(o)
+ p('Sending crash report ...')
+ params = {
+ 'args': sys.argv,
+ 'cwd': os.getcwd(),
+ 'exception': FormatException(last_tb),
+ 'host': _HOST_NAME,
+ 'stack': stack[0:4096],
+ 'user': getpass.getuser(),
+ 'version': sys.version,
+ }
+ p('\n'.join(' %s: %s' % (k, params[k][0:maxlen]) for k in sorted(params)))
+ p(post(url or DEFAULT_URL + '/breakpad', params))
def SendProfiling(url=None):
- try:
- if not url:
- url = DEFAULT_URL + '/profiling'
- params = {
- 'argv': ' '.join(sys.argv),
- # Strip the hostname.
- 'domain': _HOST_NAME.split('.', 1)[-1],
- 'duration': time.time() - _TIME_STARTED,
- 'platform': sys.platform,
- }
- post(url, params)
- except IOError:
- pass
+ params = {
+ 'argv': ' '.join(sys.argv),
+ # Strip the hostname.
+ 'domain': _HOST_NAME.split('.', 1)[-1],
+ 'duration': time.time() - _TIME_STARTED,
+ 'platform': sys.platform,
+ }
+ post(url or DEFAULT_URL + '/profiling', params)
def CheckForException():
« no previous file with comments | « no previous file | gcl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698