| 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). | |
| 14 """ | 12 """ |
| 15 | 13 |
| 16 import json | 14 import json |
| 17 import os | 15 import os |
| 18 import shutil | 16 import shutil |
| 19 import subprocess | 17 import subprocess |
| 20 import sys | 18 import sys |
| 21 import zipfile | 19 import zipfile |
| 22 | 20 |
| 23 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | 21 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 if not os.environ.get('CHROME_HEADLESS'): | 47 if not os.environ.get('CHROME_HEADLESS'): |
| 50 # This is not a buildbot checkout. | 48 # This is not a buildbot checkout. |
| 51 return 0 | 49 return 0 |
| 52 # Update the android_sdk_extras.json file to update downloaded packages. | 50 # Update the android_sdk_extras.json file to update downloaded packages. |
| 53 with open(SDK_EXTRAS_JSON_FILE) as json_file: | 51 with open(SDK_EXTRAS_JSON_FILE) as json_file: |
| 54 packages = json.load(json_file) | 52 packages = json.load(json_file) |
| 55 for package in packages: | 53 for package in packages: |
| 56 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) | 54 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) |
| 57 if not os.path.exists(local_zip): | 55 if not os.path.exists(local_zip): |
| 58 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) | 56 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) |
| 59 try: | 57 subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7', |
| 60 subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7', | 58 'cp', package_zip, local_zip]) |
| 61 'cp', package_zip, local_zip]) | |
| 62 except AccessDeniedException: | |
| 63 print ('WARNING: Bot does not have permission to download SDK packages.' | |
| 64 ' If this bot compiles for Android, it may have errors.') | |
| 65 return 0 | |
| 66 # Always clean dir and extract zip to ensure correct contents. | 59 # Always clean dir and extract zip to ensure correct contents. |
| 67 clean_and_extract(package['dir_name'], package['package'], package['zip']) | 60 clean_and_extract(package['dir_name'], package['package'], package['zip']) |
| 68 | 61 |
| 69 | 62 |
| 70 if __name__ == '__main__': | 63 if __name__ == '__main__': |
| 71 sys.exit(main()) | 64 sys.exit(main()) |
| OLD | NEW |