瀏覽代碼

Add a check so non-google employee don't send crash dumps.

Add a warning message in case the check ever fail.

Review URL: http://codereview.chromium.org/460044

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@33700 0039d316-1c4b-4281-b951-d872f2087c98
maruel@chromium.org 15 年之前
父節點
當前提交
7aca9e8cb5
共有 1 個文件被更改,包括 23 次插入18 次删除
  1. 23 18
      breakpad.py

+ 23 - 18
breakpad.py

@@ -10,30 +10,35 @@ import atexit
 import getpass
 import getpass
 import urllib
 import urllib
 import traceback
 import traceback
+import socket
 import sys
 import sys
 
 
 
 
 def SendStack(stack, url='http://chromium-status.appspot.com/breakpad'):
 def SendStack(stack, url='http://chromium-status.appspot.com/breakpad'):
   print 'Do you want to send a crash report [y/N]? ',
   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.
+  if sys.stdin.read(1).lower() != 'y':
     return
     return
+  print 'Sending crash report ...'
+  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.')
+
+
+def CheckForException():
   last_tb = getattr(sys, 'last_traceback', None)
   last_tb = getattr(sys, 'last_traceback', None)
   if last_tb:
   if last_tb:
     SendStack(''.join(traceback.format_tb(last_tb)))
     SendStack(''.join(traceback.format_tb(last_tb)))
+
+
+if (not 'test' in sys.modules['__main__'].__file__ and
+    socket.gethostname().endswith('.google.com')):
+  # Skip unit tests and we don't want anything from non-googler.
+  atexit.register(CheckForException)