Commit 59620375 authored by Lucas Carvalho's avatar Lucas Carvalho

Renamed some variables.

Renamed signature_private_file to signature_private_key_file.
And also signature_public_file to signature_certificate_file.
parent c69a72f9
......@@ -343,8 +343,8 @@ class Buildout(UserDict.DictMixin):
self.download_dir_url = None
self.upload_cache_url = None
self.upload_dir_url = None
self.signature_private_file = None
self.signature_public_file = None
self.signature_private_key_file = None
self.signature_certificate_file = None
else:
# support networkcache
networkcache_section_name = options.get('networkcache-section')
......@@ -358,10 +358,10 @@ class Buildout(UserDict.DictMixin):
'upload-cache-url', '')
self.upload_dir_url = networkcache_section.get(
'upload-dir-url', '')
self.signature_private_file = options.get(
'signature_private_file', '')
self.signature_public_file = options.get(
'signature_public_file', '')
self.signature_certificate_file = networkcache_section.get(
'signature-certificate-file', '')
self.signature_private_key_file = options.get(
'signature-private-key-file', '')
self._logger.info('Networkcache enabled.')
self._logger.info('Networkcache download cache: %r, directory '
......@@ -373,6 +373,9 @@ class Buildout(UserDict.DictMixin):
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
options['__networkcache__signature-certificate-file'] = self.signature_certificate_file
options['__networkcache__signature-private-key-file'] = self.signature_private_key_file
else:
self._logger.debug('Networkcache functionality not enabled. '
'In order to activate use networkcache-section.')
......@@ -380,8 +383,8 @@ class Buildout(UserDict.DictMixin):
self.download_dir_url = None
self.upload_cache_url = None
self.upload_dir_url = None
self.signature_private_file = None
self.signature_public_file = None
self.signature_private_key_file = None
self.signature_certificate_file = None
def _buildout_path(self, name):
if '${' in name:
......@@ -421,8 +424,8 @@ class Buildout(UserDict.DictMixin):
download_dir_url=self.download_dir_url,
upload_cache_url=self.upload_cache_url,
upload_dir_url=self.upload_dir_url,
signature_private_file=self.signature_private_file,
signature_public_file=self.signature_public_file,
signature_private_key_file=self.signature_private_key_file,
signature_certificate_file=self.signature_certificate_file,
)
# Now copy buildout and setuptools eggs, and record destination eggs:
......@@ -928,8 +931,8 @@ class Buildout(UserDict.DictMixin):
download_dir_url=self.download_dir_url,
upload_cache_url=self.upload_cache_url,
upload_dir_url=self.upload_dir_url,
signature_public_file=self.signature_public_file,
signature_private_file=self.signature_private_file,
signature_certificate_file=self.signature_certificate_file,
signature_private_key_file=self.signature_private_key_file,
)
upgraded = []
......@@ -1165,8 +1168,10 @@ def _install_and_load(spec, group, entry, buildout):
upload_cache_url=buildout_options.get(
'__networkcache__upload-cache-url'),
upload_dir_url=buildout_options.get('__networkcache__upload-dir-url'),
signature_private_file=buildout_options.get('signature_private_file'),
signature_public_file=buildout_options.get('signature_public_file'),
signature_private_key_file=buildout_options.get(
'__networkcache__signature-private-key-file'),
signature_certificate_file=buildout_options.get(
'__networkcache__signature-certificate-file'),
)
__doing__ = 'Loading %s recipe entry %s:%s.', group, spec, entry
......
......@@ -77,10 +77,10 @@ class Download(object):
self.upload_dir_url = options.get('__networkcache__upload-dir-url')
self.upload_cache_url = options.get(
'__networkcache__upload-cache-url')
self.signature_public_file = options.get(
'signature_public_file')
self.signature_private_file = options.get(
'signature_private_file')
self.signature_certificate_file = options.get(
'__networkcache__signature-certificate-file')
self.signature_private_key_file = options.get(
'__networkcache__signature-private-key-file')
@property
def download_cache(self):
......@@ -188,8 +188,8 @@ class Download(object):
try:
if not download_network_cached(self.download_dir_url,
self.download_cache_url, tmp_path, url, self.logger,
self.signature_public_file,
self.signature_private_file, md5sum):
self.signature_certificate_file,
self.signature_private_key_file, md5sum):
# Download from original url
tmp_path, headers = urllib.urlretrieve(url, tmp_path)
if not check_md5sum(tmp_path, md5sum):
......@@ -199,8 +199,8 @@ class Download(object):
if self.upload_cache_url and self.upload_dir_url:
upload_network_cached(self.upload_dir_url,
self.upload_cache_url, url, tmp_path, self.logger,
self.signature_public_file,
self.signature_private_file)
self.signature_certificate_file,
self.signature_private_key_file)
finally:
os.close(handle)
except:
......
......@@ -345,8 +345,8 @@ class Installer:
download_cache_url=None,
upload_dir_url=None,
upload_cache_url=None,
signature_public_file=None,
signature_private_file=None
signature_certificate_file=None,
signature_private_key_file=None
):
self._dest = dest
self._allow_hosts = allow_hosts
......@@ -419,8 +419,8 @@ class Installer:
self._download_cache_url = download_cache_url
self._upload_dir_url = upload_dir_url
self._upload_cache_url = upload_cache_url
self._signature_public_file = signature_public_file
self._signature_private_file = signature_private_file
self._signature_certificate_file = signature_certificate_file
self._signature_private_key_file = signature_private_key_file
_allowed_eggs_from_site_packages_regex = None
def allow_site_package_egg(self, name):
......@@ -725,12 +725,12 @@ class Installer:
new_location = os.path.join(tmp, filename)
if not download_network_cached(self._download_dir_url,
self._download_cache_url, new_location, dist.location, logger,
self._signature_public_file, self._signature_private_file):
self._signature_certificate_file, self._signature_private_key_file):
new_location = self._index.download(dist.location, tmp)
if self._upload_cache_url and self._upload_dir_url:
upload_network_cached(self._upload_dir_url,
self._upload_cache_url, dist.location, new_location, logger,
self._signature_public_file, self._signature_private_file)
self._signature_certificate_file, self._signature_private_key_file)
if (download_cache
and (realpath(new_location) == realpath(dist.location))
......@@ -1111,7 +1111,7 @@ def install(specs, dest,
include_site_packages=None, allowed_eggs_from_site_packages=None,
prefer_final=None, download_dir_url=None, download_cache_url=None,
upload_dir_url=None, upload_cache_url=None,
signature_public_file=None, signature_private_file=None):
signature_certificate_file=None, signature_private_key_file=None):
installer = Installer(
dest, links, index, executable, always_unzip, path, newest,
versions, use_dependency_links, allow_hosts=allow_hosts,
......@@ -1120,8 +1120,8 @@ def install(specs, dest,
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,
signature_public_file=signature_public_file,
signature_private_file=signature_private_file)
signature_certificate_file=signature_certificate_file,
signature_private_key_file=signature_private_key_file)
return installer.install(specs, working_set)
......
......@@ -51,7 +51,7 @@ def get_directory_key(url):
def download_network_cached(dir_url, cache_url, path, url, logger,
signature_public_file, signature_private_file, md5sum=None):
signature_certificate_file, signature_private_key_file, md5sum=None):
"""Downloads from a network cache provider
If something fail (providor be offline, or hash_string fail), we ignore
......@@ -68,15 +68,15 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
md5sum = _get_md5_from_url(url)
signature_certificate_file_list = signature_certificate_file.split('\n')
directory_key = get_directory_key(url)
url = os.path.basename(url)
logger.info('Downloading %s from network cache.' % url)
try:
nc = NetworkcacheClient(shacache=cache_url,
shadir=dir_url,
signature_private_file=signature_private_file,
signature_public_file=signature_public_file)
nc = NetworkcacheClient(shacache=cache_url, shadir=dir_url,
signature_private_key_file=signature_private_key_file,
signature_certificate_file_list=signature_certificate_file_list)
file_descriptor = nc.select(directory_key)
buffer_size = min(1024, os.path.getsize(file_descriptor.name))
......@@ -99,7 +99,7 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
def upload_network_cached(dir_url, cache_url, external_url, path, logger,
signature_public_file, signature_private_file):
signature_certificate_file, signature_private_key_file):
"""Upload file to a network cache server"""
if not LIBNETWORKCACHE_ENABLED:
return False
......@@ -113,13 +113,13 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger,
directory_key = get_directory_key(external_url)
kw = dict(file=file_name,
urlmd5=hashlib.md5(external_url).hexdigest())
signature_certificate_file_list = signature_certificate_file.split('\n')
f = open(path, 'r')
try:
nc = NetworkcacheClient(shacache=cache_url,
shadir=dir_url,
signature_public_file=signature_public_file,
signature_private_file=signature_private_file)
nc = NetworkcacheClient(shacache=cache_url, shadir=dir_url,
signature_certificate_file_list=signature_certificate_file_list,
signature_private_key_file=signature_private_key_file)
return nc.upload(f, directory_key, **kw)
except (IOError, UploadError), e:
logger.info('Fail to upload file. %s' % \
......
......@@ -93,8 +93,8 @@ class Eggs(object):
('__networkcache__download-dir-url', 'download_dir_url'),
('__networkcache__upload-cache-url', 'upload_cache_url'),
('__networkcache__upload-dir-url', 'upload_dir_url'),
('signature_private_file', 'signature_private_file'),
('signature_public_file', 'signature_public_file')):
('__networkcache__signature-private-key-file', 'signature_private_key_file'),
('__networkcache__signature-certificate-file', 'signature_certificate_file')):
if option_key in b_options:
kw[kw_key] = b_options[option_key]
......
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