Commit e0d325c2 authored by Jim Fulton's avatar Jim Fulton

Author: Alexandru Plugaru <alexandru.plugaru@gmail.com>

Date:   Mon Mar 14 18:18:04 2011 +0000
Fixes #566167

Cherry-picked from svntrunk
parent e6245154
...@@ -175,16 +175,19 @@ class Download(object): ...@@ -175,16 +175,19 @@ class Download(object):
urllib._urlopener = url_opener urllib._urlopener = url_opener
handle, tmp_path = tempfile.mkstemp(prefix='buildout-') handle, tmp_path = tempfile.mkstemp(prefix='buildout-')
try: try:
try: tmp_path, headers = urllib.urlretrieve(url, tmp_path)
tmp_path, headers = urllib.urlretrieve(url, tmp_path) if not check_md5sum(tmp_path, md5sum):
if not check_md5sum(tmp_path, md5sum): raise ChecksumError(
raise ChecksumError( 'MD5 checksum mismatch downloading %r' % url)
'MD5 checksum mismatch downloading %r' % url) except IOError, e:
finally: os.remove(tmp_path)
os.close(handle) raise zc.buildout.UserError("Error downloading extends for URL "
except: "%s: %r" % (url, e[1:3]))
except Exception, e:
os.remove(tmp_path) os.remove(tmp_path)
raise raise
finally:
os.close(handle)
if path: if path:
shutil.move(tmp_path, path) shutil.move(tmp_path, path)
......
...@@ -254,6 +254,13 @@ ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt' ...@@ -254,6 +254,13 @@ ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
>>> remove(path) >>> remove(path)
If the file is completely missing it should notify the user of the error:
>>> download(server_url+'bar.txt')
Traceback (most recent call last):
UserError: Error downloading extends for URL http://localhost/bar.txt: (404, 'Not Found')
>>> ls(cache)
Finally, let's see what happens if the download cache to be used doesn't exist Finally, let's see what happens if the download cache to be used doesn't exist
as a directory in the file system yet: as a directory in the file system yet:
......
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