Przeglądaj źródła

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
maruel@chromium.org 15 lat temu
rodzic
commit
fa877020b6
1 zmienionych plików z 15 dodań i 2 usunięć
  1. 15 2
      breakpad.py

+ 15 - 2
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.