[Qa-jenkins-scm] [jenkins.debian.net] 01/05: 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

Holger Levsen holger at moszumanska.debian.org
Thu Apr 16 14:45:23 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 2875d50816ae4b5c71619dd0bb5dafa69f854de6
Author: Mattia Rizzolo <mattia at mapreri.org>
Date:   Sun Apr 12 22:06:33 2015 +0200

    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_common.sh       |  2 +-
 bin/reproducible_html_indexes.py | 65 +++++++++++++++++++++-------------------
 bin/reproducible_scheduler.py    |  6 ++--
 3 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/bin/reproducible_common.sh b/bin/reproducible_common.sh
index b65fba7..949fbfd 100755
--- a/bin/reproducible_common.sh
+++ b/bin/reproducible_common.sh
@@ -99,7 +99,7 @@ schedule_packages() {
 	cat $TMPFILE | sqlite3 -init $INIT ${PACKAGES_DB}
 	rm $TMPFILE
 	cd /srv/jenkins/bin
-	python3 -c "from reproducible_html_indexes import build_page; build_page('scheduled')"
+	python3 -c "from reproducible_html_indexes import generate_schedule; generate_schedule()"
 }
 
 check_candidates() {
diff --git a/bin/reproducible_html_indexes.py b/bin/reproducible_html_indexes.py
index 5a35c40..5604639 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 += '<p><table class="scheduled">\n' + tab + '<tr><th>#</th><th>scheduled at</th><th>suite</th><th>architecture</th><th>source package</th></tr>\n'
-    else:
-        html += '<p>\n' + tab + '<code>\n'
+    html += '<p>\n' + tab + '<code>\n'
     for row in rows:
-        if page == 'scheduled':
-            pkg = row[3]
-            url = RB_PKG_URI + '/' + row[1] + '/' + row[2] + '/' + pkg + '.html'
-            html += tab + '<tr><td> </td><td>' + row[0] + '</td><td>' + row[1] + '</td><td>' + row[2] + '</td><td><code>'
-        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 += '</code></td></tr>'
         html += '\n'
-    if page == 'scheduled':
-        html += '</table></p>\n'
     else:
         html += tab + '</code>\n'
         html += '</p>'
@@ -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 += '<p><table class="scheduled">\n' + tab
+    html += '<tr><th>#</th><th>scheduled at</th><th>suite</th>'
+    html += '<th>architecture</th><th>source package</th></tr>\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 + '<tr><td> </td><td>' + row[0] + '</td>'
+        html += '<td>' + row[1] + '</td><td>' + row[2] + '</td><td><code>'
+        html += link_package(pkg, defaultsuite, defaultarch, bugs)
+        html += '</code></td></tr>\n'
+    html += '</table></p>\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():
diff --git a/bin/reproducible_scheduler.py b/bin/reproducible_scheduler.py
index 5d3fccc..bb465ea 100755
--- a/bin/reproducible_scheduler.py
+++ b/bin/reproducible_scheduler.py
@@ -22,7 +22,7 @@ from apt_pkg import version_compare
 from urllib.request import urlopen
 
 from reproducible_common import *
-from reproducible_html_indexes import build_page
+from reproducible_html_indexes import generate_schedule
 from reproducible_html_packages import gen_packages_html
 from reproducible_html_packages import purge_old_pages
 
@@ -215,7 +215,7 @@ def scheduler():
     total = int(query_db(query)[0][0])
     log.info('Currently scheduled packages in all suites: ' + str(total))
     if total > 250:
-        build_page('scheduled')  # from reproducible_html_indexes
+        generate_schedule()  # from reproducible_html_indexes
         log.info(str(total) + ' packages already scheduled' +
                  ', nothing to do here.')
         return
@@ -281,7 +281,7 @@ def scheduler():
         log.info('### Suite ' + suite + ' done ###')
         log.info('==============================================================')
     # update the scheduled page
-    build_page('scheduled')  # from reproducible_html_indexes, build global page
+    generate_schedule()  # from reproducible_html_indexes
     # build the kgb message text
     message = 'Scheduled in ' + '+'.join(SUITES) + ': ' + \
               '+'.join([str(len(untested[x])) for x in SUITES]) + ' new and untested packages, ' + \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list