summaryrefslogtreecommitdiffstats
path: root/scripts/html-report
diff options
context:
space:
mode:
authordann frazier <dannf@debian.org>2006-08-17 00:30:54 +0000
committerdann frazier <dannf@debian.org>2006-08-17 00:30:54 +0000
commit83af1b5d5c8f7e018a003469f86f711158deb252 (patch)
tree1f0a82c943f1f2d1b8ac70f1c56631591208ac23 /scripts/html-report
parent8a0c0175a017301b997cfa0a8fc67b2f0888cf4c (diff)
while i'm reorganizing, might as well move the scripts & dsa-texts
out of the active issues directory ok - should be done for now - let me know if you'd prefer a different organization git-svn-id: svn+ssh://svn.debian.org/svn/kernel-sec@551 e094ebfe-e918-0410-adfb-c712417f3574
Diffstat (limited to 'scripts/html-report')
-rwxr-xr-xscripts/html-report160
1 files changed, 160 insertions, 0 deletions
diff --git a/scripts/html-report b/scripts/html-report
new file mode 100755
index 00000000..38ca25e5
--- /dev/null
+++ b/scripts/html-report
@@ -0,0 +1,160 @@
+#!/usr/bin/python2.4
+
+import os, os.path, sys
+import deb822, re
+
+TrackerDir = ".."
+
+## get an unsorted list of tracked issues
+def trackedIssues(dir):
+ ignores = [ re.compile('~$'),
+ re.compile('^#.*#$'),
+ re.compile('^00'),
+ re.compile('\.patch$')]
+
+ validpaths = []
+ for f in os.listdir(dir):
+ nogood = False
+ for i in ignores:
+ if i.search(f):
+ nogood = True
+ break
+ if nogood:
+ continue
+ else:
+ validpaths.append(f)
+
+ issues = []
+ for f in validpaths:
+ path = os.path.join(dir, f)
+ if os.path.isfile(path):
+ issues.append(f)
+ return issues
+
+def trackedVersions(dir):
+ pkglist = os.path.join(dir, '00pkglist')
+ f = open(pkglist, 'r')
+ return f.read().split('\n')[:-1]
+
+def issueStatus(issue, version):
+ path = os.path.join(TrackerDir, issue)
+ i = deb822.deb822(open(path, 'r'))
+ if i.hasField(version):
+ return i.map[version]
+ else:
+ return None
+
+def statusMatrix(issues, versions):
+ Di = {}
+ for i in issues:
+ Dv = {}
+ for v in versions:
+ Dv[v] = issueStatus(i, v)
+ Di[i] = Dv
+ return Di
+
+## remaining functions create the HTML
+def htmlHeader():
+ sys.stdout.write('<html>\n')
+ sys.stdout.write('<head>\n')
+ sys.stdout.write(' <title>Debian Kernel Patch Tracker Status</title>\n')
+ sys.stdout.write('</head>\n')
+ sys.stdout.write('<body>\n')
+ sys.stdout.write('<h1><center>Debian Kernel Patch Tracker Status</center></h1>')
+ key = '''
+ <table border=1>
+ <tr>
+ <td>Key</td>
+ </tr>
+ <tr>
+ <td bgcolor="green">Fixed or N/A - version is listed if specified</td>
+ </tr>
+ <tr>
+ <td bgcolor="lightgreen">Pending - version is listed if specified</td>
+ </tr>
+ <tr>
+ <td bgcolor="yellow">Needed</td>
+ </tr>
+ <tr>
+ <td bgcolor="orange">Ignored for a reason</td>
+ </tr>
+ </table>'''
+ sys.stdout.write(key)
+ sys.stdout.write('<BR>\n')
+
+
+def htmlFooter():
+ sys.stdout.write(' </body>\n')
+ sys.stdout.write('</html>\n')
+
+def tableHeader(columns):
+ ## populateTable() will assume columns should be filled out
+ ## in sort() order, so make sure our column names match
+ columns.sort()
+ sys.stdout.write("<table border=1>\n")
+ sys.stdout.write(" <tr>\n")
+ sys.stdout.write(" <td> </td>\n")
+ for c in columns:
+ sys.stdout.write(" <td>"+c+"</td>\n")
+ sys.stdout.write(" </tr>\n")
+
+def tableFooter():
+ sys.stdout.write("</table>\n")
+
+## Parse a status string, and return an html table entry
+def statusCell(status):
+ if not status:
+ return '<td color="grey">Unknown</td>'
+
+ statusRe = re.compile("(?P<status>\S+)(\s*\((?P<ver>.*)\))?(\s*\[(?P<name>.*)\])?$")
+
+ m = statusRe.match(status)
+ if m:
+ d = m.groupdict()
+ ver = name = ""
+ if d.has_key('ver') and d['ver']:
+ ver = d['ver']
+ if d.has_key('name') and d['name']:
+ name = d['name']
+
+ if d['status'] == 'N/A':
+ return '<td bgcolor="green">N/A</td>'
+ elif d['status'] == "released":
+ return '<td bgcolor="green">' + ver + '</td>'
+ elif d['status'] == "pending":
+ return '<td bgcolor="lightgreen">' + ver + '</td>'
+ elif d['status'] == "needed":
+ return '<td bgcolor="yellow">' + ver + '</td>'
+ elif d['status'] == "ignored":
+ return '<td bgcolor="orange">' + ver + '</td>'
+ else:
+ return '<td bgcolor="grey">Unknown</td>'
+
+def populateTable(matrix):
+ issues = matrix.keys()
+ issues.sort()
+
+ for i in issues:
+ versions = matrix[i].keys()
+ versions.sort()
+ sys.stdout.write(' <tr>\n')
+ sys.stdout.write(' <td>' + i + '</td>\n')
+ for v in versions:
+ cell = statusCell(matrix[i][v].strip())
+ if cell:
+ sys.stdout.write(cell)
+ else:
+ sys.stderr.write("Error in field: " + i + ", " + v + "\n")
+ sys.stdout.write(' </tr>\n')
+
+if __name__ == '__main__':
+ ## Doing this in a separate stage means some unnecessary duplicate
+ ## opens & closes... but oh well - our data set isn't very large
+ issues = trackedIssues(TrackerDir)
+ versions = trackedVersions(TrackerDir)
+
+ htmlHeader()
+ tableHeader(versions)
+ populateTable(statusMatrix(issues, versions))
+ tableFooter()
+ htmlFooter()

© 2014-2024 Faster IT GmbH | imprint | privacy policy