Commit 18878421 authored by maruel@chromium.org's avatar maruel@chromium.org

Make sure that direct call to SendStack() doesn't send a stack trace for non googler

I don't want to receive them even in the case of a direct call to SendStack().

R=dpranke@chromium.org
BUG=
TEST=


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@117039 0039d316-1c4b-4281-b951-d872f2087c98
parent 95406ac9
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Copyright (c) 2012 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.
......@@ -33,6 +33,12 @@ _TIME_STARTED = time.time()
_HOST_NAME = socket.getfqdn()
# Skip unit tests and we don't want anything from non-googler.
IS_ENABLED = (
not 'test' in getattr(sys.modules['__main__'], '__file__', '') and
not 'NO_BREAKPAD' in os.environ and
_HOST_NAME.endswith(('.google.com', '.chromium.org')))
def post(url, params):
"""HTTP POST with timeout when it's supported."""
......@@ -75,6 +81,9 @@ def FormatException(e):
def SendStack(last_tb, stack, url=None, maxlen=50):
"""Sends the stack trace to the breakpad server."""
if not IS_ENABLED:
# Make sure to not send anything for non googler.
return
if not url:
url = DEFAULT_URL + '/breakpad'
print 'Sending crash report ...'
......@@ -133,11 +142,7 @@ def Register():
atexit.register(CheckForException)
# Skip unit tests and we don't want anything from non-googler.
if (not 'test' in getattr(sys.modules['__main__'], '__file__', '') and
not 'NO_BREAKPAD' in os.environ and
(_HOST_NAME.endswith('.google.com') or
_HOST_NAME.endswith('.chromium.org'))):
if IS_ENABLED:
Register()
# Uncomment this line if you want to test it out.
......
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Copyright (c) 2012 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.
......@@ -23,20 +23,23 @@ class Breakpad(SuperMoxTestBase):
self.mox.StubOutWithMock(breakpad.getpass, 'getuser')
self.mox.StubOutWithMock(breakpad.urllib2, 'urlopen')
breakpad._HOST_NAME = 'bozo'
self.assertEquals(False, breakpad.IS_ENABLED)
breakpad.IS_ENABLED = True
self._old_sys_argv = breakpad.sys.argv
breakpad.sys.argv = ['my_test']
self._old_sys_version = breakpad.sys.version
breakpad.sys.version = 'random python'
def tearDown(self):
breakpad.IS_ENABLED = False
breakpad.sys.version = self._old_sys_version
breakpad.sys.argv = self._old_sys_argv
super(Breakpad, self).tearDown()
def testMembersChanged(self):
members = [
'CheckForException', 'DEFAULT_URL', 'FormatException', 'Register',
'SendProfiling', 'SendStack',
'CheckForException', 'DEFAULT_URL', 'FormatException', 'IS_ENABLED',
'Register', 'SendProfiling', 'SendStack',
'atexit', 'getpass', 'os', 'post', 'socket', 'sys', 'time', 'traceback',
'urllib', 'urllib2',
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment