1""" Archive related queries 

2 

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 

8import bottle 

9import json 

10 

11from daklib.dbconn import DBConn, Archive 

12from dakweb.webregister import QueryRegister 

13 

14 

15@bottle.route('/archives') 

16def archives() -> str: 

17 """ 

18 Give information about all known archives (sets of suites) 

19 

20 :return: list of dictionaries 

21 """ 

22 

23 s = DBConn().session() 

24 q = s.query(Archive) 

25 q = q.order_by(Archive.archive_name) 

26 ret = [] 

27 for a in q: 

28 ret.append({'name': a.archive_name, 

29 'suites': [x.suite_name for x in a.suites]}) 

30 

31 s.close() 

32 

33 bottle.response.content_type = 'application/json; charset=UTF-8' 

34 return json.dumps(ret) 

35 

36 

37QueryRegister().register_path('/archives', archives)