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

Unified Diff: breakpad.py

Issue 444009: Minimalist breakpad implementation. (Closed)
Patch Set: Default to opt-out Created 11 years, 1 month 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 | drover.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
new file mode 100644
index 0000000000000000000000000000000000000000..36ac138d12f1d775e601527f91cd99a985887e8f
--- /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)))
« no previous file with comments | « no previous file | drover.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698