Skip to content
Snippets Groups Projects
Commit 846d02b6 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Updated ATNT path

parent 4b6f55c4
Branches
Tags
No related merge requests found
Pipeline #34456 passed
...@@ -8,7 +8,7 @@ import os ...@@ -8,7 +8,7 @@ import os
import sys import sys
import functools import functools
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
from bob.extension.download import download_and_unzip
# based on: http://stackoverflow.com/questions/6796492/temporarily-redirect-stdout-stderr # based on: http://stackoverflow.com/questions/6796492/temporarily-redirect-stdout-stderr
class Quiet(object): class Quiet(object):
...@@ -91,31 +91,20 @@ def atnt_database_directory(): ...@@ -91,31 +91,20 @@ def atnt_database_directory():
if os.path.exists(atnt_default_directory): if os.path.exists(atnt_default_directory):
return atnt_default_directory return atnt_default_directory
import sys, tempfile # TODO: THIS SHOULD BE A CLASS METHOD OF bob.db.atnt database
if sys.version_info[0] <= 2: source_url = ['http://bobconda.lab.idiap.ch/public/data/bob/att_faces.zip',
import urllib2 as urllib 'http://www.idiap.ch/software/bob/data/bob/att_faces.zip']
else:
import urllib.request as urllib
import tempfile
atnt_downloaded_directory = tempfile.mkdtemp(prefix='atnt_db_') atnt_downloaded_directory = tempfile.mkdtemp(prefix='atnt_db_')
db_url = "http://www.cl.cam.ac.uk/Research/DTG/attarchive/pub/data/att_faces.zip" logger.warn("Downloading the AT&T database from '%s' to '%s' ...", source_url, atnt_downloaded_directory)
logger.warn("Downloading the AT&T database from '%s' to '%s' ...", db_url, atnt_downloaded_directory)
logger.warn("To avoid this, please download the database manually, extract the data and set the ATNT_DATABASE_DIRECTORY environment variable to this directory.") logger.warn("To avoid this, please download the database manually, extract the data and set the ATNT_DATABASE_DIRECTORY environment variable to this directory.")
# to avoid re-downloading in parallel test execution # to avoid re-downloading in parallel test execution
os.environ['ATNT_DATABASE_DIRECTORY'] = atnt_downloaded_directory os.environ['ATNT_DATABASE_DIRECTORY'] = atnt_downloaded_directory
# download if not os.path.exists(atnt_downloaded_directory):
url = urllib.urlopen(db_url) os.mkdir(atnt_downloaded_directory)
local_zip_file = os.path.join(atnt_downloaded_directory, 'att_faces.zip') download_and_unzip(source_url, os.path.join(atnt_downloaded_directory, "att_faces.zip"))
dfile = open(local_zip_file, 'wb')
dfile.write(url.read())
dfile.close()
# unzip
import zipfile
zip = zipfile.ZipFile(local_zip_file)
zip.extractall(atnt_downloaded_directory)
os.remove(local_zip_file)
return atnt_downloaded_directory return atnt_downloaded_directory
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment