Commit 8a894bb6 authored by Lucas Carvalho's avatar Lucas Carvalho

Providing backward compatibility to instantiate NetworkcacheClient.

Well, the new version of slapos.libnetworkcache has being developed,
and we need to provided backward compatibility to the old versions.

So, slapos.buildout must be able to instantiate a NetworkcacheClient
object even if an TypeError is raised.
parent 0023f96b
...@@ -74,7 +74,7 @@ def download_network_cached(dir_url, cache_url, path, url, logger, ...@@ -74,7 +74,7 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
logger.info('Downloading %s from network cache.' % url) logger.info('Downloading %s from network cache.' % url)
try: try:
nc = NetworkcacheClient(shacache=cache_url, shadir=dir_url, nc = getNetworkcacheClient(shacache=cache_url, shadir=dir_url,
signature_private_key_file=signature_private_key_file, signature_private_key_file=signature_private_key_file,
signature_certificate_file_list=signature_certificate_file_list) signature_certificate_file_list=signature_certificate_file_list)
file_descriptor = nc.select(directory_key) file_descriptor = nc.select(directory_key)
...@@ -117,7 +117,7 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger, ...@@ -117,7 +117,7 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger,
f = open(path, 'r') f = open(path, 'r')
try: try:
nc = NetworkcacheClient(shacache=cache_url, shadir=dir_url, nc = getNetworkcacheClient(shacache=cache_url, shadir=dir_url,
signature_certificate_file_list=signature_certificate_file_list, signature_certificate_file_list=signature_certificate_file_list,
signature_private_key_file=signature_private_key_file) signature_private_key_file=signature_private_key_file)
return nc.upload(f, directory_key, **kw) return nc.upload(f, directory_key, **kw)
...@@ -144,4 +144,18 @@ def get_filename_from_url(url): ...@@ -144,4 +144,18 @@ def get_filename_from_url(url):
return name return name
def getNetworkcacheClient(shacache, shadir, signature_private_key_file,
signature_certificate_file_list):
"""
Provides backward compatibility to instantiate NetworkcacheClient.
"""
try:
nc = NetworkcacheClient(shacache, shadir, signature_private_key_file,
signature_certificate_file_list)
except TypeError:
nc = NetworkcacheClient(shacache, shadir)
return nc
from download import check_md5sum from download import check_md5sum
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