From fa32d9912c0e378a83d4a17befe2ecb0863e6713 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Sun, 12 Apr 2015 20:35:20 +0200 Subject: reproducible: common: add link_package() which given a package name/suite/arch returns html --- bin/reproducible_common.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'bin') 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 = '' + package + '' + 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 = '' + package + '' + 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', -- cgit v1.2.3-70-g09d2