def update_plugin(self, plugin_controller, verbose=False, force=False):
        app = get_app()
        server_url = app.get_app_value('server_url')
        plugin_metadata = plugin_controller.get_plugin_info()
        package_name = plugin_metadata.package_name
        plugin_name = plugin_metadata.plugin_name

        p = PluginRepository(server_url)
        latest_version = Version(**p.latest_version(package_name,
                                                    app_version={'major': 1,
                                                                 'minor': 0,
                                                                 'micro': 0}))

        # Check the plugin tag versus the tag of latest version from the
        # update respository. If they are different, it's a sign that they
        # the currently installed plugin may be incompatible.
        if plugin_controller.version.tags != latest_version.tags:
            if yesno('The currently installed plugin (%s-%s) is from a '
                     'different branch and may not be compatible with '
                     'this version of Microdrop. Would you like to download '
                     'a compatible version?' % (plugin_name,
                                                plugin_controller.version)
                     ) == gtk.RESPONSE_YES:
                return self.download_and_install_plugin(package_name,
                                                        force=force)
        elif plugin_controller.version < latest_version:
            return self.download_and_install_plugin(package_name, force=force)
        else:
            message = 'Plugin %s is up to date (version %s)' % (
                plugin_name, plugin_controller.version)
            if verbose:
                logging.warning(message)
            logging.info(message)
            return False
Example #2
0
 def download_and_install_plugin(self, package_name, force=False):
     temp_dir = path(tempfile.mkdtemp(prefix='microdrop_plugin_update'))
     try:
         app = get_app()
         server_url = app.get_app_value('server_url')
         plugin_repo = PluginRepository(server_url)
         plugin_repo.download_latest(package_name, temp_dir,
                                     app_version=APP_VERSION)
         archive_path = temp_dir.files()[0]
         return self.install_from_archive(archive_path, force=force)
     finally:
         temp_dir.rmtree()
     return False
Example #3
0
    def update_plugin(self, plugin_controller, verbose=False, force=False):
        app = get_app()
        server_url = app.get_app_value('server_url')
        plugin_metadata = plugin_controller.get_plugin_info()
        package_name = plugin_metadata.package_name
        plugin_name = plugin_metadata.plugin_name

        plugin_repo = PluginRepository(server_url)
        latest_version = Version(**plugin_repo
                                 .latest_version(package_name,
                                                 app_version=APP_VERSION))

        # Check the plugin tag versus the tag of latest version from the
        # update respository. If they are different, it's a sign that they
        # the currently installed plugin may be incompatible.
        if plugin_controller.version.tags != latest_version.tags:
            if yesno('The currently installed plugin (%s-%s) is from a '
                     'different branch and may not be compatible with '
                     'this version of MicroDrop. Would you like to download '
                     'a compatible version?' % (plugin_name,
                                                plugin_controller.version)
                     ) == gtk.RESPONSE_YES:
                return self.download_and_install_plugin(package_name,
                                                        force=force)
        elif plugin_controller.version < latest_version:
            return self.download_and_install_plugin(package_name, force=force)
        else:
            message = 'Plugin %s is up to date (version %s)' % (
                plugin_name, plugin_controller.version)
            if verbose:
                logging.warning(message)
            logging.info(message)
            return False
Example #4
0
def get_latest_version_content(server_url=DEFAULT_SERVER_URL):
    app_repo = AppRepository(server_url)

    plugin_repo = PluginRepository(server_url)

    plugin_info = OrderedDict(
        [
            (p, (plugin_repo.latest_version(p), plugin_repo.latest_package_url(p)))
            for p in plugin_repo.available_packages()
        ]
    )

    content = StringIO()

    # # Microdrop application #
    print >> content, "# Microdrop application installer #\n"

    app_info = (app_repo.latest_version("microdrop"), app_repo.latest_package_url("microdrop"))
    app_name = "microdrop"

    print >> content, " * [`%s` *(%s.%s.%s)*][%s]" % (
        app_name,
        app_info[0]["major"],
        app_info[0]["minor"],
        app_info[0]["micro"],
        app_name,
    )

    print >> content, "\n[%s]: %s%s" % (app_name, app_repo.server_url, app_info[1])

    print >> content, ""

    # # Microdrop plugins #
    print >> content, "# Plugins #\n"
    for name, info in plugin_info.iteritems():
        print >> content, " * [`%s` *(%s.%s.%s)*][%s]" % (
            name,
            info[0]["major"],
            info[0]["minor"],
            info[0]["micro"],
            name,
        )
    print >> content, ""
    for name, info in plugin_info.iteritems():
        print >> content, "[%s]: %s%s" % (name, plugin_repo.server_url, info[1])

    return content.getvalue()
