Exemplo n.º 1
0
    def update(self):
        """ Update installed plugins. """
        self.args.ignored = [e.lower() for e in self.args.ignored]

        self.p_main('Finding installed plugins')

        installed = backend.list_plugins()

        self.p_main('Looking up versions on BukGet')

        to_update = list()
        for i in installed:
            if i['plugin_name'].lower() in self.args.ignored:
                self.p_sub('Ignoring {}', i['plugin_name'])
                continue
            n_version = utils.select_newest_version(i, self.args.version)
            if n_version is None:
                continue
            i_version = utils.select_installed_version(i)
            if n_version['version'] > i_version['version']:
                to_update.append(i)

        self.p_main('Plugins to update:')
        self.p_blank()

        if len(to_update) < 1:
            self.p_sub('All plugins are up to date!')
            self.p_sub(('Maybe you want a pre-release? Try passing --beta, '
                        '--alpha or even --latest as command options'))
            self.p_blank()
            return

        self.p_sub(
            common.list_names([
                p['plugin_name'] + '#' + p['versions'][0]['version']
                for p in to_update
            ]))
        self.p_blank()

        if common.ask('Continue to update?', skip=self.args.no_confirm):
            prefix_format = '({{part:>{}}}/{{total}}) '.format(
                len(str(len(to_update))))
            for i in range(len(to_update)):
                plugin = to_update[i]
                os.remove(plugin['installed_file'])
                prefix = prefix_format.format(total=len(to_update), part=i + 1)
                backend.download_plugin(plugin, prefix)
            self.p_blank()
            self.p_raw('Done!')
Exemplo n.º 2
0
    def update(self):
        """ Update installed plugins. """
        self.args.ignored = [e.lower() for e in self.args.ignored]

        self.p_main('Finding installed plugins')

        installed = backend.list_plugins()

        self.p_main('Looking up versions on BukGet')

        to_update = list()
        for i in installed:
            if i['plugin_name'].lower() in self.args.ignored:
                self.p_sub('Ignoring {}',
                           i['plugin_name'])
                continue
            n_version = utils.select_newest_version(i, self.args.version)
            if n_version is None:
                continue
            i_version = utils.select_installed_version(i)
            if n_version['version'] > i_version['version']:
                to_update.append(i)

        self.p_main('Plugins to update:')
        self.p_blank()

        if len(to_update) < 1:
            self.p_sub('All plugins are up to date!')
            self.p_sub(('Maybe you want a pre-release? Try passing --beta, '
                        '--alpha or even --latest as command options'))
            self.p_blank()
            return

        self.p_sub(common.list_names([p['plugin_name'] + '#'
                                      + p['versions'][0]['version']
                                      for p in to_update]))
        self.p_blank()

        if common.ask('Continue to update?', skip=self.args.no_confirm):
            prefix_format = '({{part:>{}}}/{{total}}) '.format(
                len(str(len(to_update))))
            for i in range(len(to_update)):
                plugin = to_update[i]
                os.remove(plugin['installed_file'])
                prefix = prefix_format.format(total=len(to_update), part=i+1)
                backend.download_plugin(plugin, prefix)
            self.p_blank()
            self.p_raw('Done!')
Exemplo n.º 3
0
    def run(self):
        """ Run the command. """
        self.p_main('Saving {} to {}'.format(
            common.list_names(self.args.types), self.args.output.name))

        plugins = dict()
        servers = dict()

        if 'plugins' in self.args.types:
            self.p_main('Finding plugins')
            for plugin in p_backend.list_plugins():
                version = p_utils.select_installed_version(plugin)
                plugins[plugin['installed_file']] = (plugin['slug'],
                                                     version['slug'])
        if 'servers' in self.args.types:
            self.p_main('Finding servers')
            servers = s_backend.list_servers()

        self.p_main('Writing file')
        document = dict()
        document['servers'] = list()
        for file, key in servers.items():
            server = dict()
            server['id'] = key
            server['file'] = file

            document['servers'].append(server)

        document['plugins'] = list()
        for file, (slug, version) in plugins.items():
            plugin = dict()
            plugin['file'] = file
            plugin['slug'] = slug
            plugin['version-slug'] = version

            document['plugins'].append(plugin)

        self.args.output.write(json.dumps(document))
        self.args.output.write('\n')
Exemplo n.º 4
0
    def run(self):
        """ Run the command. """
        self.p_main('Saving {} to {}'.format(
            common.list_names(self.args.types), self.args.output.name))

        plugins = dict()
        servers = dict()

        if 'plugins' in self.args.types:
            self.p_main('Finding plugins')
            for plugin in p_backend.list_plugins():
                version = p_utils.select_installed_version(plugin)
                plugins[plugin['installed_file']] = (plugin['slug'],
                                                     version['slug'])
        if 'servers' in self.args.types:
            self.p_main('Finding servers')
            servers = s_backend.list_servers()

        self.p_main('Writing file')
        document = dict()
        document['servers'] = list()
        for file, key in servers.items():
            server = dict()
            server['id'] = key
            server['file'] = file

            document['servers'].append(server)

        document['plugins'] = list()
        for file, (slug, version) in plugins.items():
            plugin = dict()
            plugin['file'] = file
            plugin['slug'] = slug
            plugin['version-slug'] = version

            document['plugins'].append(plugin)

        self.args.output.write(json.dumps(document))
        self.args.output.write('\n')