1 """ Suite related queries
3 @contact: Debian FTPMaster <ftpmaster@debian.org>
4 @copyright: 2014 Mark Hymers <mhy@debian.org>
5 @license: GNU General Public License version 2 or later
7 @newfield maps: Mapping, Mappings
13 from daklib.dbconn import DBConn, Suite
14 from dakweb.webregister import QueryRegister
17 @bottle.route('/suites')
20 Give information about all known suites.
22 @maps: name maps to Suite: in the release file
23 @maps: codename maps to Codename: in the release file.
24 @maps: dakname is an internal name and should not be relied upon.
26 @rtype: list of dictionaries
27 @return: Dictionaries made out of
37 s = DBConn().session()
39 q = q.order_by(Suite.suite_name)
42 ret.append({'name': p.release_suite_output,
43 'codename': p.codename,
44 'dakname': p.suite_name,
45 'archive': p.archive.archive_name,
46 'architectures': [x.arch_string for x in p.architectures],
47 'components': [x.component_name for x in p.components]})
51 return json.dumps(ret)
53 QueryRegister().register_path('/suites', suites)
55 @bottle.route('/suite/<suite>')
56 def suite(suite=None):
58 Gives information about a single suite. Note that this routine will look
59 up a suite first by the main suite_name, but then also by codename if no
60 suite is initially found. It can therefore be used to canonicalise suite
64 @param suite: Name or codename of the suite.
65 @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites.
67 @maps: name maps to Suite: in the release file
68 @maps: codename maps to Codename: in the release file.
69 @maps: dakname is an internal name and should not be relied upon.
72 @return: A dictionary of
82 return bottle.HTTPError(503, 'Suite not specified.')
84 # TODO: We should probably stick this logic into daklib/dbconn.py
87 s = DBConn().session()
89 q = q.filter(Suite.suite_name == suite)
92 # This would mean dak is misconfigured
94 return bottle.HTTPError(503, 'Multiple suites found: configuration error')
98 # Look it up by suite_name
99 q = s.query(Suite).filter(Suite.codename == suite)
101 # This would mean dak is misconfigured
103 return bottle.HTTPError(503, 'Multiple suites found: configuration error')
108 so = {'name': so.release_suite_output,
109 'codename': so.codename,
110 'dakname': so.suite_name,
111 'archive': so.archive.archive_name,
112 'architectures': [x.arch_string for x in so.architectures],
113 'components': [x.component_name for x in so.components]}
117 return json.dumps(so)
119 QueryRegister().register_path('/suite', suite)