@@ -341,25 +341,38 @@ def _download(self, pkg):
341
341
try :
342
342
arch_dct = repos [self .target_arch ]
343
343
except KeyError :
344
- src = default
344
+ srcs = default
345
345
else :
346
- src = arch_dct .get (self .target_os , arch_dct .get (None , default ))
347
- pkg = os .path .basename (src )
348
- cache_dir = tempfile .gettempdir ()
349
- cache_db = os .path .join (cache_dir , 'taucmdr.setup_py.downloads' )
350
- cache_pkg = os .path .join (cache_dir , pkg )
351
- try :
352
- with open (cache_db , 'r' ) as fin :
353
- cache = pickle .load (fin )
354
- except IOError :
355
- cache = {}
356
- if not os .path .exists (cache_pkg ) or src != cache .get (cache_pkg ):
357
- print "Downloading '{}' for ({}, {})" .format (pkg , self .target_arch , self .target_os )
358
- util .download (src , cache_pkg )
359
- cache [cache_pkg ] = src
360
- with open (cache_db , 'w' ) as fout :
361
- pickle .dump (cache , fout )
362
- util .download (cache_pkg , os .path .join ('system' , 'src' , pkg ))
346
+ srcs = arch_dct .get (self .target_os , arch_dct .get (None , default ))
347
+ if not isinstance (srcs , list ):
348
+ srcs = [srcs ]
349
+ success = False
350
+ while srcs and not success :
351
+ try :
352
+ src = srcs .pop (0 )
353
+ pkg = os .path .basename (src )
354
+ cache_dir = tempfile .gettempdir ()
355
+ cache_db = os .path .join (cache_dir , 'taucmdr.setup_py.downloads' )
356
+ cache_pkg = os .path .join (cache_dir , pkg )
357
+ try :
358
+ with open (cache_db , 'r' ) as fin :
359
+ cache = pickle .load (fin )
360
+ except IOError :
361
+ cache = {}
362
+ if not os .path .exists (cache_pkg ) or src != cache .get (cache_pkg ):
363
+ print "Downloading '{}' for ({}, {})" .format (pkg , self .target_arch , self .target_os )
364
+ util .download (src , cache_pkg )
365
+ cache [cache_pkg ] = src
366
+ with open (cache_db , 'w' ) as fout :
367
+ pickle .dump (cache , fout )
368
+ util .download (cache_pkg , os .path .join ('system' , 'src' , pkg ))
369
+ success = True
370
+ except IOError :
371
+ print "Failed to download {} from URL {}; falling back to next mirror." .format (pkg , src )
372
+ pass
373
+ if not success :
374
+ raise IOError ("Unable to download {} from any mirror." .format (pkg ))
375
+
363
376
364
377
def _download_python (self ):
365
378
from taucmdr .cf .platforms import X86_64 , INTEL_KNC , INTEL_KNL , IBM64 , PPC64LE , ARM64 , DARWIN , LINUX
0 commit comments