Example #5
0
def get_latest_version_content(server_url=DEFAULT_SERVER_URL):
    app_repo = AppRepository(server_url)

    plugin_repo = PluginRepository(server_url)

    plugin_info = OrderedDict([(p, (plugin_repo.latest_version(p),
                                    plugin_repo.latest_package_url(p)))
                               for p in plugin_repo.available_packages()])

    content = StringIO()

    # # MicroDrop application #
    print >> content, '# MicroDrop application installer #\n'

    app_info = (app_repo.latest_version('microdrop'),
                app_repo.latest_package_url('microdrop'))
    app_name = 'microdrop'

    print >> content, ' * [`%s` *(%s.%s.%s)*][%s]' % (app_name,
                                                      app_info[0]['major'],
                                                      app_info[0]['minor'],
                                                      app_info[0]['micro'],
                                                      app_name)

    print >> content, '\n[%s]: %s%s' % (app_name, app_repo.server_url,
                                        app_info[1])

    print >> content, ''

    # # MicroDrop plugins #
    print >> content, '# Plugins #\n'
    for name, info in plugin_info.iteritems():
        print >> content, ' * [`%s` *(%s.%s.%s)*][%s]' % (name,
                                                          info[0]['major'],
                                                          info[0]['minor'],
                                                          info[0]['micro'],
                                                          name)
    print >> content, ''
    for name, info in plugin_info.iteritems():
        print >> content, '[%s]: %s%s' % (name, plugin_repo.server_url,
                                          info[1])

    return content.getvalue()
    def update(self):
        app = get_app()
        self.clear_plugin_list()
        self.controller.update()

        server_url = app.get_app_value('server_url')
        p = PluginRepository(server_url)
        available = set(p.available_packages(app_version={'major': 1,
                                                          'minor': 0,
                                                          'micro': 0}))
        installed = set([p.get_plugin_package_name()
                for p in self.controller.plugins])
        to_install = available.difference(installed)
        if not to_install:
            return None
        self.list_select_view = ListSelectView(sorted(to_install),
                'plugin_name')
        self.vbox_plugins.pack_start(self.list_select_view.widget)
        self.vbox_plugins.show_all()
        return True
Example #7
0
def get_latest_version_content(server_url=DEFAULT_SERVER_URL):
    app_repo = AppRepository(server_url)

    plugin_repo = PluginRepository(server_url)

    plugin_info = OrderedDict([(p, (plugin_repo.latest_version(p),
                                    plugin_repo.latest_package_url(p)))
                               for p in plugin_repo.available_packages()])

    content = StringIO()

    # # MicroDrop application #
    print >> content, '# MicroDrop application installer #\n'

    app_info = (app_repo.latest_version('microdrop'),
                app_repo.latest_package_url('microdrop'))
    app_name = 'microdrop'

    print >> content, ' * [`%s` *(%s.%s.%s)*][%s]' % (
        app_name, app_info[0]['major'], app_info[0]['minor'],
        app_info[0]['micro'], app_name)

    print >> content, '\n[%s]: %s%s' % (app_name, app_repo.server_url,
                                        app_info[1])

    print >> content, ''

    # # MicroDrop plugins #
    print >> content, '# Plugins #\n'
    for name, info in plugin_info.iteritems():
        print >> content, ' * [`%s` *(%s.%s.%s)*][%s]' % (
            name, info[0]['major'], info[0]['minor'], info[0]['micro'], name)
    print >> content, ''
    for name, info in plugin_info.iteritems():
        print >> content, '[%s]: %s%s' % (name, plugin_repo.server_url,
                                          info[1])

    return content.getvalue()
Example #8
0
    def update(self):
        app = get_app()
        self.clear_plugin_list()
        self.controller.update()

        server_url = app.get_app_value('server_url')
        plugin_repo = PluginRepository(server_url)
        # Only plugins with the same *major* version will be returned.
        available = set(plugin_repo
                        .available_packages(app_version=APP_VERSION))
        installed = set([p.get_plugin_package_name()
                         for p in self.controller.plugins])
        to_install = available.difference(installed)
        if not to_install:
            return None
        self.list_select_view = ListSelectView(sorted(to_install),
                'plugin_name')
        self.vbox_plugins.pack_start(self.list_select_view.widget)
        self.vbox_plugins.show_all()
        return True