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

Unified Diff: build/download_sdk_extras.py

Issue 1264063002: Implemented retries in download_sdk_extras.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/download_sdk_extras.py
diff --git a/build/download_sdk_extras.py b/build/download_sdk_extras.py
index d7c5d6cad6c9eec10690644bf7ba485189e3f287..d55ea7bd0d453629ae22e4d0a0934a06fd47d12f 100755
--- a/build/download_sdk_extras.py
+++ b/build/download_sdk_extras.py
@@ -45,6 +45,17 @@ def clean_and_extract(dir_name, package_name, zip_file):
z.extractall(path=SDK_EXTRAS_PATH)
+def download_package(remote_file, local_file):
+ if not os.path.exists(local_file):
+ try:
+ subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7',
+ 'cp', remote_file, local_file])
+ except subprocess.CalledProcessError:
+ print ('WARNING: Failed to download SDK packages. If this bot compiles '
+ 'for Android, it may have errors.')
+ return 0
+
+
def main():
if not os.environ.get('CHROME_HEADLESS'):
# This is not a buildbot checkout.
@@ -54,17 +65,23 @@ def main():
packages = json.load(json_file)
for package in packages:
local_zip = '%s/%s' % (SDK_EXTRAS_PATH, package['zip'])
- if not os.path.exists(local_zip):
- package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip'])
+ package_zip = '%s/%s' % (SDK_EXTRAS_BUCKET, package['zip'])
+ for attempt in xrange(2):
+ print '(%d) Downloading package %s' % (attempt + 1, package['zip'])
+ download_package(package_zip, local_zip)
try:
- subprocess.check_call(['python', GSUTIL_PATH, '--force-version', '4.7',
- 'cp', package_zip, local_zip])
- except subprocess.CalledProcessError:
- print ('WARNING: Failed to download SDK packages. If this bot compiles '
- 'for Android, it may have errors.')
- return 0
- # Always clean dir and extract zip to ensure correct contents.
- clean_and_extract(package['dir_name'], package['package'], package['zip'])
+ # Always clean dir and extract zip to ensure correct contents.
+ clean_and_extract(package['dir_name'],
+ package['package'],
+ package['zip'])
+ except zipfile.BadZipfile:
+ print 'Failed unpacking zip file. Deleting and retrying...'
+ os.remove(local_zip)
+ continue
dnj 2015/07/30 22:49:03 I don't like this continue/break thing. Either bre
pgervais 2015/07/30 23:05:16 Done.
+ break
+ else:
+ print ('WARNING: Failed to get SDK packages. If this bot compiles '
+ 'for Android, it may have errors.')
dnj 2015/07/30 22:49:03 This should return an error on failure.
pgervais 2015/07/30 23:05:16 Note the return 0 on line 56: it previously exited
navabi 2015/07/30 23:20:31 This will cause failures when gsutil cp fails to c
navabi 2015/07/30 23:40:39 This can not simply return an error on failure. If
dnj 2015/07/30 23:45:34 :(
if __name__ == '__main__':
« 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