From 4d3f591f10c9227279bf46f03819f983fed0f410 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Fri, 27 Feb 2015 02:56:30 +0100 Subject: reproducible: notes: check wheter the package has been tested before rebuilding the page in purge_old_notes(). This fix a issue with packages removed from the archive --- bin/reproducible_html_notes.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/reproducible_html_notes.py b/bin/reproducible_html_notes.py index 1f047130..56acd3ff 100755 --- a/bin/reproducible_html_notes.py +++ b/bin/reproducible_html_notes.py @@ -260,6 +260,7 @@ def gen_html_issue(issue): def purge_old_notes(notes): removed_pages = [] + to_rebuild = [] presents = sorted(os.listdir(NOTES_PATH)) for page in presents: pkg = page.rsplit('_', 1)[0] @@ -268,8 +269,18 @@ def purge_old_notes(notes): log.info('There are no notes for ' + pkg + '. Removing old page.') os.remove(NOTES_PATH + '/' + page) removed_pages.append(pkg) - if removed_pages: - gen_packages_html(removed_pages) + for pkg in removed_pages: + try: + query = 'SELECT s.name ' + \ + 'FROM results AS r JOIN sources AS s ON r.package_id=s.id ' + \ + 'WHERE s.name="{pkg}" AND r.status != "" AND s.suite="sid"' + query = query.format(pkg=pkg) + to_rebuild.append(query_db(query)[0][0]) + except IndexError: # the package is not tested. this can happen if + pass # a package got removed from the archive + if to_rebuild: + gen_packages_html(to_rebuild) + def iterate_over_notes(notes): num_notes = str(len(notes)) -- cgit v1.2.3-54-g00ecf