def _appcenter_caches(self, args): if args.appcenter_server: return [AppCenterCache(server=args.appcenter_server)] else: ret = [] servers = set() for appcenter_cache in Apps().get_appcenter_caches(): server = appcenter_cache.get_server() if server not in servers: servers.add(server) ret.append(appcenter_cache) return ret
def suggestions(self, version): try: cache = AppCenterCache.build(server=default_server()) cache_file = cache.get_cache_file('.suggestions.json') with open(cache_file) as fd: json = load(fd) except (EnvironmentError, ValueError): raise umcm.UMC_Error(_('Could not load suggestions.')) else: try: return json[version] except (KeyError, AttributeError): raise umcm.UMC_Error(_('Unexpected suggestions data.'))
def local_appcenter(): setup_local_appcenter = get_action("dev-setup-local-appcenter") ucs_versions = AppCenterCache().get_ucs_versions() print("Setting up local app-center for UCS versions = %r." % (ucs_versions, )) for ucs_version in ucs_versions: setup_local_appcenter.call(ucs_version=ucs_version) try: yield except Exception: raise finally: print("Reverting local app-center.") setup_local_appcenter.call(revert=True)
def get_blocking_apps(cls, ucs_version): ''' checks if update is possible for this app ''' ucs_version = UCS_Version(ucs_version + '-0') next_minor = '%(major)d.%(minor)d' % ucs_version next_version = '%(major)d.%(minor)d-%(patchlevel)d' % ucs_version current_version = UCS_Version(ucr_get('version/version') + '-0') current_minor = '%(major)d.%(minor)d' % current_version # if this is just a patchlevel update, everything is fine if current_minor >= next_minor: return {} # first, update the local cache and get current apps update = get_action('update') update.logger = get_logfile_logger('update-check') update.call() current_cache = Apps(locale='en') # get apps in next version with TemporaryDirectory() as tempdir: update.call(ucs_version=next_minor, cache_dir=tempdir, just_get_cache=True) next_cache = AppCenterCache.build(ucs_versions=next_minor, server=default_server(), locale='en', cache_dir=tempdir) next_apps = next_cache.get_every_single_app() # check apps blocking_apps = dict() for app in current_cache.get_all_locally_installed_apps(): if not cls.app_can_update(app, next_version, next_apps): cls.debug('app %s is not available for %s' % (app.id, next_version)) blocking_apps[app.component_id] = app.name else: cls.debug('app %s is available for %s' % (app.id, next_version)) return blocking_apps