# default setting replaces the target name with the URL filename)
-import urllib2, urlparse
+import urllib.request, urllib.error, urllib.parse, urllib.parse
import SCons.Builder, SCons.Node, SCons.Errors
pass
try :
- response = urllib2.urlopen( str(self.value) ).info()
- except Exception, e :
+ response = urllib.request.urlopen( str(self.value) ).info()
+ except Exception as e :
raise SCons.Errors.StopError( "%s [%s]" % (e, self.value) )
contents = ""
# @param source source name
# @param env environment object
def __message( s, target, source, env ) :
- print "downloading [%s] to [%s] ..." % (source[0], target[0])
+ print("downloading [%s] to [%s] ..." % (source[0], target[0]))
# the download function, which reads the data from the URL
# @@param env environment object
def __action( target, source, env ) :
try :
- stream = urllib2.urlopen( str(source[0]) )
+ stream = urllib.request.urlopen( str(source[0]) )
file = open( str(target[0]), "wb" )
file.write(stream.read())
file.close()
stream.close()
- except Exception, e :
+ except Exception as e :
raise SCons.Errors.StopError( "%s [%s]" % (e, source[0]) )
return target, source
try :
- url = urlparse.urlparse( urllib2.urlopen( str(source[0]) ).geturl() )
- except Exception, e :
+ url = urllib.parse.urlparse( urllib.request.urlopen( str(source[0]) ).geturl() )
+ except Exception as e :
raise SCons.Errors.StopError( "%s [%s]" % (e, source[0]) )
return url.path.split("/")[-1], source