]> git.decadent.org.uk Git - dak.git/blobdiff - dakweb/queries/suite.py
Make release_team_removals.sh take input from stdin
[dak.git] / dakweb / queries / suite.py
index b5c0118c586ffc2d783eba7d1294f2927dedced9..5446f699b8f622d39a0bfbf1b7343de979bbc325 100644 (file)
@@ -1,4 +1,11 @@
-#!/usr/bin/python
+""" Suite related queries
+
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@copyright: 2014  Mark Hymers <mhy@debian.org>
+@license: GNU General Public License version 2 or later
+
+@newfield maps: Mapping, Mappings
+"""
 
 import bottle
 import json
@@ -6,18 +13,25 @@ import json
 from daklib.dbconn import DBConn, Suite
 from dakweb.webregister import QueryRegister
 
+
 @bottle.route('/suites')
 def suites():
     """
-    suites()
+    Give information about all known suites.
 
-    returns: list of dictionaries
+    @maps: name maps to Suite: in the release file
+    @maps: codename maps to Codename: in the release file.
+    @maps: dakname is an internal name and should not be relied upon.
 
-    Give information about all known suites.
+    @rtype: list of dictionaries
+    @return: Dictionaries made out of
+             - name
+             - codename
+             - dakname
+             - archive
+             - architectures
+             - components
 
-    name maps to Suite: in the release file
-    codename maps to Codename: in the release file.
-    dakname is an internal name and should not be relied upon.
     """
 
     s = DBConn().session()
@@ -32,6 +46,8 @@ def suites():
                     'architectures': [x.arch_string for x in p.architectures],
                     'components': [x.component_name for x in p.components]})
 
+    s.close()
+
     return json.dumps(ret)
 
 QueryRegister().register_path('/suites', suites)
@@ -39,14 +55,27 @@ QueryRegister().register_path('/suites', suites)
 @bottle.route('/suite/<suite>')
 def suite(suite=None):
     """
-    suite(suite)
-
-    returns: dictionary
-
     Gives information about a single suite.  Note that this routine will look
     up a suite first by the main suite_name, but then also by codename if no
     suite is initially found.  It can therefore be used to canonicalise suite
-    names
+    names.
+
+    @type suite: string
+    @param suite: Name or codename of the suite.
+    @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites.
+
+    @maps: name maps to Suite: in the release file
+    @maps: codename maps to Codename: in the release file.
+    @maps: dakname is an internal name and should not be relied upon.
+
+    @rtype: dictionary
+    @return: A dictionary of
+             - name
+             - codename
+             - dakname
+             - archive
+             - architectures
+             - components
     """
 
     if suite is None:
@@ -61,6 +90,7 @@ def suite(suite=None):
 
     if q.count() > 1:
         # This would mean dak is misconfigured
+        s.close()
         return bottle.HTTPError(503, 'Multiple suites found: configuration error')
     elif q.count() == 1:
         so = q[0]
@@ -69,6 +99,7 @@ def suite(suite=None):
         q = s.query(Suite).filter(Suite.codename == suite)
         if q.count() > 1:
             # This would mean dak is misconfigured
+            s.close()
             return bottle.HTTPError(503, 'Multiple suites found: configuration error')
         elif q.count() == 1:
             so = q[0]
@@ -81,7 +112,8 @@ def suite(suite=None):
               'architectures': [x.arch_string for x in so.architectures],
               'components': [x.component_name for x in so.components]}
 
+    s.close()
+
     return json.dumps(so)
 
 QueryRegister().register_path('/suite', suite)
-