]> git.decadent.org.uk Git - dak.git/commitdiff
Add initial suites and archives routines
authorMark Hymers <mhy@debian.org>
Fri, 7 Nov 2014 16:57:10 +0000 (16:57 +0000)
committerMark Hymers <mhy@debian.org>
Fri, 7 Nov 2014 16:57:10 +0000 (16:57 +0000)
Signed-off-by: Mark Hymers <mhy@debian.org>
dakweb/dakwebserver.py
dakweb/queries/archive.py [new file with mode: 0644]
dakweb/queries/suite.py [new file with mode: 0644]

index e6f71810e73f4d0f4c1ccabc7dbbc7cc16b01788..24c729cc6f7a0d33b489f9fa9b98d5f46f9239b2 100755 (executable)
@@ -32,7 +32,9 @@ def path_help(path=None):
 QueryRegister().register_path('/path_help', list_paths)
 
 # Import our other methods
+from queries.archive import *
 from queries.source import *
+from queries.suite import *
 
 # Set up our initial database connection
 d = DBConn()
diff --git a/dakweb/queries/archive.py b/dakweb/queries/archive.py
new file mode 100644 (file)
index 0000000..41c36a2
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import bottle
+import json
+
+from daklib.dbconn import DBConn, Archive
+from dakweb.webregister import QueryRegister
+
+@bottle.route('/archives')
+def archives():
+    """
+    Returns a list of supported archives
+    """
+
+    s = DBConn().session()
+    q = s.query(Archive)
+    q = q.order_by(Archive.archive_name)
+    ret = []
+    for a in q:
+        ret.append({'name':      a.archive_name,
+                    'suites':    [x.suite_name for x in a.suites]})
+
+    return json.dumps(ret)
+
+QueryRegister().register_path('/archives', archives)
+
diff --git a/dakweb/queries/suite.py b/dakweb/queries/suite.py
new file mode 100644 (file)
index 0000000..9b37e69
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+
+import bottle
+import json
+
+from daklib.dbconn import DBConn, Suite
+from dakweb.webregister import QueryRegister
+
+@bottle.route('/suites')
+def suites():
+    """
+    Returns a list of all suites
+    """
+
+    s = DBConn().session()
+    q = s.query(Suite)
+    q = q.order_by(Suite.suite_name)
+    ret = []
+    for p in q:
+        ret.append({'name':       p.suite_name,
+                    'codename':   p.codename,
+                    'archive':    p.archive.archive_name,
+                    'architectures': [x.arch_string for x in p.architectures],
+                    'components': [x.component_name for x in p.components]})
+
+    return json.dumps(ret)
+
+QueryRegister().register_path('/suites', suites)
+