Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Utility functions to communicate with Rietveld.""" | 5 """Utility functions to communicate with Rietveld.""" |
| 6 | 6 |
| 7 import collections | 7 import collections |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import urllib2 | 10 import urllib2 |
| 11 | 11 |
| 12 | 12 |
| 13 _log = logging.getLogger(__name__) | 13 _log = logging.getLogger(__name__) |
| 14 | 14 |
| 15 BASE_CODEREVIEW_URL = 'https://codereview.chromium.org/api' | 15 BASE_CODEREVIEW_URL = 'https://codereview.chromium.org/api' |
| 16 | 16 |
| 17 TryJob = collections.namedtuple('TryJob', ('builder_name', 'master_name', 'build _number')) | 17 TryJob = collections.namedtuple('TryJob', ('builder_name', 'master_name', 'build _number')) |
| 18 | 18 TryJobResults = collections.namedtuple('TryJob', ('builder_name', 'result')) |
|
qyearsley
2016/06/29 17:37:56
Since it represents one single job's result, TryJo
| |
| 19 | 19 |
| 20 def latest_try_jobs(issue_number, builder_names, web, patchset_number=None): | 20 def latest_try_jobs(issue_number, builder_names, web, patchset_number=None): |
| 21 """Returns a list of TryJob objects for jobs on the latest patchset. | 21 """Returns a list of TryJob objects for jobs on the latest patchset. |
| 22 | 22 |
| 23 Args: | 23 Args: |
| 24 issue_number: A Rietveld issue number. | 24 issue_number: A Rietveld issue number. |
| 25 builder_names: Builders that we're interested in; try jobs for only | 25 builder_names: Builders that we're interested in; try jobs for only |
| 26 these builders will be listed. | 26 these builders will be listed. |
| 27 web: webkitpy.common.net.web.Web object (which can be mocked out). | 27 web: webkitpy.common.net.web.Web object (which can be mocked out). |
| 28 patchset_number: Use a specific patchset instead of the latest one. | 28 patchset_number: Use a specific patchset instead of the latest one. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 _log.error('Invalid JSON: %s' % contents) | 73 _log.error('Invalid JSON: %s' % contents) |
| 74 raise | 74 raise |
| 75 | 75 |
| 76 | 76 |
| 77 def _issue_url(issue_number): | 77 def _issue_url(issue_number): |
| 78 return '%s/%s' % (BASE_CODEREVIEW_URL, issue_number) | 78 return '%s/%s' % (BASE_CODEREVIEW_URL, issue_number) |
| 79 | 79 |
| 80 | 80 |
| 81 def _patchset_url(issue_number, patchset_number): | 81 def _patchset_url(issue_number, patchset_number): |
| 82 return '%s/%s' % (_issue_url(issue_number), patchset_number) | 82 return '%s/%s' % (_issue_url(issue_number), patchset_number) |
| 83 | |
| 84 | |
| 85 def get_latest_tryjob_results(issue_number, web): | |
|
qyearsley
2016/06/29 17:37:56
In the official documentation, "try job" is two wo
| |
| 86 url = _latest_patchset_url(issue_number, web) | |
| 87 patchset_data = _get_json(url, web) | |
| 88 results = [] | |
| 89 for job in patchset_data['try_job_results']: | |
| 90 results.append(TryJobResults( | |
| 91 builder_name=job['builder'], | |
| 92 result=job['result'])) | |
| 93 return results | |
|
qyearsley
2016/06/29 17:37:56
Alternatively, if you are just having builders and
| |
| OLD | NEW |