Commit 6d4e2a10 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira

Merge branch 'download' into 'master'

Using bob.extension download script

Closes #3

See merge request !11
parents 4acdc2cc fb0424da
Pipeline #34394 passed with stages
in 6 minutes and 40 seconds
...@@ -9,6 +9,7 @@ import os ...@@ -9,6 +9,7 @@ import os
import sys import sys
import pkg_resources import pkg_resources
from bob.db.base.driver import Interface as BaseInterface from bob.db.base.driver import Interface as BaseInterface
from bob.extension.download import download_and_unzip
def dumplist(args): def dumplist(args):
...@@ -118,28 +119,13 @@ def download(arguments): ...@@ -118,28 +119,13 @@ def download(arguments):
""" """
source_url = 'http://www.idiap.ch/software/bob/data/bob/att_faces.zip' source_url = ['http://bobconda.lab.idiap.ch/public/data/bob/att_faces.zip',
'http://www.idiap.ch/software/bob/data/bob/att_faces.zip'
import tempfile ]
import zipfile
if sys.version_info[0] <= 2: if not os.path.exists(arguments.output_dir):
import urllib2 as urllib os.mkdir(arguments.output_dir)
else: download_and_unzip(source_url, os.path.join(arguments.output_dir, "att_faces.zip"))
import urllib.request as urllib
if not arguments.quiet:
print ("Extracting url `%s' into `%s'" %(source_url, arguments.output_dir))
u = urllib.urlopen(source_url)
f = tempfile.NamedTemporaryFile(suffix = ".zip")
open(f.name, 'wb').write(u.read())
z = zipfile.ZipFile(f, mode='r')
members = z.infolist()
for k,m in enumerate(members):
if not arguments.quiet:
print("x [%d/%d] %s" % (k+1, len(members), m.filename,))
z.extract(m, arguments.output_dir)
z.close()
f.close()
return 0 return 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment