77if not os .path .exists (data_dir ):
88 os .makedirs (data_dir )
99
10+ try :
11+ from urllib import urlretrieve
12+ except ImportError :
13+ from urllib .request import urlretrieve
14+
1015
1116osname = dict (darwin = "osx" , linux = "linux" , windows = "windows" )[platform .system ().lower ()]
1217
@@ -35,8 +40,8 @@ def download(self, force=False):
3540 print ("Download failed, exit code was: " + str (code ) + " will try with curl" )
3641 code = os .system (self .download_command_curl ())
3742 if not os .path .exists (self .path ):
38- print ("Download failed again, exit code was: " + str (code ) + " giving up " )
39-
43+ print ("Download failed again, exit code was: " + str (code ) + " using urlretrieve " )
44+ self . download_urlretrieve ()
4045
4146 def fetch (self ):
4247 self .download ()
@@ -59,16 +64,18 @@ def fetch(self):
5964 return self
6065
6166 def download_command_wget (self ):
62- return "wget --progress=bar:force -c -P %s %s" % (data_dir , self .url )
67+ return "wget --progress=bar:force -c -P %s %s" % (data_dir , self .url + "w" )
6368
6469 def download_command_curl (self ):
65- return "cd %s; curl -O -L %s" % (data_dir , self .url )
70+ return "cd %s; curl -O -L %s" % (data_dir , self .url + "w" )
6671
72+ def download_urlretrieve (self ):
73+ urlretrieve (self .url , self .path )
6774
6875hdz2000 = Dataset ("hdz2000" )
6976aquariusA2 = Dataset ("aquarius-A2" )
7077egpbosLCDM = Dataset ("egpbos-LCDM" )
7178zeldovich = Dataset ("zeldovich" , density = False )
7279animated_stream = Dataset ("stream-animation" , density = False , numpy = True )
7380
74- # low poly cat from: https://sketchfab.com/models/1e7143dfafd04ff4891efcb06949a0b4#
81+ # low poly cat from: https://sketchfab.com/models/1e7143dfafd04ff4891efcb06949a0b4#
0 commit comments