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

Unified Diff: breakpad.py

Issue 3311023: Add some doc to breakpad.py and add support for NO_BREAKPAD environment variable. (Closed)
Patch Set: Created 10 years, 3 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 | no next file » | 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 7f2eab38791535a33014e77684677c38ba1bbe32..0a1fc083dcdd7f3104888f985dee8efd40a119c7 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.
« 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