| Index: scripts/slave/recipe_modules/gae_sdk/api.py
|
| diff --git a/scripts/slave/recipe_modules/gae_sdk/api.py b/scripts/slave/recipe_modules/gae_sdk/api.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..addb454ae7dd856506ce239da5e7f72bc86632d4
|
| --- /dev/null
|
| +++ b/scripts/slave/recipe_modules/gae_sdk/api.py
|
| @@ -0,0 +1,78 @@
|
| +# Copyright 2016 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +from recipe_engine import recipe_api
|
| +
|
| +
|
| +class GaeSdkApi(recipe_api.RecipeApi):
|
| +
|
| + PLAT_PYTHON = 'python'
|
| + PLAT_GO = 'go'
|
| +
|
| + # Map of {Platform => {Arch => (base, dirname)}}. Platform names are
|
| + # "recipe_engine/platform" values.
|
| + _PKG_MAP = {
|
| + PLAT_PYTHON: {
|
| + 'all': ('google_appengine_', 'google_appengine'),
|
| + },
|
| + PLAT_GO: {
|
| + 'linux-amd64': ('go_appengine_sdk_linux_amd64-', 'go_appengine'),
|
| + 'linux-386': ('go_appengine_sdk_linux_386-', 'go_appengine'),
|
| + 'mac-amd64': ('go_appengine_sdk_darwin_amd64-', 'go_appengine'),
|
| + },
|
| + }
|
| +
|
| + # Map of architecture bitness to CIPD bitness suffix.
|
| + _BITS_MAP = {
|
| + 64: 'amd64',
|
| + 32: '386',
|
| + }
|
| +
|
| +
|
| + class PackageNotFound(Exception):
|
| + def __init__(self, plat, arch):
|
| + super(GaeSdkApi.PackageNotFound, self).__init__(
|
| + 'Package not found for %s on %s' % (plat, arch))
|
| + self.plat = plat
|
| + self.arch = arch
|
| +
|
| + @property
|
| + def latest_ref(self):
|
| + return 'latest'
|
| +
|
| + def package_spec(self, plat, arch):
|
| + plat_dict = self._PKG_MAP.get(plat, {})
|
| + for a in (arch, 'all'):
|
| + spec = plat_dict.get(a)
|
| + if spec:
|
| + download_base, dirname = spec
|
| + pkg_name = 'infra/gae_sdk/%s/%s' % (plat, a)
|
| + return pkg_name, download_base, dirname
|
| + raise self.PackageNotFound(plat, arch)
|
| +
|
| + def package(self, plat, arch=None):
|
| + arch = arch or '%s-%s' % (
|
| + self.m.platform.name, self._BITS_MAP[self.m.platform.bits])
|
| + pkg_name, _, _ = self.package_spec(plat, arch)
|
| + return pkg_name
|
| +
|
| + @property
|
| + def platforms(self):
|
| + return sorted(self._PKG_MAP.keys())
|
| +
|
| + @property
|
| + def all_packages(self):
|
| + for plat, arch_dict in sorted(self._PKG_MAP.items()):
|
| + for arch in sorted(arch_dict.keys()):
|
| + yield plat, arch
|
| +
|
| + def fetch(self, plat, dst):
|
| + """Fetch the AppEngine SDK for the specified platform.
|
| +
|
| + Args:
|
| + plat (str): platform string, one of the PLAT_ local variables.
|
| + dst (path.Path): The destination directory to extract it.
|
| + """
|
| + pkg = self.package(plat)
|
| + self.m.cipd.ensure(dst, {pkg: self.latest_ref})
|
|
|