Ejemplo n.º 1
0
    def process_data(self):
        if self.pkgs:
            log.debug("call proxy.install_select_pkgs")
            proxy.install_select_pkgs(self.pkgs)
            log.debug("done proxy.install_select_pkgs")
        else:
            log.debug("No pkgs to downloaded, just done")
            self.downgrade_done = True

        while True:
            if not self.downgrade_done:
                time.sleep(0.2)
                continue

            ppa_source_dict = get_ppa_source_dict()

            # Sort out the unique owner urls, so that the PPAs from same owner will only fetch key fingerprint only once
            key_fingerprint_dict = {}
            for url in self.urls:
                if url in ppa_source_dict:
                    id = ppa_source_dict[url]
                    key_fingerprint = SOURCE_PARSER.get_key_fingerprint(id)
                else:
                    key_fingerprint = ''

                owner, ppa_name = url.split('/')[3:5]

                if owner not in key_fingerprint_dict:
                    key_fingerprint_dict[owner] = key_fingerprint
            log.debug("Get the key_fingerprint_dict done: %s" % key_fingerprint_dict)

            for url in self.urls:
                owner, ppa_name = url.split('/')[3:5]
                key_fingerprint = key_fingerprint_dict[owner]

                self.set_progress_text(_('Removing key files...'))
                if not key_fingerprint:
                    try:
                        #TODO wrap the LP API or use library
                        owner, ppa_name = url.split('/')[3:5]
                        lp_url = 'https://launchpad.net/api/beta/~%s/+archive/%s' % (owner, ppa_name)
                        req =  Request(lp_url)
                        req.add_header("Accept","application/json")
                        lp_page = urlopen(req).read()
                        data = json.loads(lp_page)
                        key_fingerprint = data['signing_key_fingerprint']
                    except Exception, e:
                        log.error(e)
                        continue

                log.debug("Get the key fingerprint: %s", key_fingerprint)
                result = proxy.purge_source(url, key_fingerprint)
                log.debug("Set source: %s to %s" % (url, str(result)))

            self.removekey_done = True
            log.debug("removekey_done is True")
            break
Ejemplo n.º 2
0
    def process_data(self):
        if self.pkgs:
            proxy.install_select_pkgs(self.pkgs)
        else:
            self.downgrade_done = True

        ppa_source_dict = get_ppa_source_dict()

        # Sort out the unique owner urls, so that the PPAs from same owner will only fetch key fingerprint only once
        key_fingerprint_dict = {}
        for url in self.urls:
            if url in ppa_source_dict:
                id = ppa_source_dict[url]
                key_fingerprint = SOURCE_PARSER.get_key_fingerprint(id)
            else:
                key_fingerprint = ''

            owner, ppa_name = url.split('/')[3:5]

            if owner not in key_fingerprint_dict:
                key_fingerprint_dict[owner] = key_fingerprint

        for url in self.urls:
            owner, ppa_name = url.split('/')[3:5]
            key_fingerprint = key_fingerprint_dict[owner]

            self.set_progress_text(_('Removing key files...'))
            if not key_fingerprint:
                try:
                    #TODO wrap the LP API or use library
                    owner, ppa_name = url.split('/')[3:5]
                    lp_url = 'https://launchpad.net/api/beta/~%s/+archive/%s' % (
                        owner, ppa_name)
                    req = Request(lp_url)
                    req.add_header("Accept", "application/json")
                    lp_page = urlopen(req).read()
                    data = json.loads(lp_page)
                    key_fingerprint = data['signing_key_fingerprint']
                except Exception, e:
                    log.error(e)
                    continue

            log.debug("Get the key fingerprint: %s", key_fingerprint)
            result = proxy.purge_source(url, key_fingerprint)
            log.debug("Set source: %s to %s" % (url, str(result)))
Ejemplo n.º 3
0
 def process_data(self):
     proxy.install_select_pkgs(self.pkgs)