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 |
(...skipping 30 matching lines...) Expand all Loading... | |
41 if os.path.exists(local_dir): | 41 if os.path.exists(local_dir): |
42 shutil.rmtree(local_dir) | 42 shutil.rmtree(local_dir) |
43 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, zip_file) | 43 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, zip_file) |
44 with zipfile.ZipFile(local_zip) as z: | 44 with zipfile.ZipFile(local_zip) as z: |
45 z.extractall(path=SDK_EXTRAS_PATH) | 45 z.extractall(path=SDK_EXTRAS_PATH) |
46 | 46 |
47 | 47 |
48 def main(): | 48 def main(): |
49 if not os.environ.get('CHROME_HEADLESS'): | 49 if not os.environ.get('CHROME_HEADLESS'): |
50 # This is not a buildbot checkout. | 50 # This is not a buildbot checkout. |
51 return 0 | 51 return 0 |
navabi
2015/02/20 19:50:33
This will be removed as a hook anyway. Right now t
| |
52 elif 'OS=android' not in os.environ.get('GYP_DEFINES', ''): | |
53 # Not an Android buildbot. | |
54 return 0 | |
55 # Update the android_sdk_extras.json file to update downloaded packages. | 52 # Update the android_sdk_extras.json file to update downloaded packages. |
56 with open(SDK_EXTRAS_JSON_FILE) as json_file: | 53 with open(SDK_EXTRAS_JSON_FILE) as json_file: |
57 packages = json.load(json_file) | 54 packages = json.load(json_file) |
58 for package in packages: | 55 for package in packages: |
59 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) | 56 local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip']) |
60 if not os.path.exists(local_zip): | 57 if not os.path.exists(local_zip): |
61 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) | 58 package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip']) |
62 subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7', | 59 try: |
63 '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 | |
64 # Always clean dir and extract zip to ensure correct contents. | 66 # Always clean dir and extract zip to ensure correct contents. |
65 clean_and_extract(package['dir_name'], package['package'], package['zip']) | 67 clean_and_extract(package['dir_name'], package['package'], package['zip']) |
66 | 68 |
67 | 69 |
68 if __name__ == '__main__': | 70 if __name__ == '__main__': |
69 sys.exit(main()) | 71 sys.exit(main()) |
OLD | NEW |