diff --git a/breakpad.py b/breakpad.py new file mode 100644 index 000000000..36ac138d1 --- /dev/null +++ b/breakpad.py @@ -0,0 +1,39 @@ +# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Breakpad for Python. + +Sends a notification when a process stops on an exception.""" + +import atexit +import getpass +import urllib +import traceback +import sys + + +def SendStack(stack, url='http://chromium-status.appspot.com/breakpad'): + print 'Do you want to send a crash report [y/N]? ', + if sys.stdin.read(1).lower() == 'y': + try: + params = { + 'args': sys.argv, + 'stack': stack, + 'user': getpass.getuser(), + } + request = urllib.urlopen(url, urllib.urlencode(params)) + print request.read() + request.close() + except IOError: + print('There was a failure while trying to send the stack trace. Too bad.') + + +@atexit.register +def CheckForException(): + if 'test' in sys.modules['__main__'].__file__: + # Probably a unit test. + return + last_tb = getattr(sys, 'last_traceback', None) + if last_tb: + SendStack(''.join(traceback.format_tb(last_tb))) diff --git a/drover.py b/drover.py index 99eafb2cb..f19308a41 100644 --- a/drover.py +++ b/drover.py @@ -9,6 +9,8 @@ import subprocess import sys import webbrowser +import breakpad + USAGE = """ WARNING: Please use this tool in an empty directory (or at least one that you don't mind clobbering.) diff --git a/gcl.py b/gcl.py index 4a61b4cbd..b347a4d0b 100755 --- a/gcl.py +++ b/gcl.py @@ -18,6 +18,8 @@ import tempfile import upload import urllib2 +import breakpad + # gcl now depends on gclient. from scm import SVN import gclient_utils diff --git a/gclient.py b/gclient.py index cb93162a2..8090d202f 100755 --- a/gclient.py +++ b/gclient.py @@ -78,6 +78,8 @@ import sys import urlparse import urllib +import breakpad + import gclient_scm import gclient_utils diff --git a/git_cl_hooks.py b/git_cl_hooks.py index 1e153f006..81d48cea0 100644 --- a/git_cl_hooks.py +++ b/git_cl_hooks.py @@ -7,6 +7,8 @@ import re import subprocess import sys +import breakpad + import presubmit_support import scm