diff options
-rw-r--r-- | app.py | 31 |
1 files changed, 13 insertions, 18 deletions
@@ -1,5 +1,4 @@ import io -from html import escape import json import tarfile import tempfile @@ -30,9 +29,8 @@ def index_lpuser(LPUSER): 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) + return flask.render_template("list-ppas.html", ppas=ppas, + base_url=flask.request.base_url) @app.route("/<LPUSER>/<PPA>") @@ -44,9 +42,8 @@ def index_ppa(LPUSER, PPA): 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) + return flask.render_template("list-packages.html", packages=packages, + base_url=flask.request.base_url) @app.route("/<LPUSER>/<PPA>/<PACKAGE>") @@ -65,16 +62,15 @@ def index_package(LPUSER, PPA, PACKAGE): 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) + return flask.render_template("list-series.html", series=series, + base_url=flask.request.base_url) @app.route("/<LPUSER>/<PPA>/<PACKAGE>/<RELEASE>") def index_release(LPUSER, PPA, PACKAGE, RELEASE): autopkgtest_url_base = f"https://autopkgtest.ubuntu.com/results/autopkgtest-{RELEASE}-{LPUSER}-{PPA}" try: - data = json.loads(urlopen(f"https://autopkgtest.ubuntu.com/results/autopkgtest-{RELEASE}-{LPUSER}-{PPA}/?format=json").read()) + data = json.loads(urlopen(f"{autopkgtest_url_base}?format=json").read()) except urllib.error.HTTPError: data = [] @@ -85,9 +81,8 @@ def index_release(LPUSER, PPA, PACKAGE, RELEASE): 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) + return flask.render_template("list-arches.html", arches=arches, + base_url=flask.request.base_url) @app.route("/<LPUSER>/<PPA>/<PACKAGE>/<RELEASE>/<ARCH>") @@ -104,11 +99,11 @@ def index_results(LPUSER, PPA, PACKAGE, RELEASE, ARCH): if suffix != "result.tar": continue runs[index] = info - + headers = ("version", "triggers", "date", "duration", "requester", "result", "url_prefix") package_results = [] for idx, info in runs.items(): - date = " ".join(idx.split("/")[-1].split("_")[0:2]), + date = " ".join(idx.split("/")[-1].split("_")[0:2]) tar_stream = io.BytesIO(urlopen(f"{autopkgtest_url_base}/{info['name']}").read()) file = tarfile.open(fileobj=tar_stream) exitcode = int(file.extractfile("exitcode").read().decode().splitlines()[0]) @@ -127,7 +122,7 @@ def index_results(LPUSER, PPA, PACKAGE, RELEASE, ARCH): result = { "version": version, "triggers": triggers, - "date": " ".join(idx.split("/")[-1].split("_")[0:2]), + "date": date, "duration": duration, "requester": requester, "result": exitcode, @@ -136,7 +131,7 @@ def index_results(LPUSER, PPA, PACKAGE, RELEASE, ARCH): package_results.append([result[h] for h in headers]) - return flask.render_template("browse-results.html", + return flask.render_template("browse-results.html", package=PACKAGE, release=RELEASE, arch=ARCH, |