[LNT] Add json support to machine overview page

Michael Zolotukhin mzolotukhin at apple.com
Mon Dec 8 15:25:40 PST 2014


Hi,

This patch adds JSON-format for machine-overview page. Does it look good?

Thanks,
Michael

Index: lnt/server/ui/views.py
===================================================================
--- lnt/server/ui/views.py	(revision 223085)
+++ lnt/server/ui/views.py	(working copy)
@@ -172,6 +172,20 @@
             order_by(ts.Run.start_time.desc()))
     associated_runs = associated_runs.items()
     associated_runs.sort()
+    if bool(request.args.get('json')):
+        json_obj = dict()
+        machine_obj = ts.query(ts.Machine).filter(ts.Machine.id == id).one()
+        json_obj['name'] = machine_obj.name
+        json_obj['id'] = machine_obj.id
+        json_obj['runs'] = []
+        for t in ts.query(ts.Run):
+            json_obj['runs'].append((t.order.llvm_project_revision,
+                                     t.start_time,
+                                     t.end_time))
+        json_obj['tests'] = []
+        for test in ts.query(ts.Test).all():
+            json_obj['tests'].append((test.name, test.id))
+        return flask.jsonify(**json_obj)

     return render_template("v4_machine.html",
                            testsuite_name=g.testsuite_name, id=id,
Index: tests/server/ui/V4Pages.py
===================================================================
--- tests/server/ui/V4Pages.py	(revision 223085)
+++ tests/server/ui/V4Pages.py	(working copy)
@@ -38,6 +38,9 @@
     # Get a machine overview page.
     check_code(client, '/v4/nts/machine/1')

+    # Get a machine overview page in JSON format.
+    check_code(client, '/v4/nts/machine/1?json=true')
+
     # Get the order summary page.
     check_code(client, '/v4/nts/all_orders')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141208/497b8456/attachment.html>


More information about the llvm-commits mailing list