1
1
#!/usr/bin/env python
2
2
# Moved some utilities here from ../../configure
3
3
4
+ from __future__ import print_function
4
5
import urllib
5
6
import hashlib
6
7
import sys
@@ -36,10 +37,13 @@ def retrievefile(url, targetfile):
36
37
sys .stdout .write (' <%s>\n Connecting...\r ' % url )
37
38
sys .stdout .flush ()
38
39
ConfigOpener ().retrieve (url , targetfile , reporthook = reporthook )
39
- print '' # clear the line
40
+ print ( '' ) # clear the line
40
41
return targetfile
42
+ except IOError as err :
43
+ print (' ** IOError %s\n ' % err )
44
+ return None
41
45
except :
42
- print ' ** Error occurred while downloading\n <%s>' % url
46
+ print ( ' ** Error occurred while downloading\n <%s>' % url )
43
47
raise
44
48
45
49
def md5sum (targetfile ):
@@ -56,12 +60,12 @@ def unpack(packedfile, parent_path):
56
60
"""Unpacks packedfile into parent_path. Assumes .zip. Returns parent_path"""
57
61
if zipfile .is_zipfile (packedfile ):
58
62
with contextlib .closing (zipfile .ZipFile (packedfile , 'r' )) as icuzip :
59
- print ' Extracting zipfile: %s' % packedfile
63
+ print ( ' Extracting zipfile: %s' % packedfile )
60
64
icuzip .extractall (parent_path )
61
65
return parent_path
62
66
elif tarfile .is_tarfile (packedfile ):
63
67
with contextlib .closing (tarfile .TarFile .open (packedfile , 'r' )) as icuzip :
64
- print ' Extracting tarfile: %s' % packedfile
68
+ print ( ' Extracting tarfile: %s' % packedfile )
65
69
icuzip .extractall (parent_path )
66
70
return parent_path
67
71
else :
@@ -112,7 +116,7 @@ def parse(opt):
112
116
theRet [anOpt ] = True
113
117
else :
114
118
# future proof: ignore unknown types
115
- print 'Warning: ignoring unknown --download= type "%s"' % anOpt
119
+ print ( 'Warning: ignoring unknown --download= type "%s"' % anOpt )
116
120
# all done
117
121
return theRet
118
122
@@ -122,6 +126,6 @@ def candownload(auto_downloads, package):
122
126
if auto_downloads [package ]:
123
127
return True
124
128
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 )
127
131
return False
0 commit comments