| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 # Copyright 2014 The LUCI Authors. All rights reserved. | 2 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Tasks definition. | 6 """Tasks definition. |
| 7 | 7 |
| 8 Each user request creates a new TaskRequest. The TaskRequest instance saves the | 8 Each user request creates a new TaskRequest. The TaskRequest instance saves the |
| 9 metadata of the request, e.g. who requested it, when why, etc. It links to the | 9 metadata of the request, e.g. who requested it, when why, etc. It links to the |
| 10 actual data of the request in a TaskProperties. The TaskProperties represents | 10 actual data of the request in a TaskProperties. The TaskProperties represents |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 """ | 253 """ |
| 254 # Package name template. May use cipd.ALL_PARAMS. | 254 # Package name template. May use cipd.ALL_PARAMS. |
| 255 # Most users will specify ${platform} parameter. | 255 # Most users will specify ${platform} parameter. |
| 256 package_name = ndb.StringProperty( | 256 package_name = ndb.StringProperty( |
| 257 indexed=False, validator=_validate_package_name_template) | 257 indexed=False, validator=_validate_package_name_template) |
| 258 # Package version that is valid for all packages matched by package_name. | 258 # Package version that is valid for all packages matched by package_name. |
| 259 # Most users will specify tags. | 259 # Most users will specify tags. |
| 260 version = ndb.StringProperty( | 260 version = ndb.StringProperty( |
| 261 indexed=False, validator=_validate_package_version) | 261 indexed=False, validator=_validate_package_version) |
| 262 | 262 |
| 263 def __str__(self): |
| 264 return '%s:%s' % (self.package_name, self.version) |
| 265 |
| 263 def _pre_put_hook(self): | 266 def _pre_put_hook(self): |
| 264 super(CipdPackage, self)._pre_put_hook() | 267 super(CipdPackage, self)._pre_put_hook() |
| 265 if not self.package_name: | 268 if not self.package_name: |
| 266 raise datastore_errors.BadValueError('CIPD package name is required') | 269 raise datastore_errors.BadValueError('CIPD package name is required') |
| 267 if not self.version: | 270 if not self.version: |
| 268 raise datastore_errors.BadValueError('CIPD package version is required') | 271 raise datastore_errors.BadValueError('CIPD package version is required') |
| 269 | 272 |
| 270 | 273 |
| 271 class CipdInput(ndb.Model): | 274 class CipdInput(ndb.Model): |
| 272 """Specifies which CIPD client and packages to install, from which server. | 275 """Specifies which CIPD client and packages to install, from which server. |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 _put_request(request) | 769 _put_request(request) |
| 767 return request | 770 return request |
| 768 | 771 |
| 769 | 772 |
| 770 def validate_priority(priority): | 773 def validate_priority(priority): |
| 771 """Throws ValueError if priority is not a valid value.""" | 774 """Throws ValueError if priority is not a valid value.""" |
| 772 if 0 > priority or MAXIMUM_PRIORITY < priority: | 775 if 0 > priority or MAXIMUM_PRIORITY < priority: |
| 773 raise datastore_errors.BadValueError( | 776 raise datastore_errors.BadValueError( |
| 774 'priority (%d) must be between 0 and %d (inclusive)' % | 777 'priority (%d) must be between 0 and %d (inclusive)' % |
| 775 (priority, MAXIMUM_PRIORITY)) | 778 (priority, MAXIMUM_PRIORITY)) |
| OLD | NEW |