Commit 0896daca authored by Łukasz Nowak's avatar Łukasz Nowak

Be nice for slapos.libnetworkcache.

Convert buildout emptiness to Nones.
parent 1961d5d4
......@@ -72,9 +72,12 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
directory_key = get_directory_key(url)
url = os.path.basename(url)
if len(signature_certificate_list) == 0:
# convert [] into None in order to call nc nicely
signature_certificate_list = None
try:
nc = NetworkcacheClient(cache_url, dir_url,
signature_certificate_list=signature_certificate_list)
nc = NetworkcacheClient(cache_url, dir_url,
signature_certificate_list=signature_certificate_list)
except TypeError:
logger.warning('Incompatible version of networkcache, not using it.')
return False
......@@ -119,12 +122,15 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger,
urlmd5=hashlib.md5(external_url).hexdigest())
f = open(path, 'r')
if not signature_private_key_file:
# convert '' into None in order to call nc nicely
signature_private_key_file = None
try:
nc = NetworkcacheClient(cache_url, dir_url,
signature_private_key_file=signature_private_key_file)
nc = NetworkcacheClient(cache_url, dir_url,
signature_private_key_file=signature_private_key_file)
except TypeError:
logger.warning('Incompatible version of networkcache, not using it.')
return False
logger.warning('Incompatible version of networkcache, not using it.')
return False
try:
return nc.upload(f, directory_key, **kw)
......
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