示例#1
0
    def do_source_operation(self, enable_str, source_json, *args):
        enable = int(enable_str)
        source = json.loads(source_json)
        distro = source['distro_value']
        log.debug("Enable? %s for source: %s for distro: %s" % (enable, source['name'], distro))

        if ppa.is_ppa(source['url']):
            file_name = '%s-%s' % (ppa.get_source_file_name(source['url']), distro)
        else:
            file_name = source['slug']

        # TODO these kinds of source should never be featured
        if not source['component'] and distro:
            distro = distro + '/'
        elif not source['component'] and not distro:
            distro = './'

        try:
            result = proxy.set_separated_entry(source['url'], distro, source['component'],
                                               source['summary'], enable, file_name)
            log.debug("Enable source: %s result: %s" % (source['name'], result))
            if source['key']:
                proxy.add_apt_key_from_content(source['key'])

            if result == 'enabled':
                notify = Notify.Notification(summary=_('New source has been enabled'),
                                             body=_('"%s" is enabled now, Please click the update button to update %s') % (source['name'], self.current_app))
                notify.set_property('icon-name', 'ubuntu-tweak')
                notify.set_hint_string("x-canonical-append", "true")
                notify.show()

                self.update_action_button(self.UPDATE_ACTION)
        except Exception, e:
            log.error(e)
            self.update_sources()
示例#2
0
    def set_enable(self, key, enable):
        # To make other module use the source enable feature, move the logical to here
        # So that other module can call
        gpg_key = self.get_key(key)
        url = self.get_url(key)
        distro = self.get_distro(key)
        comps = self.get_comps(key)
        comment = self.get_name(key)

        if ppa.is_ppa(url):
            file_name = '%s-%s' % (ppa.get_source_file_name(url), distro)
        else:
            file_name = self.get_slug(key)

        if gpg_key:
            proxy.add_apt_key_from_content(gpg_key)

        if not comps and distro:
            distro = distro + '/'
        elif not comps and not distro:
            distro = './'

        result = proxy.set_separated_entry(url, distro, comps,
                                           comment, enable, file_name)

        return str(result)
示例#3
0
    def do_source_operation(self, enable_str, source_json, *args):
        enable = int(enable_str)
        source = json.loads(source_json)
        distro = source['distro_value']
        log.debug("Enable? %s for source: %s for distro: %s" % (enable, source['name'], distro))

        if ppa.is_ppa(source['url']):
            file_name = '%s-%s' % (ppa.get_source_file_name(source['url']), distro)
        else:
            file_name = source['slug']

        # TODO these kinds of source should never be featured
        if not source['component'] and distro:
            distro = distro + '/'
        elif not source['component'] and not distro:
            distro = './'

        try:
            result = proxy.set_separated_entry(source['url'], distro, source['component'],
                                               source['summary'], enable, file_name)
            log.debug("Enable source: %s result: %s" % (source['name'], result))
            if source['key']:
                proxy.add_apt_key_from_content(source['key'])

            if result == 'enabled':
                notify = Notify.Notification(summary=_('New source has been enabled'),
                                             body=_('"%s" is enabled now, Please click the update button to update %s') % (source['name'], self.current_app))
                notify.set_property('icon-name', 'ubuntu-tweak')
                notify.set_hint_string("x-canonical-append", "true")
                notify.show()

                self.update_action_button(self.UPDATE_ACTION)
        except Exception, e:
            log.error(e)
            self.update_sources()
示例#4
0
    def set_enable(self, key, enable):
        # To make other module use the source enable feature, move the logical to here
        # So that other module can call
        gpg_key = self.get_key(key)
        url = self.get_url(key)
        distro = self.get_distro(key)
        comps = self.get_comps(key)
        comment = self.get_name(key)

        if ppa.is_ppa(url):
            file_name = '%s-%s' % (ppa.get_source_file_name(url), distro)
        else:
            file_name = self.get_slug(key)

        if gpg_key:
            proxy.add_apt_key_from_content(gpg_key)

        if not comps and distro:
            distro = distro + '/'
        elif not comps and not distro:
            distro = './'

        result = proxy.set_separated_entry(url, distro, comps, comment, enable,
                                           file_name)

        return str(result)
示例#5
0
    def do_source_operation(self, enable_str, source_json, *args):
        enable = int(enable_str)
        source = json.loads(source_json)
        distro = source["distro_value"]
        log.debug("Enable? %s for source: %s for distro: %s" % (enable, source["name"], distro))

        if ppa.is_ppa(source["url"]):
            file_name = "%s-%s" % (ppa.get_source_file_name(source["url"]), distro)
        else:
            file_name = source["slug"]

        # TODO these kinds of source should never be featured
        if not source["component"] and distro:
            distro = distro + "/"
        elif not source["component"] and not distro:
            distro = "./"

        try:
            result = proxy.set_separated_entry(
                source["url"], distro, source["component"], source["summary"], enable, file_name
            )
            log.debug("Enable source: %s result: %s" % (source["name"], result))
            if source["key"]:
                proxy.add_apt_key_from_content(source["key"])

            if result == "enabled":
                notify = Notify.Notification(
                    summary=_("New source has been enabled"),
                    body=_('"%s" is enabled now, Please click the update button to update %s')
                    % (source["name"], self.current_app),
                )
                notify.set_property("icon-name", "ubuntu-tweak")
                notify.set_hint_string("x-canonical-append", "true")
                notify.show()

                self.update_action_button(self.UPDATE_ACTION)
        except Exception, e:
            log.error(e)
            self.update_sources()