def do_update_key_info(config, ticket, fingerprint, xml): try: ki = pending_key_info.get(fingerprint, None) if ki: from xml.dom import minidom doc = minidom.parseString(qdom.to_UTF8(xml)) ki.info = doc.documentElement.childNodes ki.blocker.trigger() ki.blocker = None else: logger.info("Unexpected key info for %s (not in %s)", fingerprint, pending_key_info) except Exception as ex: logger.warning("do_update_key_info", exc_info = True) send_json(["return", ticket, ["error", str(ex)]])
def import_feed(self, url, contents): """contents can be a path or an Element.""" iface_cache = self.config.iface_cache iface_cache.get_interface(url) if isinstance(contents, qdom.Element): feed = model.ZeroInstallFeed(contents) else: feed = reader.load_feed(contents) iface_cache._feeds[url] = feed xml = qdom.to_UTF8(feed.feed_element) upstream_dir = basedir.save_cache_path(namespaces.config_site, "interfaces") cached = os.path.join(upstream_dir, model.escape(url)) with open(cached, "wb") as stream: stream.write(xml) return feed
def do_confirm_keys(config, ticket, url, xml): try: if gui_driver is not None: config = gui_driver.config fingerprints = [] #valid_sigs = [ for (fingerprint, info) in infos] pending = PendingFromOCaml(url = url, sigs = []) global pending_key_info pending_key_info = {} key_infos = {} for result in xml.childNodes: fingerprint = result.attrs['fingerprint'] fingerprints.append(fingerprint) sig = gpg.ValidSig([fingerprint, None, 0]) ki = OCamlKeyInfo() if 'pending' in result.attrs: ki.blocker = tasks.Blocker("Getting info for key '%s'" % fingerprint) elif 'error' in result.attrs: from xml.dom import minidom doc = minidom.parseString('<item vote="bad"/>') root = doc.documentElement root.appendChild(doc.createTextNode(_('Error getting key information: %s') % result.attrs['error'])) ki.info = [root] else: from xml.dom import minidom doc = minidom.parseString(qdom.to_UTF8(result)) ki.info = doc.documentElement.childNodes key_infos[sig] = ki pending_key_info[fingerprint] = ki confirmed_keys = [] blocker = config.handler.confirm_import_feed(pending, key_infos, confirmed_keys) if blocker: yield blocker tasks.check(blocker) send_json(["return", ticket, ["ok", confirmed_keys]]) except Exception as ex: logger.warning("do_confirm_keys", exc_info = True) send_json(["return", ticket, ["error", str(ex)]])