From 2875d50816ae4b5c71619dd0bb5dafa69f854de6 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Sun, 12 Apr 2015 22:06:33 +0200 Subject: reproducible: _html_indexes: move the code generating the schedule page to its own function. it does not make sense to bloat the generic code by special casing it --- bin/reproducible_html_indexes.py | 65 +++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 30 deletions(-) (limited to 'bin/reproducible_html_indexes.py') diff --git a/bin/reproducible_html_indexes.py b/bin/reproducible_html_indexes.py index 5a35c402..56046398 100755 --- a/bin/reproducible_html_indexes.py +++ b/bin/reproducible_html_indexes.py @@ -55,7 +55,6 @@ for issue in filtered_issues: queries = { 'count_total': 'SELECT COUNT(*) FROM results AS r JOIN sources AS s ON r.package_id=s.id WHERE s.suite="{suite}" AND s.architecture="{arch}"', - 'scheduled': 'SELECT sch.date_scheduled, s.suite, s.architecture, s.name FROM schedule AS sch JOIN sources AS s ON sch.package_id=s.id WHERE sch.date_build_started = "" ORDER BY sch.date_scheduled', 'reproducible_all': 'SELECT s.name FROM results AS r JOIN sources AS s ON r.package_id=s.id WHERE s.suite="{suite}" AND s.architecture="{arch}" AND r.status="reproducible" ORDER BY r.build_date DESC', 'reproducible_last24h': 'SELECT s.name FROM results AS r JOIN sources AS s ON r.package_id=s.id WHERE s.suite="{suite}" AND s.architecture="{arch}" AND r.status="reproducible" AND r.build_date > datetime("now", "-24 hours") ORDER BY r.build_date DESC', 'reproducible_last48h': 'SELECT s.name FROM results AS r JOIN sources AS s ON r.package_id=s.id WHERE s.suite="{suite}" AND s.architecture="{arch}" AND r.status="reproducible" AND r.build_date > datetime("now", "-48 hours") ORDER BY r.build_date DESC', @@ -252,15 +251,6 @@ pages = { } global_pages = { - 'scheduled': { - 'title': 'Packages currently scheduled for testing for build reproducibility', - 'body': [ - { - 'query': 'scheduled', - 'text': Template('$tot packages are currently scheduled for testing:') - } - ] - } } @@ -309,28 +299,16 @@ def build_page_section(page, section, suite, arch): raise html = '' footnote = True if rows else False - if not rows and page != 'scheduled': # there are no package in this set + if not rows: # there are no package in this set return (html, footnote) # do not output anything on the page. html += build_leading_text_section(section, rows, suite, arch) - if page == 'scheduled': - html += '

\n' + tab + '\n' - else: - html += '

\n' + tab + '\n' + html += '

\n' + tab + '\n' for row in rows: - if page == 'scheduled': - pkg = row[3] - url = RB_PKG_URI + '/' + row[1] + '/' + row[2] + '/' + pkg + '.html' - html += tab + '

' html += '\n' - if page == 'scheduled': - html += '
#scheduled atsuitearchitecturesource package
 ' + row[0] + '' + row[1] + '' + row[2] + '' - else: - pkg = row[0] - url = RB_PKG_URI + '/' + suite + '/' + arch + '/' + pkg + '.html' - html += tab*2 + pkg = row[0] + url = RB_PKG_URI + '/' + suite + '/' + arch + '/' + pkg + '.html' + html += tab*2 html += link_package(pkg, suite, arch, bugs) - if page == 'scheduled': - html += '

\n' else: html += tab + '\n' html += '

' @@ -361,8 +339,6 @@ def build_page(page, suite=None, arch=None): for lsuite in SUITES: for larch in ARCHES: html += build_page_section(page, section, lsuite, larch)[0] - if page == 'scheduled': - break footnote = True else: html1, footnote1 = build_page_section(page, section, suite, arch) @@ -371,7 +347,7 @@ def build_page(page, suite=None, arch=None): if not suite: # global page destfile = BASE + '/index_' + page + '.html' desturl = REPRODUCIBLE_URL + '/index_' + page + '.html' - suite = defaultsuite # used for the links generated by write_html_page + suite = defaultsuite # used for the links generated by write_html_page else: destfile = BASE + '/' + suite + '/' + arch + '/index_' + page + '.html' desturl = REPRODUCIBLE_URL + '/' + suite + '/' + arch + '/index_' + \ @@ -380,9 +356,38 @@ def build_page(page, suite=None, arch=None): log.info('"' + title + '" now available at ' + desturl) +def generate_schedule(): + """ the schedule is very different than others index pages """ + log.info('Building the schedule index page...') + title = 'Packages currently scheduled for testing for build reproducibility' + query = 'SELECT sch.date_scheduled, s.suite, s.architecture, s.name ' + \ + 'FROM schedule AS sch JOIN sources AS s ON sch.package_id=s.id ' + \ + 'WHERE sch.date_build_started = "" ORDER BY sch.date_scheduled' + text = Template('$tot packages are currently scheduled for testing:') + html = '' + rows = query_db(query) + html += build_leading_text_section({'text': text}, rows, defaultsuite, defaultarch) + html += '

\n' + tab + html += '' + html += '\n' + for row in rows: + # 0: date_scheduled, 1: suite, 2: arch, 3: pkg name + pkg = row[3] + url = RB_PKG_URI + '/' + row[1] + '/' + row[2] + '/' + pkg + '.html' + html += tab + '' + html += '\n' + html += '
#scheduled atsuitearchitecturesource package
 ' + row[0] + '' + row[1] + '' + row[2] + '' + html += link_package(pkg, defaultsuite, defaultarch, bugs) + html += '

\n' + destfile = BASE + '/index_scheduled.html' + desturl = REPRODUCIBLE_URL + '/index_scheduled.html' + write_html_page(title=title, body=html, destfile=destfile, style_note=True) + + bugs = get_bugs() if __name__ == '__main__': + generate_schedule() for suite in SUITES: for arch in ARCHES: for page in pages.keys(): -- cgit v1.2.3-70-g09d2