| 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 25 matching lines...) Expand all Loading... |
| 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 |
| 50 # Update the android_sdk_extras.json file to update downloaded packages. | 52 # Update the android_sdk_extras.json file to update downloaded packages. |
| 51 with open(SDK_EXTRAS_JSON_FILE) as json_file: | 53 with open(SDK_EXTRAS_JSON_FILE) as json_file: |
| 52 packages = json.load(json_file) | 54 packages = json.load(json_file) |
| 53 for package in packages: | 55 for package in packages: |
| 54 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) | 56 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) |
| 55 if not os.path.exists(local_zip): | 57 if not os.path.exists(local_zip): |
| 56 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) | 58 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) |
| 57 subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7', | 59 try: |
| 58 'cp', package_zip, local_zip]) | 60 subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7', |
| 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 |
| 59 # Always clean dir and extract zip to ensure correct contents. | 66 # Always clean dir and extract zip to ensure correct contents. |
| 60 clean_and_extract(package['dir_name'], package['package'], package['zip']) | 67 clean_and_extract(package['dir_name'], package['package'], package['zip']) |
| 61 | 68 |
| 62 | 69 |
| 63 if __name__ == '__main__': | 70 if __name__ == '__main__': |
| 64 sys.exit(main()) | 71 sys.exit(main()) |
| OLD | NEW |