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,
logger.info('Downloading %s from network cache.' % url)
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_certificate_file_list=signature_certificate_file_list)
file_descriptor = nc.select(directory_key)
......@@ -117,7 +117,7 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger,
f = open(path, 'r')
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_private_key_file=signature_private_key_file)
return nc.upload(f, directory_key, **kw)
......@@ -144,4 +144,18 @@ def get_filename_from_url(url):
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
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