Commit ce3baeea authored by Lucas Carvalho's avatar Lucas Carvalho

Restore some code from original version which has been removed accidentally by someone.

parent 6047dbd3
...@@ -180,25 +180,27 @@ class Download(object): ...@@ -180,25 +180,27 @@ class Download(object):
self.logger.info('Downloading %s' % url) self.logger.info('Downloading %s' % url)
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: if not download_network_cached(self.network_cache, tmp_path,
if not download_network_cached(self.network_cache, tmp_path, url, self.logger):
url, self.logger):
# Download from original url
# Download from original url 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) # Upload the file to networkcached.
# Upload the file to networkcached. upload_network_cached(self.network_cache, url,
upload_network_cached(self.network_cache, url, tmp_path, self.logger)
tmp_path, self.logger) 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)
......
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