#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright © 2015 Holger Levsen
# based on ~jenkins.d.n:~mattia/status.sh by Mattia Rizzolo
# Licensed under GPL-2
#
# Depends: python3
#
from reproducible_common import *
from reproducible_html_indexes import build_leading_text_section
def generate_schedule(arch):
""" the schedule pages are very different than others index pages """
log.info('Building the schedule index page for ' + arch + '...')
title = 'Packages currently scheduled on ' + arch + ' 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 = "" AND s.architecture="{arch}" ORDER BY sch.date_scheduled'
text = Template('$tot packages are currently scheduled for testing on $arch:')
html = ''
rows = query_db(query.format(arch=arch))
html += build_leading_text_section({'text': text}, rows, defaultsuite, arch)
html += generate_live_status_table(arch)
html += '\n' + tab
html += '# | scheduled at | suite | '
html += 'architecture | source package |
\n'
for row in rows:
# 0: date_scheduled, 1: suite, 2: arch, 3: pkg name
pkg = row[3]
html += tab + ' | ' + row[0] + ' | '
html += '' + row[1] + ' | ' + row[2] + ' | '
html += link_package(pkg, row[1], row[2], bugs)
html += ' |
\n'
html += '
\n'
destfile = BASE + '/index_' + arch + '_scheduled.html'
desturl = REPRODUCIBLE_URL + '/index_' + arch + '_scheduled.html'
write_html_page(title=title, body=html, destfile=destfile)
log.info("Page generated at " + desturl)
def generate_live_status_table(arch):
query = 'SELECT s.id, s.name, s.version, s.suite, s.architecture, ' + \
'p.scheduler, p.date_scheduled, p.date_build_started, ' + \
'r.status, r.version, r.build_duration, p.builder, p.notify ' + \
'FROM sources AS s JOIN schedule AS p ON p.package_id=s.id LEFT JOIN results AS r ON s.id=r.package_id ' + \
'WHERE (p.date_build_started != "" OR p.notify != "") AND s.architecture="{arch}" ' + \
'ORDER BY p.date_build_started DESC'
html = ''
rows = query_db(query.format(arch=arch))
html += '\n' + tab
html += '# | src pkg id | name | version | '
html += 'suite | arch | scheduled by | '
html += 'scheduled on | build started | status | '
html += 'version building | previous build duration | builder job | notify | '
html += '
\n'
for row in rows:
pkg = row[1]
arch = row[4]
suite = row[3]
html += tab + ' | ' + str(row[0]) + ' | '
html += ''
html += link_package(pkg, suite, arch)
html += ' | ' + str(row[2]) + ' | ' + str(row[3]) + ' | '
html += '' + str(row[4]) + ' | ' + str(row[5]) + ' | ' + str(row[6]) + ' | '
html += '' + str(row[7]) + ' | ' + str(row[8]) + ' | ' + str(row[9]) + ' | '
html += '' + str(row[10]) + ' | ' + str(row[11]) + ' | ' + str(row[12]) + ' | '
html += '
\n'
html += '
\n'
return html
if __name__ == '__main__':
for arch in ARCHS:
generate_schedule(arch)