From fa877020b64bf1b78dd15b675eb146df536858c9 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Thu, 9 Sep 2010 20:01:09 +0000 Subject: [PATCH] Add some doc to breakpad.py and add support for NO_BREAKPAD environment variable. TEST=none BUG=none Review URL: http://codereview.chromium.org/3311023 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@58982 0039d316-1c4b-4281-b951-d872f2087c98 --- breakpad.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/breakpad.py b/breakpad.py index 7f2eab3879..0a1fc083dc 100644 --- a/breakpad.py +++ b/breakpad.py @@ -4,10 +4,17 @@ """Breakpad for Python. -Sends a notification when a process stops on an exception.""" +Sends a notification when a process stops on an exception. + +It is only enabled when all these conditions are met: + 1. hostname finishes with '.google.com' + 2. main module name doesn't contain the word 'test' + 3. no NO_BREAKPAD environment variable is defined +""" import atexit import getpass +import os import urllib import traceback import socket @@ -33,6 +40,11 @@ def SendStack(last_tb, stack, url=None): 'exception': last_tb, 'host': socket.getfqdn(), } + try: + # That may not always work. + params['exception'] = str(last_tb) + except: + pass request = urllib.urlopen(url, urllib.urlencode(params)) print request.read() request.close() @@ -60,7 +72,8 @@ def Register(): # Skip unit tests and we don't want anything from non-googler. if (not 'test' in sys.modules['__main__'].__file__ and - socket.getfqdn().endswith('.google.com')): + socket.getfqdn().endswith('.google.com') and + not 'NO_BREAKPAD' in os.environ): Register() # Uncomment this line if you want to test it out.