Index: breakpad.py |
diff --git a/breakpad.py b/breakpad.py |
index d5b4d926a0af6da64febd81d905fe126e04a2618..c30423d4f8d502986e04058b998355466d526c75 100644 |
--- a/breakpad.py |
+++ b/breakpad.py |
@@ -13,6 +13,7 @@ It is only enabled when all these conditions are met: |
""" |
import atexit |
+import time |
import getpass |
import os |
import urllib |
@@ -22,10 +23,12 @@ import sys |
# Configure these values. |
-DEFAULT_URL = 'https://chromium-status.appspot.com/breakpad' |
+DEFAULT_URL = 'https://chromium-status.appspot.com' |
_REGISTERED = False |
+_TIME_STARTED = time.time() |
+ |
def FormatException(e): |
"""Returns a human readable form of an exception. |
@@ -58,7 +61,7 @@ def FormatException(e): |
def SendStack(last_tb, stack, url=None, maxlen=50): |
"""Sends the stack trace to the breakpad server.""" |
if not url: |
- url = DEFAULT_URL |
+ url = DEFAULT_URL + '/breakpad' |
print 'Sending crash report ...' |
try: |
params = { |
@@ -80,13 +83,31 @@ def SendStack(last_tb, stack, url=None, maxlen=50): |
print('There was a failure while trying to send the stack trace. Too bad.') |
+def SendProfiling(url=None): |
+ try: |
+ if not url: |
+ url = DEFAULT_URL + '/profiling' |
+ params = { |
+ 'argv': ' '.join(sys.argv), |
+ 'duration': time.time() - _TIME_STARTED, |
cmp
2011/04/27 21:30:05
please add 'os' here (result of uname or whatever)
|
+ } |
+ request = urllib.urlopen(url, urllib.urlencode(params)) |
+ request.read() |
+ request.close() |
+ except IOError: |
+ pass |
cmp
2011/04/27 21:30:05
since this runs all of the time, set a timer to ke
|
+ |
+ |
def CheckForException(): |
"""Runs at exit. Look if there was an exception active.""" |
last_value = getattr(sys, 'last_value', None) |
- if last_value and not isinstance(last_value, KeyboardInterrupt): |
- last_tb = getattr(sys, 'last_traceback', None) |
- if last_tb: |
- SendStack(last_value, ''.join(traceback.format_tb(last_tb))) |
+ if last_value: |
+ if not isinstance(last_value, KeyboardInterrupt): |
+ last_tb = getattr(sys, 'last_traceback', None) |
+ if last_tb: |
+ SendStack(last_value, ''.join(traceback.format_tb(last_tb))) |
+ else: |
+ SendProfiling() |
def Register(): |