in ccmlib/hcd/hcd_cluster.py [0:0]
def download_hcd_version(version, verbose=False):
url = HCD_ARCHIVE
if repository.CCM_CONFIG.has_option('repositories', 'hcd'):
url = repository.CCM_CONFIG.get('repositories', 'hcd')
url = url % version
_, target = tempfile.mkstemp(suffix=".tar.gz", prefix="ccm-")
try:
repository.__download(url, target, show_progress=verbose)
common.debug("Extracting {} as version {} ...".format(target, version))
tar = tarfile.open(target)
dir = tar.next().name.split("/")[0] # pylint: disable=all
tar.extractall(path=repository.__get_dir())
tar.close()
target_dir = os.path.join(repository.__get_dir(), version)
if os.path.exists(target_dir):
rmdirs(target_dir)
shutil.move(os.path.join(repository.__get_dir(), dir), target_dir)
except urllib.error.URLError as e:
msg = "Invalid version %s" % version if url is None else "Invalid url %s" % url
msg = msg + " (underlying error is: %s)" % str(e)
raise ArgumentError(msg)
except tarfile.ReadError as e:
raise ArgumentError("Unable to uncompress downloaded file: %s" % str(e))