archive.py 883 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. """ Archive related queries
  2. @contact: Debian FTPMaster <ftpmaster@debian.org>
  3. @copyright: 2014 Mark Hymers <mhy@debian.org>
  4. @license: GNU General Public License version 2 or later
  5. """
  6. import bottle
  7. import json
  8. from daklib.dbconn import DBConn, Archive
  9. from dakweb.webregister import QueryRegister
  10. @bottle.route('/archives')
  11. def archives():
  12. """
  13. Give information about all known archives (sets of suites)
  14. @rtype: dict
  15. return: list of dictionaries
  16. """
  17. s = DBConn().session()
  18. q = s.query(Archive)
  19. q = q.order_by(Archive.archive_name)
  20. ret = []
  21. for a in q:
  22. ret.append({'name': a.archive_name,
  23. 'suites': [x.suite_name for x in a.suites]})
  24. s.close()
  25. bottle.response.content_type = 'application/json; charset=UTF-8'
  26. return json.dumps(ret)
  27. QueryRegister().register_path('/archives', archives)