| OLD | NEW |
| 1 # Copyright (c) 2009, Google Inc. All rights reserved. | 1 # Copyright (c) 2009, Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| 11 # in the documentation and/or other materials provided with the | 11 # in the documentation and/or other materials provided with the |
| 12 # distribution. | 12 # distribution. |
| 13 # * Neither the name of Google Inc. nor the names of its | 13 # * Neither the name of Google Inc. nor the names of its |
| 14 # contributors may be used to endorse or promote products derived from | 14 # contributors may be used to endorse or promote products derived from |
| 15 # this software without specific prior written permission. | 15 # this software without specific prior written permission. |
| 16 # | 16 # |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import collections |
| 29 import re | 30 import re |
| 30 import urllib2 | 31 import urllib2 |
| 31 | 32 |
| 32 from webkitpy.common.memoized import memoized | 33 from webkitpy.common.memoized import memoized |
| 33 from webkitpy.common.net.layouttestresults import LayoutTestResults | 34 from webkitpy.common.net.layouttestresults import LayoutTestResults |
| 34 from webkitpy.common.net.networktransaction import NetworkTransaction | 35 from webkitpy.common.net.networktransaction import NetworkTransaction |
| 35 from webkitpy.common.system.logutils import get_logger | 36 from webkitpy.common.system.logutils import get_logger |
| 36 | 37 |
| 37 | 38 |
| 38 RESULTS_URL_BASE = 'https://storage.googleapis.com/chromium-layout-test-archives
' | 39 RESULTS_URL_BASE = 'https://storage.googleapis.com/chromium-layout-test-archives
' |
| 39 | 40 |
| 40 _log = get_logger(__file__) | 41 _log = get_logger(__file__) |
| 41 | 42 |
| 42 | 43 |
| 44 class Build(collections.namedtuple('TryJob', ('builder_name', 'build_number'))): |
| 45 """Represents a combination of builder and build number. |
| 46 |
| 47 If build number is None, this represents the latest build |
| 48 for a given builder. |
| 49 """ |
| 50 def __new__(cls, builder_name, build_number=None): |
| 51 return super(Build, cls).__new__(cls, builder_name, build_number) |
| 52 |
| 53 |
| 43 class BuildBot(object): | 54 class BuildBot(object): |
| 44 """This class represents an interface to BuildBot-related functionality. | 55 """This class represents an interface to BuildBot-related functionality. |
| 45 | 56 |
| 46 This includes fetching layout test results from Google Storage; | 57 This includes fetching layout test results from Google Storage; |
| 47 for more information about the layout test result format, see: | 58 for more information about the layout test result format, see: |
| 48 https://www.chromium.org/developers/the-json-test-results-format | 59 https://www.chromium.org/developers/the-json-test-results-format |
| 49 """ | 60 """ |
| 50 | 61 |
| 51 def results_url(self, builder_name, build_number=None): | 62 def results_url(self, builder_name, build_number=None): |
| 52 """Returns a URL for one set of archived layout test results. | 63 """Returns a URL for one set of archived layout test results. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 101 |
| 91 def _fetch_file_from_results(self, results_url, file_name): | 102 def _fetch_file_from_results(self, results_url, file_name): |
| 92 # It seems this can return None if the url redirects and then returns 40
4. | 103 # It seems this can return None if the url redirects and then returns 40
4. |
| 93 # FIXME: This could use Web instead of using urllib2 directly. | 104 # FIXME: This could use Web instead of using urllib2 directly. |
| 94 result = urllib2.urlopen("%s/%s" % (results_url, file_name)) | 105 result = urllib2.urlopen("%s/%s" % (results_url, file_name)) |
| 95 if not result: | 106 if not result: |
| 96 return None | 107 return None |
| 97 # urlopen returns a file-like object which sometimes works fine with str
() | 108 # urlopen returns a file-like object which sometimes works fine with str
() |
| 98 # but sometimes is a addinfourl object. In either case calling read() i
s correct. | 109 # but sometimes is a addinfourl object. In either case calling read() i
s correct. |
| 99 return result.read() | 110 return result.read() |
| OLD | NEW |