summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2023-01-22 19:15:48 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2023-01-22 19:15:48 +0100
commit4f64fd88a9270b9a24b2669d8721772ee1b36fa4 (patch)
tree1f2660f8befb3fbf038fd9074bf6a4166d7b411a /app.py
parentcdcbab386a8c6428ba346b41a4155e92f04b1e16 (diff)
now we've got the whole flow, need to beautify the thing
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'app.py')
-rw-r--r--app.py81
1 files changed, 49 insertions, 32 deletions
diff --git a/app.py b/app.py
index f18f0b0..d525532 100644
--- a/app.py
+++ b/app.py
@@ -6,63 +6,80 @@ from urllib.request import urlopen
import urllib.error
import flask
-from flask import Flask, jsonify
+from flask import Flask, jsonify, redirect
from launchpadlib.launchpad import Launchpad
app = Flask(__name__)
+tmpdir = tempfile.TemporaryDirectory()
+
+launchpad = Launchpad.login_anonymously("just testing", "production", tmpdir.name, version="devel")
@app.route("/", methods=["GET"])
def index_root():
- tmpdir = tempfile.TemporaryDirectory()
-
- launchpad = Launchpad.login_anonymously("just testing", "production", tmpdir.name, version="devel")
- ogayot = launchpad.people["ogayot"]
-
- runs = []
-
- for ppa in ogayot.ppas:
- series_set = set()
- for source_pkg in ppa.getPublishedSources():
- series_set.add(source_pkg.distro_series.name)
+ return redirect("/ogayot", code=302)
- for series in series_set:
- RELEASE = series
- LPUSER = ogayot.name
- PPA = ppa.name
- try:
- runs.append(json.loads(urlopen(f"https://autopkgtest.ubuntu.com/results/autopkgtest-{RELEASE}-{LPUSER}-{PPA}/?format=json").read()))
- except urllib.error.HTTPError:
- pass
+@app.route("/<LPUSER>", methods=["GET"])
+def index_lpuser(LPUSER):
+ lpuser = launchpad.people[LPUSER]
- return jsonify(runs)
+ return jsonify([ppa.name for ppa in lpuser.ppas])
-@app.route("/<ppa_name>", methods=["GET"])
-def index_ppa(ppa_name):
- tmpdir = tempfile.TemporaryDirectory()
- launchpad = Launchpad.login_anonymously("just testing", "production", tmpdir.name, version="devel")
- ogayot = launchpad.people["ogayot"]
+@app.route("/<LPUSER>/<PPA>", methods=["GET"])
+def index_ppa(LPUSER, PPA):
+ lpuser = launchpad.people[LPUSER]
runs = []
- ppa = next(filter(lambda p: p.name == ppa_name, ogayot.ppas))
+ ppa = next(filter(lambda p: p.name == PPA, lpuser.ppas))
series_set = set()
for source_pkg in ppa.getPublishedSources():
series_set.add(source_pkg.distro_series.name)
for series in series_set:
RELEASE = series
- LPUSER = ogayot.name
- PPA = ppa.name
try:
- runs.append(json.loads(urlopen(f"https://autopkgtest.ubuntu.com/results/autopkgtest-{RELEASE}-{LPUSER}-{PPA}/?format=json").read()))
+ urlopen(f"https://autopkgtest.ubuntu.com/results/autopkgtest-{RELEASE}-{LPUSER}-{PPA}/?format=json").read()
except urllib.error.HTTPError:
- pass
+ continue
+
+ return jsonify(list(set([pkg.source_package_name for pkg in ppa.getPublishedSources()])))
+
+
+@app.route("/<LPUSER>/<PPA>/<PACKAGE>", methods=["GET"])
+def index_package(LPUSER, PPA, PACKAGE):
+ lpuser = launchpad.people[LPUSER]
+
+ runs = []
+
+ ppa = next(filter(lambda p: p.name == PPA, lpuser.ppas))
+ series_set = set()
+ for source_pkg in ppa.getPublishedSources():
+ if source_pkg.source_package_name != PACKAGE:
+ continue
+ series_set.add(source_pkg.distro_series.name)
+
+ return jsonify(list(series_set))
+
+
+@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}"
+ data = json.loads(urlopen(f"{autopkgtest_url_base}?format=json").read())
+ try:
+ data = json.loads(urlopen(f"https://autopkgtest.ubuntu.com/results/autopkgtest-{RELEASE}-{LPUSER}-{PPA}/?format=json").read())
+ except urllib.error.HTTPError:
+ return jsonify([])
+
+ arches_set = set()
+ for section in data:
+ arches_set.add(section["name"].split("/")[1])
+
+ return jsonify(list(arches_set))
- return jsonify(runs)
@app.route("/<LPUSER>/<PPA>/<PACKAGE>/<RELEASE>/<ARCH>")
def index_results(LPUSER, PPA, PACKAGE, RELEASE, ARCH):