diff options
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 33 |
1 files changed, 28 insertions, 5 deletions
@@ -1,4 +1,5 @@ import io +from html import escape import json import tarfile import tempfile @@ -15,6 +16,8 @@ tmpdir = tempfile.TemporaryDirectory() launchpad = Launchpad.login_anonymously("just testing", "production", tmpdir.name, version="devel") +use_json = False + @app.route("/") def index_root(): return redirect("/ogayot", code=302) @@ -24,7 +27,12 @@ def index_root(): def index_lpuser(LPUSER): lpuser = launchpad.people[LPUSER] - return jsonify([ppa.name for ppa in lpuser.ppas]) + ppas = [ppa.name for ppa in lpuser.ppas] + if use_json: + return jsonify(ppas) + else: + return flask.render_template("list-ppas.html", ppas=ppas, + base_url=flask.request.base_url) @app.route("/<LPUSER>/<PPA>") @@ -33,7 +41,12 @@ def index_ppa(LPUSER, PPA): ppa = next(filter(lambda p: p.name == PPA, lpuser.ppas)) - return jsonify(list(set([pkg.source_package_name for pkg in ppa.getPublishedSources()]))) + packages = list(set([pkg.source_package_name for pkg in ppa.getPublishedSources()])) + if use_json: + return jsonify(packages) + else: + return flask.render_template("list-packages.html", packages=packages, + base_url=flask.request.base_url) @app.route("/<LPUSER>/<PPA>/<PACKAGE>") @@ -49,7 +62,12 @@ def index_package(LPUSER, PPA, PACKAGE): continue series_set.add(source_pkg.distro_series.name) - return jsonify(list(series_set)) + series = list(series_set) + if use_json: + return jsonify(series) + else: + return flask.render_template("list-series.html", series=series, + base_url=flask.request.base_url) @app.route("/<LPUSER>/<PPA>/<PACKAGE>/<RELEASE>") @@ -58,13 +76,18 @@ def index_release(LPUSER, PPA, PACKAGE, RELEASE): try: data = json.loads(urlopen(f"https://autopkgtest.ubuntu.com/results/autopkgtest-{RELEASE}-{LPUSER}-{PPA}/?format=json").read()) except urllib.error.HTTPError: - return jsonify([]) + data = [] arches_set = set() for section in data: arches_set.add(section["name"].split("/")[1]) - return jsonify(list(arches_set)) + arches = list(arches_set) + if use_json: + return jsonify(arches) + else: + return flask.render_template("list-arches.html", arches=arches, + base_url=flask.request.base_url) @app.route("/<LPUSER>/<PPA>/<PACKAGE>/<RELEASE>/<ARCH>") |