Esempio n. 1
0
 def test_timeout_reset_after_call(self):
     old_timeout = socket.getdefaulttimeout()
     self.stub_urlopen_with_timeout_check(30, None, "url")
     try:
         socket.setdefaulttimeout(1234)
         base_utils.urlopen("url", timeout=30)
         self.assertEquals(1234, socket.getdefaulttimeout())
     finally:
         socket.setdefaulttimeout(old_timeout)
Esempio n. 2
0
 def test_timeout_reset_after_call(self):
     old_timeout = socket.getdefaulttimeout()
     self.stub_urlopen_with_timeout_check(30, None, "url")
     try:
         socket.setdefaulttimeout(1234)
         base_utils.urlopen("url", timeout=30)
         self.assertEquals(1234, socket.getdefaulttimeout())
     finally:
         socket.setdefaulttimeout(old_timeout)
Esempio n. 3
0
def get_sheriffs(lab_only=False):
    """
    Polls the javascript file that holds the identity of the sheriff and
    parses it's output to return a list of chromium sheriff email addresses.
    The javascript file can contain the ldap of more than one sheriff, eg:
    document.write('sheriff_one, sheriff_two').

    @param lab_only: if True, only pulls lab sheriff.
    @return: A list of chroium.org sheriff email addresses to cc on the bug.
             An empty list if failed to parse the javascript.
    """
    sheriff_ids = []
    sheriff_js_list = _LAB_SHERIFF_JS.split(',')
    if not lab_only:
        sheriff_js_list.extend(_SHERIFF_JS.split(','))

    for sheriff_js in sheriff_js_list:
        try:
            url_content = base_utils.urlopen(
                '%s%s' % (_CHROMIUM_BUILD_URL, sheriff_js)).read()
        except (ValueError, IOError) as e:
            logging.warning('could not parse sheriff from url %s%s: %s',
                            _CHROMIUM_BUILD_URL, sheriff_js, str(e))
        except (urllib2.URLError, httplib.HTTPException) as e:
            logging.warning('unexpected error reading from url "%s%s": %s',
                            _CHROMIUM_BUILD_URL, sheriff_js, str(e))
        else:
            ldaps = re.search(r"document.write\('(.*)'\)", url_content)
            if not ldaps:
                logging.warning('Could not retrieve sheriff ldaps for: %s',
                                url_content)
                continue
            sheriff_ids += [
                '*****@*****.**' % alias.replace(' ', '')
                for alias in ldaps.group(1).split(',')
            ]
    return sheriff_ids
Esempio n. 4
0
 def test_args_are_untouched(self):
     self.stub_urlopen_with_timeout_check(30, None, "http://url",
                                          "POST data")
     base_utils.urlopen("http://url", timeout=30, data="POST data")
Esempio n. 5
0
 def test_timeout_set_by_default(self):
     def test_func(timeout):
         self.assertTrue(timeout is not None)
     self.stub_urlopen_with_timeout_comparison(test_func, None, "url")
     base_utils.urlopen("url")
Esempio n. 6
0
 def test_timeout_set_during_call(self):
     self.stub_urlopen_with_timeout_check(30, "retval", "url")
     retval = base_utils.urlopen("url", timeout=30)
     self.assertEquals(retval, "retval")
Esempio n. 7
0
 def test_args_are_untouched(self):
     self.stub_urlopen_with_timeout_check(30, None, "http://url",
                                          "POST data")
     base_utils.urlopen("http://url", timeout=30, data="POST data")
Esempio n. 8
0
    def test_timeout_set_by_default(self):
        def test_func(timeout):
            self.assertTrue(timeout is not None)

        self.stub_urlopen_with_timeout_comparison(test_func, None, "url")
        base_utils.urlopen("url")
Esempio n. 9
0
 def test_timeout_set_during_call(self):
     self.stub_urlopen_with_timeout_check(30, "retval", "url")
     retval = base_utils.urlopen("url", timeout=30)
     self.assertEquals(retval, "retval")