summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Lane <iain.lane@canonical.com>2017-04-21 10:12:56 (GMT)
committerIain Lane <iain.lane@canonical.com>2017-04-21 10:57:28 (GMT)
commit49e6e401daff792c65880a3454a83096232aeb3c (patch)
tree14ce310a322e78a237e56f0dde7c8b71a7a63850
parent02dce0410f9b47f70f51e89c8721c68f45594eaf (diff)
web: Sort the Ubuntu releases
-rwxr-xr-xdeployment/charms/xenial/autopkgtest-web/hooks/install2
-rwxr-xr-xwebcontrol/browse.cgi21
-rw-r--r--webcontrol/templates/browse-statistics.html2
3 files changed, 21 insertions, 4 deletions
diff --git a/deployment/charms/xenial/autopkgtest-web/hooks/install b/deployment/charms/xenial/autopkgtest-web/hooks/install
index 8eccd68..0e474cb 100755
--- a/deployment/charms/xenial/autopkgtest-web/hooks/install
+++ b/deployment/charms/xenial/autopkgtest-web/hooks/install
@@ -5,7 +5,7 @@ juju-log 'Invoking charm-pre-install hooks'
[ -d exec.d ] && ( for f in exec.d/*/charm-pre-install; do [ -x $f ] && /bin/sh -c "$f"; done )
juju-log "Installing dependencies"
-apt-get install -y make git distro-info apache2 python3-amqplib python3-flask python3-flask-openid libjs-bootstrap libjs-jquery amqp-tools
+apt-get install -y make git distro-info apache2 python3-amqplib python3-distro-info python3-flask python3-flask-openid libjs-bootstrap libjs-jquery amqp-tools
juju-log "Checking out code"
cat <<EOF | su - ubuntu
diff --git a/webcontrol/browse.cgi b/webcontrol/browse.cgi
index d3eef91..aebafc4 100755
--- a/webcontrol/browse.cgi
+++ b/webcontrol/browse.cgi
@@ -8,6 +8,8 @@ import json
import configparser
import urllib.parse
import re
+import distro_info
+from collections import OrderedDict
import amqplib.client_0_8 as amqp
from wsgiref.handlers import CGIHandler
@@ -21,6 +23,8 @@ amqp_uri = None
AMQP_CONTEXTS = ['ubuntu', 'huge', 'ppa', 'upstream']
+ALL_UBUNTU_RELEASES = distro_info.UbuntuDistroInfo().all
+
def init_config():
global db_con, swift_container_url, amqp_uri
@@ -51,6 +55,18 @@ def get_test_id(release, arch, src):
def render(template, code=200, **kwargs):
+ # sort the values passed in, so that releases are in the right order
+ try:
+ release_arches = OrderedDict()
+ for k in sorted(kwargs['release_arches'], key=ALL_UBUNTU_RELEASES.index):
+ release_arches[k] = kwargs['release_arches'][k]
+ kwargs['release_arches'] = release_arches
+ except KeyError:
+ pass
+ try:
+ kwargs['releases'] = sorted(kwargs['releases'], key=ALL_UBUNTU_RELEASES.index)
+ except KeyError:
+ pass
return (flask.render_template(template,
base_url=flask.url_for('index_root'),
static_url=flask.url_for('static', filename='/'),
@@ -153,7 +169,8 @@ def get_queue_info():
queue_name = 'debci-%s-%s-%s' % (context, release, arch)
result.setdefault(context, {}).setdefault(release, {})[arch] = get_queue_requests(ch, queue_name)
all_arches.add(arch)
- return (sorted(release_arches.keys()), sorted(all_arches), result)
+
+ return (release_arches.keys(), sorted(all_arches), result)
def get_source_versions(db, release):
@@ -250,7 +267,7 @@ def package_overview(package, _=None):
return render('browse-package.html',
package=package,
- releases=sorted(results.keys()),
+ releases=results.keys(),
arches=sorted(arches),
results=results,
title_suffix='- %s' % package)
diff --git a/webcontrol/templates/browse-statistics.html b/webcontrol/templates/browse-statistics.html
index 43c04e2..fddcaa6 100644
--- a/webcontrol/templates/browse-statistics.html
+++ b/webcontrol/templates/browse-statistics.html
@@ -2,7 +2,7 @@
{% block content %}
<h1 class="page-header">Statistics</h1>
- {% for r in release_arches|sort %}
+ {% for r in release_arches %}
<h3 class="page-header">{{ r.capitalize() }}</h2>
<table class="table" style="width: auto">