Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 """Implementation of package repository service. | 5 """Implementation of package repository service. |
| 6 | 6 |
| 7 Package and PackageInstance | 7 Package and PackageInstance |
| 8 --------------------------- | 8 --------------------------- |
| 9 | 9 |
| 10 Definitions: | 10 Definitions: |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 """Returns Package entity if it exists. | 158 """Returns Package entity if it exists. |
| 159 | 159 |
| 160 Args: | 160 Args: |
| 161 package_name: name of the package, e.g. 'infra/tools/cipd'. | 161 package_name: name of the package, e.g. 'infra/tools/cipd'. |
| 162 | 162 |
| 163 Returns: | 163 Returns: |
| 164 Package or None. | 164 Package or None. |
| 165 """ | 165 """ |
| 166 return package_key(package_name).get() | 166 return package_key(package_name).get() |
| 167 | 167 |
| 168 def list_packages(self, prefix): | |
| 169 """Returns list of Packages with the given prefix. | |
| 170 | |
| 171 Args: | |
| 172 prefix: string prefix of the packages to list. | |
| 173 | |
| 174 Returns: | |
| 175 [Package, ...]. | |
| 176 """ | |
| 177 query = Package.query().order(Package.key) | |
| 178 | |
| 179 # Only apply the filtering if a prefix was given. The empty string isn't a | |
| 180 # valid key and will result in an exception. | |
| 181 if prefix: | |
| 182 query = query.filter( | |
| 183 # Prefix match using the operators available to us. Packages can only | |
| 184 # contain lowercase ascii, numbers, and '/' so '\uffff' will always | |
| 185 # be larger. | |
| 186 ndb.AND(Package.key >= ndb.Key(Package, prefix), | |
|
Vadim Sh.
2015/06/19 21:12:03
this thing may require additional composite index
estaab
2015/06/20 02:25:25
Sounds good.
| |
| 187 Package.key <= ndb.Key(Package, prefix + u'\uffff'))) | |
| 188 pkgs = [] | |
| 189 for pkg in query: | |
|
Vadim Sh.
2015/06/19 21:12:03
use keys_only=True query and extract package_name
estaab
2015/06/20 02:25:25
Done.
| |
| 190 pkgs.append(pkg.package_name) | |
| 191 return pkgs | |
|
Vadim Sh.
2015/06/19 21:12:03
return sorted(pkgs)
estaab
2015/06/20 02:25:25
Done
| |
| 192 | |
| 168 def get_processing_result(self, package_name, instance_id, processor_name): | 193 def get_processing_result(self, package_name, instance_id, processor_name): |
| 169 """Returns results of some asynchronous processor or None if not ready. | 194 """Returns results of some asynchronous processor or None if not ready. |
| 170 | 195 |
| 171 Args: | 196 Args: |
| 172 package_name: name of the package, e.g. 'infra/tools/cipd'. | 197 package_name: name of the package, e.g. 'infra/tools/cipd'. |
| 173 instance_id: identifier of the package instance (SHA1 of package file). | 198 instance_id: identifier of the package instance (SHA1 of package file). |
| 174 processor_name: name of the processor to retrieve results of. | 199 processor_name: name of the processor to retrieve results of. |
| 175 | 200 |
| 176 Returns: | 201 Returns: |
| 177 ProcessingResult entity or None. | 202 ProcessingResult entity or None. |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 779 processors=payload['processors']) | 804 processors=payload['processors']) |
| 780 | 805 |
| 781 | 806 |
| 782 def get_backend_routes(): # pragma: no cover | 807 def get_backend_routes(): # pragma: no cover |
| 783 """Returns a list of webapp2.Route to add to backend WSGI app.""" | 808 """Returns a list of webapp2.Route to add to backend WSGI app.""" |
| 784 return [ | 809 return [ |
| 785 webapp2.Route( | 810 webapp2.Route( |
| 786 r'/internal/taskqueue/cipd-process/<instance_id:.+>', | 811 r'/internal/taskqueue/cipd-process/<instance_id:.+>', |
| 787 ProcessTaskQueueHandler), | 812 ProcessTaskQueueHandler), |
| 788 ] | 813 ] |
| OLD | NEW |