コード例 #1
0
 def main(self, args):
     something_changed = False
     for app_cache in self._app_caches(args):
         # first of all, set up local cache
         mkdir(app_cache.get_cache_dir())
         if self._extract_local_archive(app_cache):
             something_changed = True
     for appcenter_cache in self._appcenter_caches(args):
         # download meta files like index.json
         mkdir(appcenter_cache.get_cache_dir())
         if self._download_supra_files(appcenter_cache):
             appcenter_cache.clear_cache()
             something_changed = True
     for app_cache in self._app_caches(args):
         # try it one more time (ucs.ini may have changed)
         mkdir(app_cache.get_cache_dir())
         if self._extract_local_archive(app_cache):
             something_changed = True
         # download apps based on meta files
         if self._download_apps(app_cache):
             app_cache.clear_cache()
             something_changed = True
     if something_changed:
         apps_cache = Apps()
         for app in apps_cache.get_all_locally_installed_apps():
             newest_app = apps_cache.find_candidate(app) or app
             if app < newest_app:
                 ucr_save({app.ucr_upgrade_key: 'yes'})
         self._update_local_files()
コード例 #2
0
    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