Skip to content

Commit c20eb4f

Browse files
srl295targos
authored andcommitted
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. #23244 PR-URL: #23715 Fixes: #22344 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 1bdbf87 commit c20eb4f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

configure.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1287,8 +1287,8 @@ def icu_download(path):
12871287
if (md5 == gotmd5):
12881288
return targetfile
12891289
else:
1290-
error('Expected: %s *MISMATCH*' % md5)
1291-
error('\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile)
1290+
warn('Expected: %s *MISMATCH*' % md5)
1291+
warn('\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile)
12921292
return None
12931293
icu_config = {
12941294
'variables': {}
@@ -1432,11 +1432,12 @@ def write_config(data, name):
14321432
# ICU source dir relative to tools/icu (for .gyp file)
14331433
o['variables']['icu_path'] = icu_full_path
14341434
if not os.path.isdir(icu_full_path):
1435-
warn('* ECMA-402 (Intl) support didn\'t find ICU in %s..' % icu_full_path)
14361435
# can we download (or find) a zipfile?
14371436
localzip = icu_download(icu_full_path)
14381437
if localzip:
14391438
nodedownload.unpack(localzip, icu_parent_path)
1439+
else:
1440+
warn('* ECMA-402 (Intl) support didn\'t find ICU in %s..' % icu_full_path)
14401441
if not os.path.isdir(icu_full_path):
14411442
error('''Cannot build Intl without ICU in %s.
14421443
Fix, or disable with "--with-intl=none"''' % icu_full_path)

tools/configure.d/nodedownload.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# Moved some utilities here from ../../configure
33

4+
from __future__ import print_function
45
import urllib
56
import hashlib
67
import sys
@@ -36,10 +37,13 @@ def retrievefile(url, targetfile):
3637
sys.stdout.write(' <%s>\nConnecting...\r' % url)
3738
sys.stdout.flush()
3839
ConfigOpener().retrieve(url, targetfile, reporthook=reporthook)
39-
print '' # clear the line
40+
print('') # clear the line
4041
return targetfile
42+
except IOError as err:
43+
print(' ** IOError %s\n' % err)
44+
return None
4145
except:
42-
print ' ** Error occurred while downloading\n <%s>' % url
46+
print(' ** Error occurred while downloading\n <%s>' % url)
4347
raise
4448

4549
def md5sum(targetfile):
@@ -56,12 +60,12 @@ def unpack(packedfile, parent_path):
5660
"""Unpacks packedfile into parent_path. Assumes .zip. Returns parent_path"""
5761
if zipfile.is_zipfile(packedfile):
5862
with contextlib.closing(zipfile.ZipFile(packedfile, 'r')) as icuzip:
59-
print ' Extracting zipfile: %s' % packedfile
63+
print(' Extracting zipfile: %s' % packedfile)
6064
icuzip.extractall(parent_path)
6165
return parent_path
6266
elif tarfile.is_tarfile(packedfile):
6367
with contextlib.closing(tarfile.TarFile.open(packedfile, 'r')) as icuzip:
64-
print ' Extracting tarfile: %s' % packedfile
68+
print(' Extracting tarfile: %s' % packedfile)
6569
icuzip.extractall(parent_path)
6670
return parent_path
6771
else:
@@ -112,7 +116,7 @@ def parse(opt):
112116
theRet[anOpt] = True
113117
else:
114118
# future proof: ignore unknown types
115-
print 'Warning: ignoring unknown --download= type "%s"' % anOpt
119+
print('Warning: ignoring unknown --download= type "%s"' % anOpt)
116120
# all done
117121
return theRet
118122

@@ -122,6 +126,6 @@ def candownload(auto_downloads, package):
122126
if auto_downloads[package]:
123127
return True
124128
else:
125-
print """Warning: Not downloading package "%s". You could pass "--download=all"
126-
(Windows: "download-all") to try auto-downloading it.""" % package
129+
print("""Warning: Not downloading package "%s". You could pass "--download=all"
130+
(Windows: "download-all") to try auto-downloading it.""" % package)
127131
return False

0 commit comments

Comments
 (0)