Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: rietveld.py

Issue 10920061: Add function to trigger try jobs on Rietveld. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Change get_pending_try_jobs() Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 if output.startswith('<'): 296 if output.startswith('<'):
297 # It's an error message. Return as no result. 297 # It's an error message. Return as no result.
298 break 298 break
299 data = json.loads(output) or {} 299 data = json.loads(output) or {}
300 if not data.get('results'): 300 if not data.get('results'):
301 break 301 break
302 for i in data['results']: 302 for i in data['results']:
303 yield i 303 yield i
304 cursor = '&cursor=%s' % data['cursor'] 304 cursor = '&cursor=%s' % data['cursor']
305 305
306 def trigger_try_jobs(
307 self, issue, patchset, reason, clobber, revision, builders_and_tests):
308 """Requests new try jobs.
309
310 |builders_and_tests| is a map of builders: [tests] to run.
311
312 Returns the keys of the new TryJobResult entites.
313 """
314 params = [
315 ('reason', reason),
316 ('clobber', 'True' if clobber else 'False'),
317 ('revision', revision if revision else 'HEAD'),
318 ('builders', json.dumps(builders_and_tests)),
319 ('xsrf_token', self.xsrf_token()),
320 ]
321 return self.post('/%d/try/%d' % (issue, patchset), params)
322
323 def get_pending_try_jobs(self, cursor=None, limit=100):
324 """Retrieves the try job requests in pending state.
325
326 Returns a tuple of the list of try jobs and the cursor for the next request.
327 """
328 url = '/get_pending_try_patchsets?limit=%d' % limit
329 extra = ('&cursor=' + cursor) if cursor else ''
330 data = json.loads(self.get(url + extra))
331 return data['jobs'], data['cursor']
332
306 def get(self, request_path, **kwargs): 333 def get(self, request_path, **kwargs):
307 kwargs.setdefault('payload', None) 334 kwargs.setdefault('payload', None)
308 return self._send(request_path, **kwargs) 335 return self._send(request_path, **kwargs)
309 336
310 def post(self, request_path, data, **kwargs): 337 def post(self, request_path, data, **kwargs):
311 ctype, body = upload.EncodeMultipartFormData(data, []) 338 ctype, body = upload.EncodeMultipartFormData(data, [])
312 return self._send(request_path, payload=body, content_type=ctype, **kwargs) 339 return self._send(request_path, payload=body, content_type=ctype, **kwargs)
313 340
314 def _send(self, request_path, **kwargs): 341 def _send(self, request_path, **kwargs):
315 """Sends a POST/GET to Rietveld. Returns the response body.""" 342 """Sends a POST/GET to Rietveld. Returns the response body."""
(...skipping 29 matching lines...) Expand all
345 if not 'Name or service not known' in e.reason: 372 if not 'Name or service not known' in e.reason:
346 # Usually internal GAE flakiness. 373 # Usually internal GAE flakiness.
347 raise 374 raise
348 # If reaching this line, loop again. Uses a small backoff. 375 # If reaching this line, loop again. Uses a small backoff.
349 time.sleep(1+maxtries*2) 376 time.sleep(1+maxtries*2)
350 finally: 377 finally:
351 upload.ErrorExit = old_error_exit 378 upload.ErrorExit = old_error_exit
352 379
353 # DEPRECATED. 380 # DEPRECATED.
354 Send = get 381 Send = get
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698