Commit bd3b9c3b authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify library existence detection.

parent 5d5ebff6
......@@ -20,6 +20,13 @@ import re
import urllib
import urlparse
try:
from slapos.libnetworkcache import NetworkcacheClient, UploadError, \
DirectoryNotFound
except ImportError:
LIBNETWORKCACHE_ENABLED = False
else:
LIBNETWORKCACHE_ENABLED = True
_md5_re = re.compile(r'md5=([a-f0-9]+)')
......@@ -52,12 +59,8 @@ def download_network_cached(sha_dir, sha_cache, path, url, logger, md5sum=None):
return True if download succeeded.
"""
try:
from slapos.libnetworkcache import NetworkcacheClient, UploadError, \
DirectoryNotFound
except:
return False
if not LIBNETWORKCACHE_ENABLED:
return False
if sha_cache in (None, '',):
# Not able to use network cache
......@@ -94,11 +97,8 @@ def download_network_cached(sha_dir, sha_cache, path, url, logger, md5sum=None):
def upload_network_cached(sha_cache, sha_dir, external_url, path, logger):
"""Upload file to a network cache server"""
try:
from slapos.libnetworkcache import NetworkcacheClient, UploadError, \
DirectoryNotFound
except:
return False
if not LIBNETWORKCACHE_ENABLED:
return False
if sha_cache in [None, ''] or sha_dir in [None, '']:
logger.debug(
......
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