diff options
| -rw-r--r-- | app.py | 33 | ||||
| -rw-r--r-- | templates/list-arches.html | 5 | ||||
| -rw-r--r-- | templates/list-packages.html | 5 | ||||
| -rw-r--r-- | templates/list-ppas.html | 5 | ||||
| -rw-r--r-- | templates/list-series.html | 5 | 
5 files changed, 48 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>") diff --git a/templates/list-arches.html b/templates/list-arches.html new file mode 100644 index 0000000..d5f10fe --- /dev/null +++ b/templates/list-arches.html @@ -0,0 +1,5 @@ +<ul> +    {% for arch in arches %} +    <li><a href={{base_url}}/{{arch}}>{{arch}}</a></li> +    {% endfor %} +</ul> diff --git a/templates/list-packages.html b/templates/list-packages.html new file mode 100644 index 0000000..dc2c8b9 --- /dev/null +++ b/templates/list-packages.html @@ -0,0 +1,5 @@ +<ul> +    {% for pkg in packages %} +    <li><a href={{base_url}}/{{pkg}}>{{pkg}}</a></li> +    {% endfor %} +</ul> diff --git a/templates/list-ppas.html b/templates/list-ppas.html new file mode 100644 index 0000000..b89cf31 --- /dev/null +++ b/templates/list-ppas.html @@ -0,0 +1,5 @@ +<ul> +    {% for ppa in ppas %} +    <li><a href={{base_url}}/{{ppa}}>{{ppa}}</a></li> +    {% endfor %} +</ul> diff --git a/templates/list-series.html b/templates/list-series.html new file mode 100644 index 0000000..2948ae8 --- /dev/null +++ b/templates/list-series.html @@ -0,0 +1,5 @@ +<ul> +    {% for release in series %} +    <li><a href={{base_url}}/{{release}}>{{release}}</a></li> +    {% endfor %} +</ul> | 
