archive.py 832 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/python
  2. """ Archive 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
  6. """
  7. import bottle
  8. import json
  9. from daklib.dbconn import DBConn, Archive
  10. from dakweb.webregister import QueryRegister
  11. @bottle.route('/archives')
  12. def archives():
  13. """
  14. Give information about all known archives (sets of suites)
  15. @rtype: dict
  16. return: list of dictionaries
  17. """
  18. s = DBConn().session()
  19. q = s.query(Archive)
  20. q = q.order_by(Archive.archive_name)
  21. ret = []
  22. for a in q:
  23. ret.append({'name': a.archive_name,
  24. 'suites': [x.suite_name for x in a.suites]})
  25. s.close()
  26. return json.dumps(ret)
  27. QueryRegister().register_path('/archives', archives)