From aed7e4798d61c491c709f079645b1ad22957cdbd Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Fri, 7 Nov 2014 16:57:10 +0000 Subject: [PATCH] Add initial suites and archives routines Signed-off-by: Mark Hymers --- dakweb/dakwebserver.py | 2 ++ dakweb/queries/archive.py | 26 ++++++++++++++++++++++++++ dakweb/queries/suite.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 dakweb/queries/archive.py create mode 100644 dakweb/queries/suite.py diff --git a/dakweb/dakwebserver.py b/dakweb/dakwebserver.py index e6f71810..24c729cc 100755 --- a/dakweb/dakwebserver.py +++ b/dakweb/dakwebserver.py @@ -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 index 00000000..41c36a2a --- /dev/null +++ b/dakweb/queries/archive.py @@ -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 index 00000000..9b37e691 --- /dev/null +++ b/dakweb/queries/suite.py @@ -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) + -- 2.39.5