def load_from_cache(layer, redo=False): '''Given a layer object, check against cache to see if that layer id exists if yes then get the package list and load it in the layer and return true. If it doesn't exist return false. Default operation is to not redo the cache. Add notices to the layer's origins matching the origin_str''' loaded = False origin_layer = 'Layer: ' + layer.fs_hash[:10] if not layer.packages and not redo: # there are no packages in this layer and we are not repopulating the # cache, try to get it from the cache raw_pkg_list = cache.get_packages(layer.fs_hash) if raw_pkg_list: logger.debug('Loaded from cache: layer {}'.format( layer.fs_hash[:10])) message = formats.loading_from_cache.format( layer_id=layer.fs_hash[:10]) # add notice to the origin layer.origins.add_notice_to_origins(origin_layer, Notice(message, 'info')) for pkg_dict in raw_pkg_list: pkg = Package(pkg_dict['name']) pkg.fill(pkg_dict) layer.add_package(pkg) loaded = True return loaded
def load_from_cache(layer, redo=False): '''Given a layer object, check against cache to see if that layer id exists if yes then get the package list and load it in the layer and return true. If it doesn't exist return false. Default operation is to not redo the cache. Add notices to the layer's origins matching the origin_str''' loaded = False if not layer.packages and not redo: # there are no packages in this layer and we are not repopulating the # cache, try to get it from the cache raw_pkg_list = cache.get_packages(layer.fs_hash) if raw_pkg_list: logger.debug('Loaded from cache: layer \"%s\"', layer.fs_hash[:10]) for pkg_dict in raw_pkg_list: pkg = Package(pkg_dict['name']) pkg.fill(pkg_dict) layer.add_package(pkg) load_notices_from_cache(layer) loaded = True return loaded
def load_packages_from_cache(layer): '''Given a layer object, populate package level information''' loaded = False raw_pkg_list = cache.get_packages(layer.fs_hash) if raw_pkg_list: logger.debug('Loading packages from cache: layer \"%s\"', layer.fs_hash[:10]) for pkg_dict in raw_pkg_list: pkg = Package(pkg_dict['name']) pkg.fill(pkg_dict) # collect package origins if 'origins' in pkg_dict.keys(): for origin_dict in pkg_dict['origins']: for notice in origin_dict['notices']: pkg.origins.add_notice_to_origins( origin_dict['origin_str'], Notice(notice['message'], notice['level'])) layer.add_package(pkg) loaded = True return loaded