summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattia Rizzolo <mattia@mapreri.org>2015-04-12 20:35:20 +0200
committerHolger Levsen <holger@layer-acht.org>2015-04-13 01:08:14 +0200
commitfa32d9912c0e378a83d4a17befe2ecb0863e6713 (patch)
tree21f93f9c4ffac8f002984ba526ecce29d829dffc
parent5bcc76c1b809c783dd600cf6213bae2bbaeab970 (diff)
downloadjenkins.debian.net-fa32d9912c0e378a83d4a17befe2ecb0863e6713.tar.xz
reproducible: common: add link_package() which given a package name/suite/arch returns html
-rwxr-xr-xbin/reproducible_common.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index 8d3e5a62..fcd554f7 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -12,14 +12,16 @@
import os
import re
import sys
+import json
import errno
import sqlite3
import logging
import argparse
import datetime
import psycopg2
-from traceback import print_exception
+import html as HTML
from string import Template
+from traceback import print_exception
DEBUG = False
QUIET = False
@@ -327,6 +329,32 @@ def package_has_notes(package):
return False
+def link_package(package, suite, arch, bugs={}):
+ url = RB_PKG_URI + '/' + suite + '/' + arch + '/' + package + '.html'
+ query = 'SELECT n.issues, n.bugs, n.comments ' + \
+ 'FROM notes AS n JOIN sources AS s ON s.id=n.package_id ' + \
+ 'WHERE s.name="{pkg}" AND s.suite="{suite}" ' + \
+ 'AND s.architecture="{arch}"'
+ try:
+ notes = query_db(query.format(pkg=package, suite=suite, arch=arch))[0]
+ except IndexError: # no notes for this package
+ html = '<a href="' + url + '" class="package">' + package + '</a>'
+ else:
+ title = ''
+ for issue in json.loads(notes[0]):
+ title += issue + '\n'
+ for bug in json.loads(notes[1]):
+ title += '#' + str(bug) + '\n'
+ if notes[2]:
+ title += notes[2]
+ title = HTML.escape(title.strip())
+ html = '<a href="' + url + '" class="noted" title="' + title + \
+ '">' + package + '</a>'
+ finally:
+ html += get_trailing_icon(package, bugs)
+ return html
+
+
def join_status_icon(status, package=None, version=None):
table = {'reproducible' : 'weather-clear.png',
'FTBFS': 'weather-storm.png',