| OLD | NEW |
| 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 on the test bots. This | 10 be extracted in the android_tools/sdk/extras directory on the test bots. This |
| 11 script will not do anything for developers. | 11 script will not do anything for developers. |
| 12 |
| 13 TODO(navabi): Move this script (crbug.com/459819). |
| 12 """ | 14 """ |
| 13 | 15 |
| 14 import json | 16 import json |
| 15 import os | 17 import os |
| 16 import shutil | 18 import shutil |
| 17 import subprocess | 19 import subprocess |
| 18 import sys | 20 import sys |
| 19 import zipfile | 21 import zipfile |
| 20 | 22 |
| 21 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | 23 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 shutil.rmtree(local_dir) | 42 shutil.rmtree(local_dir) |
| 41 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, zip_file) | 43 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, zip_file) |
| 42 with zipfile.ZipFile(local_zip) as z: | 44 with zipfile.ZipFile(local_zip) as z: |
| 43 z.extractall(path=SDK_EXTRAS_PATH) | 45 z.extractall(path=SDK_EXTRAS_PATH) |
| 44 | 46 |
| 45 | 47 |
| 46 def main(): | 48 def main(): |
| 47 if not os.environ.get('CHROME_HEADLESS'): | 49 if not os.environ.get('CHROME_HEADLESS'): |
| 48 # This is not a buildbot checkout. | 50 # This is not a buildbot checkout. |
| 49 return 0 | 51 return 0 |
| 52 elif 'OS=android' not in os.environ.get('GYP_DEFINES', ''): |
| 53 # Not an Android buildbot. |
| 54 return 0 |
| 50 # Update the android_sdk_extras.json file to update downloaded packages. | 55 # Update the android_sdk_extras.json file to update downloaded packages. |
| 51 with open(SDK_EXTRAS_JSON_FILE) as json_file: | 56 with open(SDK_EXTRAS_JSON_FILE) as json_file: |
| 52 packages = json.load(json_file) | 57 packages = json.load(json_file) |
| 53 for package in packages: | 58 for package in packages: |
| 54 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) | 59 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) |
| 55 if not os.path.exists(local_zip): | 60 if not os.path.exists(local_zip): |
| 56 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) | 61 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) |
| 57 subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7', | 62 subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7', |
| 58 'cp', package_zip, local_zip]) | 63 'cp', package_zip, local_zip]) |
| 59 # Always clean dir and extract zip to ensure correct contents. | 64 # Always clean dir and extract zip to ensure correct contents. |
| 60 clean_and_extract(package['dir_name'], package['package'], package['zip']) | 65 clean_and_extract(package['dir_name'], package['package'], package['zip']) |
| 61 | 66 |
| 62 | 67 |
| 63 if __name__ == '__main__': | 68 if __name__ == '__main__': |
| 64 sys.exit(main()) | 69 sys.exit(main()) |
| OLD | NEW |