Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 """Defines class Rietveld to easily access a rietveld instance. | 5 """Defines class Rietveld to easily access a rietveld instance. |
| 6 | 6 |
| 7 Security implications: | 7 Security implications: |
| 8 | 8 |
| 9 The following hypothesis are made: | 9 The following hypothesis are made: |
| 10 - Rietveld enforces: | 10 - Rietveld enforces: |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 # It's an error message. Return as no result. | 324 # It's an error message. Return as no result. |
| 325 break | 325 break |
| 326 data = json.loads(output) or {} | 326 data = json.loads(output) or {} |
| 327 if not data.get('results'): | 327 if not data.get('results'): |
| 328 break | 328 break |
| 329 for i in data['results']: | 329 for i in data['results']: |
| 330 yield i | 330 yield i |
| 331 cursor = '&cursor=%s' % data['cursor'] | 331 cursor = '&cursor=%s' % data['cursor'] |
| 332 | 332 |
| 333 def trigger_try_jobs( | 333 def trigger_try_jobs( |
| 334 self, issue, patchset, reason, clobber, revision, builders_and_tests): | 334 self, issue, patchset, reason, clobber, revision, masters): |
|
Paweł Hajdan Jr.
2014/02/27 02:20:24
CQ relies on trigger_try_jobs working the way it w
Michael Achenbach
2014/02/27 18:35:23
Done. As soon as CQ is going to call the new metho
| |
| 335 """Requests new try jobs. | 335 """Requests new try jobs. |
| 336 | 336 |
| 337 |builders_and_tests| is a map of builders: [tests] to run. | 337 |masters| is a map of masters: map of builders: [tests] to run. |
| 338 | 338 |
| 339 Returns the keys of the new TryJobResult entites. | 339 Returns the keys of the new TryJobResult entites. |
| 340 """ | 340 """ |
| 341 params = [ | 341 for (master, builders_and_tests) in masters.iteritems(): |
| 342 ('reason', reason), | 342 params = [ |
| 343 ('clobber', 'True' if clobber else 'False'), | 343 ('reason', reason), |
| 344 ('builders', json.dumps(builders_and_tests)), | 344 ('clobber', 'True' if clobber else 'False'), |
| 345 ('xsrf_token', self.xsrf_token()), | 345 ('builders', json.dumps(builders_and_tests)), |
| 346 ] | 346 ('xsrf_token', self.xsrf_token()), |
| 347 if revision: | 347 ] |
| 348 params.append(('revision', revision)) | 348 if revision: |
| 349 return self.post('/%d/try/%d' % (issue, patchset), params) | 349 params.append(('revision', revision)) |
| 350 if master: | |
| 351 # Temporarily allow empty master names for old configurations. The try | |
| 352 # job will not be associated with a master name on rietveld. This is | |
| 353 # going to be deprecated. | |
| 354 params.append(('master', master)) | |
| 355 self.post('/%d/try/%d' % (issue, patchset), params) | |
| 350 | 356 |
| 351 def get_pending_try_jobs(self, cursor=None, limit=100): | 357 def get_pending_try_jobs(self, cursor=None, limit=100): |
| 352 """Retrieves the try job requests in pending state. | 358 """Retrieves the try job requests in pending state. |
| 353 | 359 |
| 354 Returns a tuple of the list of try jobs and the cursor for the next request. | 360 Returns a tuple of the list of try jobs and the cursor for the next request. |
| 355 """ | 361 """ |
| 356 url = '/get_pending_try_patchsets?limit=%d' % limit | 362 url = '/get_pending_try_patchsets?limit=%d' % limit |
| 357 extra = ('&cursor=' + cursor) if cursor else '' | 363 extra = ('&cursor=' + cursor) if cursor else '' |
| 358 data = json.loads(self.get(url + extra)) | 364 data = json.loads(self.get(url + extra)) |
| 359 return data['jobs'], data['cursor'] | 365 return data['jobs'], data['cursor'] |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 add_as_reviewer=False): | 538 add_as_reviewer=False): |
| 533 logging.info('ReadOnlyRietveld: posting comment "%s" to issue %d' % | 539 logging.info('ReadOnlyRietveld: posting comment "%s" to issue %d' % |
| 534 (message, issue)) | 540 (message, issue)) |
| 535 | 541 |
| 536 def set_flag(self, issue, patchset, flag, value): # pylint:disable=R0201 | 542 def set_flag(self, issue, patchset, flag, value): # pylint:disable=R0201 |
| 537 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % | 543 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % |
| 538 (flag, value, issue)) | 544 (flag, value, issue)) |
| 539 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value | 545 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value |
| 540 | 546 |
| 541 def trigger_try_jobs( # pylint:disable=R0201 | 547 def trigger_try_jobs( # pylint:disable=R0201 |
| 542 self, issue, patchset, reason, clobber, revision, builders_and_tests): | 548 self, issue, patchset, reason, clobber, revision, masters): |
| 543 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 549 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 544 (builders_and_tests, issue)) | 550 (masters, issue)) |
| OLD | NEW |