summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_json.py
diff options
context:
space:
mode:
authorMattia Rizzolo <mattia@mapreri.org>2015-01-30 12:50:43 +0100
committerHolger Levsen <holger@layer-acht.org>2015-01-30 12:52:36 +0100
commit4282dfda3f8c9110bd9af567daddec8deb40a1c8 (patch)
tree1806e8686ca49778dff38379f32f8f43b591cdbf /bin/reproducible_json.py
parent8fc0af71ad23d3b1e1b0a44f97a21b3a69f1f024 (diff)
downloadjenkins.debian.net-4282dfda3f8c9110bd9af567daddec8deb40a1c8.tar.xz
reproducible: rewrite the reproducible_json.sh in python, and replace it
Diffstat (limited to 'bin/reproducible_json.py')
-rwxr-xr-xbin/reproducible_json.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/reproducible_json.py b/bin/reproducible_json.py
new file mode 100755
index 00000000..7080b9ea
--- /dev/null
+++ b/bin/reproducible_json.py
@@ -0,0 +1,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.')
+