archive.py 874 B

1234567891011121314151617181920212223242526272829303132333435363738
  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() -> str:
  12. """
  13. Give information about all known archives (sets of suites)
  14. :return: list of dictionaries
  15. """
  16. s = DBConn().session()
  17. q = s.query(Archive)
  18. q = q.order_by(Archive.archive_name)
  19. ret = []
  20. for a in q:
  21. ret.append({'name': a.archive_name,
  22. 'suites': [x.suite_name for x in a.suites]})
  23. s.close()
  24. bottle.response.content_type = 'application/json; charset=UTF-8'
  25. return json.dumps(ret)
  26. QueryRegister().register_path('/archives', archives)