From d8f2d2726143ecfbf99b90b7bbbc6f41b3cd95fc Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 17 Oct 2018 09:41:07 -0700 Subject: tools, icu: actually failover if there are multiple URLs Building on #23269, if multiple ICU download URLs are present, try the next one in case of error. Part of the ICU 63.1 bump, but independent code-wise. https://github.com/nodejs/node/issues/23244 PR-URL: https://github.com/nodejs/node/pull/23715 Fixes: https://github.com/nodejs/node/issues/22344 Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau Reviewed-By: Gus Caplan Reviewed-By: Michael Dawson --- tools/configure.d/nodedownload.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'tools/configure.d') diff --git a/tools/configure.d/nodedownload.py b/tools/configure.d/nodedownload.py index 3f4bc090f71..e3fe2c517cc 100644 --- a/tools/configure.d/nodedownload.py +++ b/tools/configure.d/nodedownload.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # Moved some utilities here from ../../configure +from __future__ import print_function import urllib import hashlib import sys @@ -36,10 +37,13 @@ def retrievefile(url, targetfile): sys.stdout.write(' <%s>\nConnecting...\r' % url) sys.stdout.flush() ConfigOpener().retrieve(url, targetfile, reporthook=reporthook) - print '' # clear the line + print('') # clear the line return targetfile + except IOError as err: + print(' ** IOError %s\n' % err) + return None except: - print ' ** Error occurred while downloading\n <%s>' % url + print(' ** Error occurred while downloading\n <%s>' % url) raise def md5sum(targetfile): @@ -56,12 +60,12 @@ def unpack(packedfile, parent_path): """Unpacks packedfile into parent_path. Assumes .zip. Returns parent_path""" if zipfile.is_zipfile(packedfile): with contextlib.closing(zipfile.ZipFile(packedfile, 'r')) as icuzip: - print ' Extracting zipfile: %s' % packedfile + print(' Extracting zipfile: %s' % packedfile) icuzip.extractall(parent_path) return parent_path elif tarfile.is_tarfile(packedfile): with contextlib.closing(tarfile.TarFile.open(packedfile, 'r')) as icuzip: - print ' Extracting tarfile: %s' % packedfile + print(' Extracting tarfile: %s' % packedfile) icuzip.extractall(parent_path) return parent_path else: @@ -112,7 +116,7 @@ def parse(opt): theRet[anOpt] = True else: # future proof: ignore unknown types - print 'Warning: ignoring unknown --download= type "%s"' % anOpt + print('Warning: ignoring unknown --download= type "%s"' % anOpt) # all done return theRet @@ -122,6 +126,6 @@ def candownload(auto_downloads, package): if auto_downloads[package]: return True else: - print """Warning: Not downloading package "%s". You could pass "--download=all" - (Windows: "download-all") to try auto-downloading it.""" % package + print("""Warning: Not downloading package "%s". You could pass "--download=all" + (Windows: "download-all") to try auto-downloading it.""" % package) return False -- cgit v1.2.3