Skip to content
Snippets Groups Projects
Commit 6873cd6b authored by Manuel Günther's avatar Manuel Günther
Browse files

Fixed urllib for python 3.

parent fbdf09fd
No related branches found
No related tags found
No related merge requests found
*.swp
*~ *~
*.swp
*.pyc *.pyc
*.png *.so
*.pdf *.dylib
CMakeLists.txt
bin
eggs
parts
.installed.cfg .installed.cfg
.mr.developer.cfg .mr.developer.cfg
eggs/ *.egg-info
develop-eggs/ develop-eggs
bob.example.faceverify.egg-info/ sphinx
dist
.nfs*
.gdb_history
build
*.egg
src/ src/
bin/ *.png
dist/ *.pdf
sphinx/
Database/
...@@ -41,14 +41,19 @@ def atnt_database_directory(atnt_user_directory = None): ...@@ -41,14 +41,19 @@ def atnt_database_directory(atnt_user_directory = None):
os.mkdir(atnt_default_directory) os.mkdir(atnt_default_directory)
# setup # setup
import urllib2, tempfile import sys, tempfile
if sys.version_info[0] <= 2:
import urllib2 as urllib
else:
import urllib.request as urllib
db_url = 'http://www.cl.cam.ac.uk/Research/DTG/attarchive/pub/data/att_faces.zip' db_url = 'http://www.cl.cam.ac.uk/Research/DTG/attarchive/pub/data/att_faces.zip'
import logging import logging
logger = logging.getLogger('bob') logger = logging.getLogger('bob')
logger.warn("Downloading the AT&T database from '%s' to '%s' ..." % (db_url, atnt_default_directory)) logger.warn("Downloading the AT&T database from '%s' to '%s' ..." % (db_url, atnt_default_directory))
# download # download
url = urllib2.urlopen(db_url) url = urllib.urlopen(db_url)
local_zip_file = tempfile.mkstemp(prefix='atnt_db_', suffix='.zip')[1] local_zip_file = tempfile.mkstemp(prefix='atnt_db_', suffix='.zip')[1]
dfile = open(local_zip_file, 'w') dfile = open(local_zip_file, 'w')
dfile.write(url.read()) dfile.write(url.read())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment