Commit 136ba144 authored by Łukasz Nowak's avatar Łukasz Nowak

Support download/upload.

parent 519543aa
...@@ -354,6 +354,11 @@ class Buildout(UserDict.DictMixin): ...@@ -354,6 +354,11 @@ class Buildout(UserDict.DictMixin):
'%r' % (self.download_cache_url, self.download_dir_url)) '%r' % (self.download_cache_url, self.download_dir_url))
self._logger.info('Networkcache upload cache: %r, directory %r'% self._logger.info('Networkcache upload cache: %r, directory %r'%
(self.upload_cache_url, self.upload_dir_url)) (self.upload_cache_url, self.upload_dir_url))
# expose __networkcache__* in options for easier integration
options['__networkcache__download-cache-url'] = self.download_cache_url
options['__networkcache__download-dir-url'] = self.download_dir_url
options['__networkcache__upload-cache-url'] = self.upload_cache_url
options['__networkcache__upload-dir-url'] = self.upload_dir_url
else: else:
self._logger.warning('Networkcache functionality not enabled.') self._logger.warning('Networkcache functionality not enabled.')
self.download_cache_url = None self.download_cache_url = None
...@@ -1120,21 +1125,6 @@ def _install_and_load(spec, group, entry, buildout): ...@@ -1120,21 +1125,6 @@ def _install_and_load(spec, group, entry, buildout):
dest = buildout_options['eggs-directory'] dest = buildout_options['eggs-directory']
path = [buildout_options['develop-eggs-directory']] path = [buildout_options['develop-eggs-directory']]
networkcache_kw = {}
if LIBNETWORKCACHE_ENABLED:
# support networkcache
networkcache_section_name = buildout_options.get('networkcache-section')
if networkcache_section_name:
networkcache_section = buildout[networkcache_section_name]
networkcache_kw['download_cache_url'] = networkcache_section[
'download-cache-url']
networkcache_kw['download_dir_url'] = networkcache_section[
'download-dir-url']
networkcache_kw['upload_cache_url'] = networkcache_section.get(
'upload-cache-url')
networkcache_kw['upload_dir_url'] = networkcache_section.get(
'upload-dir-url')
zc.buildout.easy_install.install( zc.buildout.easy_install.install(
[spec], dest, [spec], dest,
links=buildout._links, links=buildout._links,
...@@ -1144,7 +1134,14 @@ def _install_and_load(spec, group, entry, buildout): ...@@ -1144,7 +1134,14 @@ def _install_and_load(spec, group, entry, buildout):
newest=buildout.newest, newest=buildout.newest,
allow_hosts=buildout._allow_hosts, allow_hosts=buildout._allow_hosts,
prefer_final=not buildout.accept_buildout_test_releases, prefer_final=not buildout.accept_buildout_test_releases,
**networkcache_kw) download_cache_url=buildout_options.get(
'__networkcache__download-cache-url'),
download_dir_url=buildout_options.get(
'__networkcache__download-dir-url'),
upload_cache_url=buildout_options.get(
'__networkcache__upload-cache-url'),
upload_dir_url=buildout_options.get('__networkcache__upload-dir-url')
)
__doing__ = 'Loading %s recipe entry %s:%s.', group, spec, entry __doing__ = 'Loading %s recipe entry %s:%s.', group, spec, entry
return pkg_resources.load_entry_point( return pkg_resources.load_entry_point(
......
...@@ -71,8 +71,12 @@ class Download(object): ...@@ -71,8 +71,12 @@ class Download(object):
self.fallback = fallback self.fallback = fallback
self.hash_name = hash_name self.hash_name = hash_name
self.logger = logger or logging.getLogger('zc.buildout') self.logger = logger or logging.getLogger('zc.buildout')
self.download_dir_url = options.get('sha-dir') self.download_dir_url = options.get('__networkcache__download-dir-url')
self.download_cache_url = options.get('sha-cache') self.download_cache_url = options.get(
'__networkcache__download-cache-url')
self.upload_dir_url = options.get('__networkcache__upload-dir-url')
self.upload_cache_url = options.get(
'__networkcache__upload-cache-url')
@property @property
def download_cache(self): def download_cache(self):
...@@ -187,8 +191,9 @@ class Download(object): ...@@ -187,8 +191,9 @@ class Download(object):
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.download_cache_url, self.download_dir_url, url, if self.upload_cache_url and self.upload_dir_url:
tmp_path, self.logger) upload_network_cached(self.upload_cache_url,
self.upload_dir_url, url, tmp_path, self.logger)
finally: finally:
os.close(handle) os.close(handle)
except: except:
......
...@@ -342,7 +342,9 @@ class Installer: ...@@ -342,7 +342,9 @@ class Installer:
allowed_eggs_from_site_packages=None, allowed_eggs_from_site_packages=None,
prefer_final=None, prefer_final=None,
download_dir_url=None, download_dir_url=None,
download_cache_url=None download_cache_url=None,
upload_dir_url=None,
upload_cache_url=None
): ):
self._dest = dest self._dest = dest
self._allow_hosts = allow_hosts self._allow_hosts = allow_hosts
...@@ -413,6 +415,8 @@ class Installer: ...@@ -413,6 +415,8 @@ class Installer:
self._download_dir_url = download_dir_url self._download_dir_url = download_dir_url
self._download_cache_url = download_cache_url self._download_cache_url = download_cache_url
self._upload_dir_url = upload_dir_url
self._upload_cache_url = upload_cache_url
_allowed_eggs_from_site_packages_regex = None _allowed_eggs_from_site_packages_regex = None
def allow_site_package_egg(self, name): def allow_site_package_egg(self, name):
...@@ -718,8 +722,9 @@ class Installer: ...@@ -718,8 +722,9 @@ class Installer:
if not download_network_cached(self._download_dir_url, self._download_cache_url, if not download_network_cached(self._download_dir_url, self._download_cache_url,
new_location, dist.location, logger): new_location, dist.location, logger):
new_location = self._index.download(dist.location, tmp) new_location = self._index.download(dist.location, tmp)
upload_network_cached(self._download_cache_url, self._download_dir_url, if self._upload_cache_url and self._upload_dir_url:
dist.location, new_location, logger) upload_network_cached(self._upload_cache_url,
self._upload_dir_url, dist.location, new_location, logger)
if (download_cache if (download_cache
and (realpath(new_location) == realpath(dist.location)) and (realpath(new_location) == realpath(dist.location))
...@@ -1105,7 +1110,9 @@ def install(specs, dest, ...@@ -1105,7 +1110,9 @@ def install(specs, dest,
versions, use_dependency_links, allow_hosts=allow_hosts, versions, use_dependency_links, allow_hosts=allow_hosts,
include_site_packages=include_site_packages, include_site_packages=include_site_packages,
allowed_eggs_from_site_packages=allowed_eggs_from_site_packages, allowed_eggs_from_site_packages=allowed_eggs_from_site_packages,
prefer_final=prefer_final, download_dir_url=download_dir_url, download_cache_url=download_cache_url) prefer_final=prefer_final, download_dir_url=download_dir_url,
download_cache_url=download_cache_url, upload_dir_url=upload_dir_url,
upload_cache_url=upload_cache_url)
return installer.install(specs, working_set) return installer.install(specs, working_set)
......
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