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

Side by Side Diff: appengine/cr-buildbucket/service.py

Issue 1877083003: buildbucket: add retry API. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « appengine/cr-buildbucket/api.py ('k') | appengine/cr-buildbucket/test/api_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 import datetime 5 import datetime
6 import logging 6 import logging
7 import urlparse 7 import urlparse
8 8
9 from google.appengine.api import taskqueue 9 from google.appengine.api import taskqueue
10 from google.appengine.api import modules 10 from google.appengine.api import modules
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if client_operation_id is not None: 175 if client_operation_id is not None:
176 yield ctx.memcache_set(client_operation_cache_key, build.key.id(), 60) 176 yield ctx.memcache_set(client_operation_cache_key, build.key.id(), 60)
177 raise ndb.Return(build) 177 raise ndb.Return(build)
178 178
179 179
180 def add(*args, **kwargs): 180 def add(*args, **kwargs):
181 """Sync version of add_async.""" 181 """Sync version of add_async."""
182 return add_async(*args, **kwargs).get_result() 182 return add_async(*args, **kwargs).get_result()
183 183
184 184
185 def retry(
186 build_id, lease_expiration_date=None, client_operation_id=None,
187 pubsub_callback=None):
188 """Adds a build with same bucket, parameters and tags as the given one."""
189 build = model.Build.get_by_id(build_id)
190 if not build:
191 raise errors.BuildNotFoundError('Build %s not found' % build_id)
192 return add(
Vadim Sh. 2016/04/11 23:30:10 does it make sense to add some sort of a "backlink
nodir 2016/04/11 23:57:36 Done
193 build.bucket,
194 tags=build.tags,
195 parameters=build.parameters,
196 lease_expiration_date=lease_expiration_date,
197 client_operation_id=client_operation_id,
198 pubsub_callback=pubsub_callback,
199 )
200
201
185 def get(build_id): 202 def get(build_id):
186 """Gets a build by |build_id|. 203 """Gets a build by |build_id|.
187 204
188 Requires the current user to have permissions to view the build. 205 Requires the current user to have permissions to view the build.
189 """ 206 """
190 build = model.Build.get_by_id(build_id) 207 build = model.Build.get_by_id(build_id)
191 if not build: 208 if not build:
192 return None 209 return None
193 if not acl.can_view_build(build): 210 if not acl.can_view_build(build):
194 raise current_identity_cannot('view build %s', build.key.id()) 211 raise current_identity_cannot('view build %s', build.key.id())
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 if isinstance(identity, basestring): 794 if isinstance(identity, basestring):
778 if not identity: # pragma: no cover 795 if not identity: # pragma: no cover
779 return None 796 return None
780 if ':' not in identity: # pragma: no branch 797 if ':' not in identity: # pragma: no branch
781 identity = 'user:%s' % identity 798 identity = 'user:%s' % identity
782 try: 799 try:
783 identity = auth.Identity.from_bytes(identity) 800 identity = auth.Identity.from_bytes(identity)
784 except ValueError as ex: 801 except ValueError as ex:
785 raise errors.InvalidInputError('Invalid identity identity: %s' % ex) 802 raise errors.InvalidInputError('Invalid identity identity: %s' % ex)
786 return identity 803 return identity
OLDNEW
« no previous file with comments | « appengine/cr-buildbucket/api.py ('k') | appengine/cr-buildbucket/test/api_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698