Commit 42a4f020 authored by Lucas Carvalho's avatar Lucas Carvalho

network-cache options should not be default

parent 54a9d788
......@@ -138,7 +138,6 @@ _buildout_default_options = _annotate_section({
'socket-timeout': '',
'unzip': 'false',
'use-dependency-links': 'true',
'network-cache': 'http://127.0.0.1:5001/',
}, 'DEFAULT_VALUE')
......@@ -363,7 +362,7 @@ class Buildout(UserDict.DictMixin):
newest=self.newest,
allow_hosts=self._allow_hosts,
prefer_final=not self.accept_buildout_test_releases,
network_cache=options['network-cache'],
network_cache=options.get('network-cache'),
)
# Now copy buildout and setuptools eggs, and record destination eggs:
......
......@@ -181,13 +181,10 @@ class Download(object):
urllib._urlopener = url_opener
handle, tmp_path = tempfile.mkstemp(prefix='buildout-')
sha256sum = get_sha256sum_from_networkcached(self.network_cache,
url,
self.logger)
try:
try:
if not download_network_cached(self.network_cache,
tmp_path, sha256sum, self.logger):
tmp_path, self.logger):
# Download from original url
tmp_path, headers = urllib.urlretrieve(url, tmp_path)
......
......@@ -110,7 +110,7 @@ def get_sha256sum_from_networkcached(network_cache, url, logger):
' %s' % str(e))
def download_network_cached(network_cache, path, sha256sum, logger):
def download_network_cached(network_cache, path, logger):
"""Download from a network cache provider
If something fail (providor be offline, or hash_string fail), we ignore
......@@ -118,10 +118,14 @@ def download_network_cached(network_cache, path, sha256sum, logger):
return True if download succeeded.
"""
if sha256sum is None:
if network_cache in (None, '',):
# Not able to use network cache
return False
sha256sum = get_sha256sum_from_networkcached(network_cache,
url,
self.logger)
url = os.path.join(network_cache, sha256sum)
logger.info('Downloading from network cache %s' % url)
try:
......@@ -177,6 +181,9 @@ def fetch_from_network_cache(network_cache, location, tmp, logger=None):
""" Try to download from a network cache and preserve
original filename.
"""
if network_cache in (None, ''):
return None
# Make a id from URL
md5sum = _get_md5_from_url(location)
......
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