def get_template_list(remote_repo): """Retrieves a tmpl_list of templates from the specified repository""" url = c(remote_repo, 'url') tmpl_list = urlopen("%s/templatelist.txt" % url) templates = [template.strip() for template in tmpl_list] tmpl_list.close() return templates
def get_template_list(remote_repo): """Retrieves a tmpl_list of templates from the specified repository""" url = get_config().getstring(remote_repo, 'url') url = url.rstrip('/') + '/' tmpl_list = urlopen(urlparse.urljoin(url, 'templatelist.txt')) templates = [template.strip() for template in tmpl_list] tmpl_list.close() return templates
def is_fresh(localfile, remotefile): """Checks whether local copy matches remote file""" # get remote hash remote_hashfile = urlopen("%s.tar.pfff" % remotefile) remote_hash = remote_hashfile.read() remote_hashfile.close() # get a local one try: with open("%s.tar.pfff" % localfile, 'r') as f: local_hash = f.read() except IOError: # no local hash found return False return remote_hash == local_hash
def is_fresh(localfile, remotefile, unfinished=False): """Checks whether local copy matches remote file""" # get remote hash extension = "ova" if _url_exists("%s.ova" % remotefile) else "tar" remote_hashfile = urlopen("%s.%s.pfff" % (remotefile, extension)) remote_hash = remote_hashfile.read() remote_hashfile.close() # get a local one try: with open("%s.%s.pfff%s" % (localfile, extension, ".unfinished" if unfinished else ""), "r") as f: local_hash = f.read() except IOError: # no local hash found return False return remote_hash == local_hash
def is_fresh(localfile, remotefile, unfinished=False): """Checks whether local copy matches remote file""" # get remote hash extension = "ova" if _url_exists("%s.ova" % remotefile) else "tar" remote_hashfile = urlopen("%s.%s.pfff" % (remotefile, extension)) remote_hash = remote_hashfile.read() remote_hashfile.close() # get a local one try: with open("%s.%s.pfff%s" % (localfile, extension, '.unfinished' if unfinished else ''), 'r') as f: local_hash = f.read() except IOError: # no local hash found return False return remote_hash == local_hash