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

Side by Side Diff: build/download_sdk_extras.py

Issue 934753007: Use CHROME_HEADLESS to check if download_sdk_extras.py is running on a bot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call gsutil.py with python for windows. Created 5 years, 10 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
« no previous file with comments | « no previous file | 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Script to download sdk/extras packages on the bots from google storage. 6 """Script to download sdk/extras packages on the bots from google storage.
7 7
8 The script expects arguments that specify zips file in the google storage 8 The script expects arguments that specify zips file in the google storage
9 bucket named: <dir in SDK extras>_<package name>_<version>.zip. The file will 9 bucket named: <dir in SDK extras>_<package name>_<version>.zip. The file will
10 be extracted in the android_tools/sdk/extras directory. 10 be extracted in the android_tools/sdk/extras directory on the test bots. This
11 script will not do anything for developers.
11 """ 12 """
12 13
13 import json 14 import json
14 import os 15 import os
15 import shutil 16 import shutil
16 import subprocess 17 import subprocess
17 import sys 18 import sys
18 import zipfile 19 import zipfile
19 20
20 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'android')) 21 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
22 CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
23 sys.path.insert(0, os.path.join(SCRIPT_DIR, 'android'))
24 sys.path.insert(1, os.path.join(CHROME_SRC, 'tools'))
25
21 from pylib import constants 26 from pylib import constants
27 import find_depot_tools
22 28
23 GSUTIL_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 29 DEPOT_PATH = find_depot_tools.add_depot_tools_to_path()
24 os.pardir, os.pardir, os.pardir, os.pardir, 'depot_tools', 'gsutil.py') 30 GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py')
25 SDK_EXTRAS_BUCKET = 'gs://chrome-sdk-extras' 31 SDK_EXTRAS_BUCKET = 'gs://chrome-sdk-extras'
26 SDK_EXTRAS_PATH = os.path.join(constants.ANDROID_SDK_ROOT, 'extras') 32 SDK_EXTRAS_PATH = os.path.join(constants.ANDROID_SDK_ROOT, 'extras')
27 SDK_EXTRAS_JSON_FILE = os.path.join(os.path.dirname(__file__), 33 SDK_EXTRAS_JSON_FILE = os.path.join(os.path.dirname(__file__),
28 'android_sdk_extras.json') 34 'android_sdk_extras.json')
29 35
30 36
31 def clean_and_extract(dir_name, package_name, zip_file): 37 def clean_and_extract(dir_name, package_name, zip_file):
32 local_dir = '%s/%s/%s' % (SDK_EXTRAS_PATH, dir_name, package_name) 38 local_dir = '%s/%s/%s' % (SDK_EXTRAS_PATH, dir_name, package_name)
33 if os.path.exists(local_dir): 39 if os.path.exists(local_dir):
34 shutil.rmtree(local_dir) 40 shutil.rmtree(local_dir)
35 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, zip_file) 41 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, zip_file)
36 with zipfile.ZipFile(local_zip) as z: 42 with zipfile.ZipFile(local_zip) as z:
37 z.extractall(path=SDK_EXTRAS_PATH) 43 z.extractall(path=SDK_EXTRAS_PATH)
38 44
39 45
40 def main(): 46 def main():
41 if not os.path.exists(GSUTIL_PATH) or not os.path.exists(SDK_EXTRAS_PATH): 47 if not os.environ.get('CHROME_HEADLESS'):
42 # This is not a buildbot checkout. 48 # This is not a buildbot checkout.
43 return 0 49 return 0
44 # Update the android_sdk_extras.json file to update downloaded packages. 50 # Update the android_sdk_extras.json file to update downloaded packages.
45 with open(SDK_EXTRAS_JSON_FILE) as json_file: 51 with open(SDK_EXTRAS_JSON_FILE) as json_file:
46 packages = json.load(json_file) 52 packages = json.load(json_file)
47 for package in packages: 53 for package in packages:
48 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) 54 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip'])
49 if not os.path.exists(local_zip): 55 if not os.path.exists(local_zip):
50 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) 56 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip'])
51 subprocess.check_call([GSUTIL_PATH, '--force-version', '4.7', 'cp', 57 subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7',
52 package_zip, local_zip]) 58 'cp', package_zip, local_zip])
53 # Always clean dir and extract zip to ensure correct contents. 59 # Always clean dir and extract zip to ensure correct contents.
54 clean_and_extract(package['dir_name'], package['package'], package['zip']) 60 clean_and_extract(package['dir_name'], package['package'], package['zip'])
55 61
56 62
57 if __name__ == '__main__': 63 if __name__ == '__main__':
58 sys.exit(main()) 64 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698