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

Side by Side Diff: scripts/slave/recipe_modules/gae_sdk/api.py

Issue 2355483004: Add CIPD GAE SDK recipe module and packager. (Closed)
Patch Set: pylint Created 4 years, 2 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
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from recipe_engine import recipe_api
6
7
8 class GaeSdkApi(recipe_api.RecipeApi):
9
10 PLAT_PYTHON = 'python'
11 PLAT_GO = 'go'
12
13 # Map of {Platform => {Arch => (base, dirname)}}. Platform names are
14 # "recipe_engine/platform" values.
15 _PKG_MAP = {
16 PLAT_PYTHON: {
17 'all': ('google_appengine_', 'google_appengine'),
18 },
19 PLAT_GO: {
20 'linux-amd64': ('go_appengine_sdk_linux_amd64-', 'go_appengine'),
21 'linux-386': ('go_appengine_sdk_linux_386-', 'go_appengine'),
22 'mac-amd64': ('go_appengine_sdk_darwin_amd64-', 'go_appengine'),
23 },
24 }
25
26 # Map of architecture bitness to CIPD bitness suffix.
27 _BITS_MAP = {
28 64: 'amd64',
29 32: '386',
30 }
31
32
33 class PackageNotFound(Exception):
34 def __init__(self, plat, arch):
35 super(GaeSdkApi.PackageNotFound, self).__init__(
36 'Package not found for %s on %s' % (plat, arch))
37 self.plat = plat
38 self.arch = arch
39
40 @property
41 def latest_ref(self):
42 return 'latest'
43
44 def package_spec(self, plat, arch):
45 plat_dict = self._PKG_MAP.get(plat, {})
46 for a in (arch, 'all'):
47 spec = plat_dict.get(a)
48 if spec:
49 download_base, dirname = spec
50 pkg_name = 'infra/gae_sdk/%s/%s' % (plat, a)
51 return pkg_name, download_base, dirname
52 raise self.PackageNotFound(plat, arch)
53
54 def package(self, plat, arch=None):
55 arch = arch or '%s-%s' % (
56 self.m.platform.name, self._BITS_MAP[self.m.platform.bits])
57 pkg_name, _, _ = self.package_spec(plat, arch)
58 return pkg_name
59
60 @property
61 def platforms(self):
62 return sorted(self._PKG_MAP.keys())
63
64 @property
65 def all_packages(self):
66 for plat, arch_dict in sorted(self._PKG_MAP.items()):
67 for arch in sorted(arch_dict.keys()):
68 yield plat, arch
69
70 def fetch(self, plat, dst):
71 """Fetch the AppEngine SDK for the specified platform.
72
73 Args:
74 plat (str): platform string, one of the PLAT_ local variables.
75 dst (path.Path): The destination directory to extract it.
76 """
77 pkg = self.package(plat)
78 self.m.cipd.ensure(dst, {pkg: self.latest_ref})
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/gae_sdk/__init__.py ('k') | scripts/slave/recipe_modules/gae_sdk/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698