diff --git a/ipyvolume/datasets.py b/ipyvolume/datasets.py index d35b92d5..6e34a837 100644 --- a/ipyvolume/datasets.py +++ b/ipyvolume/datasets.py @@ -7,6 +7,11 @@ if not os.path.exists(data_dir): os.makedirs(data_dir) +try: + from urllib import urlretrieve +except ImportError: + from urllib.request import urlretrieve + osname = dict(darwin="osx", linux="linux", windows="windows")[platform.system().lower()] @@ -35,8 +40,8 @@ def download(self, force=False): print("Download failed, exit code was: " +str(code) +" will try with curl") code = os.system(self.download_command_curl()) if not os.path.exists(self.path): - print("Download failed again, exit code was: " +str(code) +" giving up") - + print("Download failed again, exit code was: " +str(code) +" using urlretrieve") + self.download_urlretrieve() def fetch(self): self.download() @@ -59,11 +64,13 @@ def fetch(self): return self def download_command_wget(self): - return "wget --progress=bar:force -c -P %s %s" % (data_dir, self.url) + return "wget --progress=bar:force -c -P %s %s" % (data_dir, self.url+"w") def download_command_curl(self): - return "cd %s; curl -O -L %s" % (data_dir, self.url) + return "cd %s; curl -O -L %s" % (data_dir, self.url+"w") + def download_urlretrieve(self): + urlretrieve(self.url, self.path) hdz2000 = Dataset("hdz2000") aquariusA2 = Dataset("aquarius-A2") @@ -71,4 +78,4 @@ def download_command_curl(self): zeldovich = Dataset("zeldovich", density=False) animated_stream = Dataset("stream-animation", density=False, numpy=True) -# low poly cat from: https://sketchfab.com/models/1e7143dfafd04ff4891efcb06949a0b4# \ No newline at end of file +# low poly cat from: https://sketchfab.com/models/1e7143dfafd04ff4891efcb06949a0b4#