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

Side by Side Diff: build/download_sdk_extras.py

Issue 709663002: Add gclient hook to download SDK extras on bots. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: is_buildbot_checkout -> is_android_buildbot_checkout Created 6 years 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 | « DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Script to download sdk/extras packages on the bots from google storage.
7
8 The script expects an argument that specifies the packet name in the following
9 format: <dir_in_sdk_extras>_<package_name>_<version>. There will be a
cjhopman 2014/12/30 19:32:52 this comment implies that I can have underscores i
10 correpsonding bucket in google storage with that name, and it will be downloaded
cjhopman 2014/12/30 19:32:52 nit: correpsonding/corresponding
11 to android_tools/sdk/extras/.
12 """
13
14 import os
15 import subprocess
16 import sys
17
18 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'android'))
19 from pylib import constants
20
21 GSUTIL_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
22 os.pardir, os.pardir, os.pardir, os.pardir, 'depot_tools', 'gsutil.py')
23 SDK_EXTRAS_BUCKET = 'gs://chrome-sdk-extras'
24 SDK_EXTRAS_PATH = os.path.join(constants.ANDROID_SDK_ROOT, 'extras')
25
26
27 def GetCmdOutputAndStatus(cmd_lst):
28 process = subprocess.Popen(cmd_lst, stdout=subprocess.PIPE)
29 stdout, _ = process.communicate()
30 return stdout, process.returncode
31
32 def is_android_buildbot_checkout():
33 if not os.path.exists(GSUTIL_PATH) or not os.path.exists(SDK_EXTRAS_PATH):
34 return False
35 stdout, rc = GetCmdOutputAndStatus([GSUTIL_PATH, 'ls', SDK_EXTRAS_BUCKET])
36 # If successfully read bucket, then this must be a bot with permissions
37 return not rc
38
39 def main(args):
40 if is_android_buildbot_checkout():
41 success = True
42 for arg in args[1:]:
43 # Package is named <folder>_<package_name>_<version>
44 first_underscore = arg.find('_')
cjhopman 2014/12/30 19:32:52 should this use a different separator that wouldn'
45 last_underscore = arg.rfind('_')
46 folder = arg[0:first_underscore]
47 package = arg[first_underscore+1:last_underscore]
48 # Package bucket is <SDK_EXTRAS_BUCKET>/<folder>_<package_name>_<version>
49 # and in that bucket will be the directory <folder>/<package_name> to cp.
50 package_bucket = '%s/%s/%s/%s' % (SDK_EXTRAS_BUCKET, arg, folder, package)
cjhopman 2014/12/30 19:32:52 This with the comment above is a little confusing
51 package_dir = '%s/%s/%s' % (SDK_EXTRAS_PATH, folder, package)
52 if not os.path.exists(package_dir):
53 os.makedirs(package_dir)
54 # rsync is only supported by gsutil version 4.x
55 cmd_lst = [GSUTIL_PATH, '--force-version', '4.6', '-m', 'rsync', '-r',
56 '-d', package_bucket, package_dir]
57 stdout, rc = GetCmdOutputAndStatus(cmd_lst)
cjhopman 2014/12/30 19:32:52 how about just: stdout = subprocess.check_output(
58 success = (rc == 0) and success
59 if not success:
60 return 1
61 return 0
62
63
64 if __name__ == '__main__':
65 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698