summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_json.py
blob: 7080b9ea172897dcbc6736173b9143c1c4f41507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright © 2015 Mattia Rizzolo <mattia@mapreri.org>
# Licensed under GPL-2+
#
# Depends: python3
#
# Build the reproducible.json file, to provide a nice datasource

from reproducible_common import *

import json

result = sorted(query_db('SELECT name, version, status FROM source_packages' +
                         ' WHERE status != ""'))
count = int(query_db('SELECT COUNT(name) FROM source_packages ' +
                           'WHERE status != ""')[0][0])

log.info('processing ' + str(count) + ' package to create .json output')

all_pkgs = []
keys = ['package', 'version', 'status']
for row in result:
    pkg = dict(zip(keys, row))
    pkg['suite'] = 'sid'
    all_pkgs.append(pkg)

with open(REPRODUCIBLE_JSON, 'w') as fd:
    json.dump(all_pkgs, fd, indent=4, sort_keys=True)

log.info(REPRODUCIBLE_URL + '/reproducible.json has been updated.')