| 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 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 def _fetch_revision_to_build_map(self): | 136 def _fetch_revision_to_build_map(self): |
| 137 # All _fetch requests go through _buildbot for easier mocking | 137 # All _fetch requests go through _buildbot for easier mocking |
| 138 # FIXME: This should use NetworkTransaction's 404 handling instead. | 138 # FIXME: This should use NetworkTransaction's 404 handling instead. |
| 139 try: | 139 try: |
| 140 # FIXME: This method is horribly slow due to the huge network load. | 140 # FIXME: This method is horribly slow due to the huge network load. |
| 141 # FIXME: This is a poor way to do revision -> build mapping. | 141 # FIXME: This is a poor way to do revision -> build mapping. |
| 142 # Better would be to ask buildbot through some sort of API. | 142 # Better would be to ask buildbot through some sort of API. |
| 143 _log.info("Loading revision/build list from %s." % self.results_url(
)) | 143 _log.info("Loading revision/build list from %s." % self.results_url(
)) |
| 144 _log.info("This may take a while...") | 144 _log.info("This may take a while...") |
| 145 result_files = self._buildbot._fetch_twisted_directory_listing(self.
results_url()) | 145 result_files = self._buildbot._fetch_twisted_directory_listing(self.
results_url()) |
| 146 except urllib2.HTTPError, error: | 146 except urllib2.HTTPError as error: |
| 147 if error.code != 404: | 147 if error.code != 404: |
| 148 raise | 148 raise |
| 149 _log.debug("Revision/build list failed to load.") | 149 _log.debug("Revision/build list failed to load.") |
| 150 result_files = [] | 150 result_files = [] |
| 151 return dict(self._file_info_list_to_revision_to_build_list(result_files)
) | 151 return dict(self._file_info_list_to_revision_to_build_list(result_files)
) |
| 152 | 152 |
| 153 def _file_info_list_to_revision_to_build_list(self, file_info_list): | 153 def _file_info_list_to_revision_to_build_list(self, file_info_list): |
| 154 # This assumes there was only one build per revision, which is false but
we don't care for now. | 154 # This assumes there was only one build per revision, which is false but
we don't care for now. |
| 155 revisions_and_builds = [] | 155 revisions_and_builds = [] |
| 156 for file_info in file_info_list: | 156 for file_info in file_info_list: |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 # FIXME: These _fetch methods should move to a networking class. | 282 # FIXME: These _fetch methods should move to a networking class. |
| 283 def _fetch_build_dictionary(self, builder, build_number): | 283 def _fetch_build_dictionary(self, builder, build_number): |
| 284 # Note: filter=1 will remove None and {} and '', which cuts noise but ca
n | 284 # Note: filter=1 will remove None and {} and '', which cuts noise but ca
n |
| 285 # cause keys to be missing which you might otherwise expect. | 285 # cause keys to be missing which you might otherwise expect. |
| 286 # FIXME: The bot sends a *huge* amount of data for each request, we shou
ld | 286 # FIXME: The bot sends a *huge* amount of data for each request, we shou
ld |
| 287 # find a way to reduce the response size further. | 287 # find a way to reduce the response size further. |
| 288 buildbot_url = config_urls.chromium_buildbot_url(builder.master_name()) | 288 buildbot_url = config_urls.chromium_buildbot_url(builder.master_name()) |
| 289 json_url = "%s/json/builders/%s/builds/%s?filter=1" % (buildbot_url, url
lib.quote(builder.name()), build_number) | 289 json_url = "%s/json/builders/%s/builds/%s?filter=1" % (buildbot_url, url
lib.quote(builder.name()), build_number) |
| 290 try: | 290 try: |
| 291 return json.load(urllib2.urlopen(json_url)) | 291 return json.load(urllib2.urlopen(json_url)) |
| 292 except urllib2.URLError, err: | 292 except urllib2.URLError as err: |
| 293 build_url = Build.build_url(builder, build_number) | 293 build_url = Build.build_url(builder, build_number) |
| 294 _log.error("Error fetching data for %s build %s (%s, json: %s): %s"
% | 294 _log.error("Error fetching data for %s build %s (%s, json: %s): %s"
% |
| 295 (builder.name(), build_number, build_url, json_url, err)) | 295 (builder.name(), build_number, build_url, json_url, err)) |
| 296 return None | 296 return None |
| 297 except ValueError, err: | 297 except ValueError as err: |
| 298 build_url = Build.build_url(builder, build_number) | 298 build_url = Build.build_url(builder, build_number) |
| 299 _log.error("Error decoding json data from %s: %s" % (build_url, err)
) | 299 _log.error("Error decoding json data from %s: %s" % (build_url, err)
) |
| 300 return None | 300 return None |
| 301 | 301 |
| 302 def _file_cell_text(self, file_cell): | 302 def _file_cell_text(self, file_cell): |
| 303 """Traverses down through firstChild elements until one containing a str
ing is found, then returns that string""" | 303 """Traverses down through firstChild elements until one containing a str
ing is found, then returns that string""" |
| 304 element = file_cell | 304 element = file_cell |
| 305 while element.string is None and element.contents: | 305 while element.string is None and element.contents: |
| 306 element = element.contents[0] | 306 element = element.contents[0] |
| 307 return element.string | 307 return element.string |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 if not revision_statuses[future_revision]: | 398 if not revision_statuses[future_revision]: |
| 399 break | 399 break |
| 400 builders_succeeded_in_future = builders_succeeded_in_future.unio
n(revision_statuses[future_revision]) | 400 builders_succeeded_in_future = builders_succeeded_in_future.unio
n(revision_statuses[future_revision]) |
| 401 | 401 |
| 402 builders_succeeded_in_past = set() | 402 builders_succeeded_in_past = set() |
| 403 for past_revision in revisions_in_order[i:]: | 403 for past_revision in revisions_in_order[i:]: |
| 404 if not revision_statuses[past_revision]: | 404 if not revision_statuses[past_revision]: |
| 405 break | 405 break |
| 406 builders_succeeded_in_past = builders_succeeded_in_past.union(re
vision_statuses[past_revision]) | 406 builders_succeeded_in_past = builders_succeeded_in_past.union(re
vision_statuses[past_revision]) |
| 407 | 407 |
| 408 if len(builders_succeeded_in_future) == len(builder_revisions) and l
en(builders_succeeded_in_past) == len(builder_revisions): | 408 if len(builders_succeeded_in_future) == len(builder_revisions) and l
en( |
| 409 builders_succeeded_in_past) == len(builder_revisions): |
| 409 return revision | 410 return revision |
| 410 return None | 411 return None |
| OLD | NEW |