res = self.db.query("SELECT name FROM arches \
WHERE NOT name = ANY(%s)", ("noarch", "src"))
- return sorted((a.name for a in res), key=priority)
+ return iter(sorted((a.name for a in res), key=priority))
+
+ def exists(self, name):
+ # noarch doesn't really exist
+ if name == "noarch":
+ return False
+
+ res = self.db.get("SELECT 1 FROM arches \
+ WHERE name = %s", name)
+
+ if res:
+ return True
+
+ return False
def get_all(self, really=False):
query = "SELECT * FROM arches"
self.set_header("Content-Type", "text/plain")
arch = self.get_argument("arch", None)
- arch = self.pakfire.arches.get_by_name(arch)
-
- if not arch:
- raise tornado.web.HTTPError(400, "You must specify the architecture.")
+ if not arch or not self.backend.arches.exists(arch):
+ raise tornado.web.HTTPError(400, "You must specify a valid architecture")
ret = {
"type" : "mirrorlist",
# Select a list of preferred mirrors
for mirror in self.mirrors.get_for_location(self.current_address):
mirrors.append({
- "url" : "/".join((mirror.url, distro.identifier, repo.identifier, arch.name)),
+ "url" : "/".join((mirror.url, distro.identifier, repo.identifier, arch)),
"location" : mirror.country_code,
"preferred" : 1,
})
for mirror in remaining_mirrors:
mirrors.append({
- "url" : "/".join((mirror.url, distro.identifier, repo.identifier, arch.name)),
+ "url" : "/".join((mirror.url, distro.identifier, repo.identifier, arch)),
"location" : mirror.country_code,
"preferred" : 0,
})
continue
mirror = {
- "url" : "/".join((mirror.url, distro.identifier, repo.identifier, arch.name)),
+ "url" : "/".join((mirror.url, distro.identifier, repo.identifier, arch)),
"location" : mirror.country_code,
"preferred" : 0,
}