blob: 7996093aa1a8434d4ca6198fe46569da23e6c1eb [file] [log] [blame]
mbligh9bb92fe2007-09-12 15:54:23 +00001#!/usr/bin/python
2import os, re, db
3
mbligh8e1ab172007-09-13 17:29:56 +00004# Pulling hierarchy:
5#
6# test pulls in (kernel, job, attributes, iterations)
7# kernel pulls in (patches)
8#
9# Note that job does put pull test - test is the primary object.
mbligh9bb92fe2007-09-12 15:54:23 +000010
mblighd72c9132007-09-13 22:57:06 +000011status_colour = {
12 'GOOD' : '#66ff66', # green
13 'WARN' : '#fffc00', # yellow
mbligh52f97442007-09-14 17:43:28 +000014 'FAIL' : '#ff6666', # red
mblighd72c9132007-09-13 22:57:06 +000015 'ABORT' : '#ff6666', # red
16 'ERROR' : '#ff6666', # red
17 'NOSTATUS' : '#ffffff', # white
mblighbfec5222007-09-14 16:58:57 +000018 '' : '#ffffff', # white
mblighd72c9132007-09-13 22:57:06 +000019}
20
mbligh250300e2007-09-18 00:50:57 +000021html_root = 'http://test.kernel.org/google/'
22
mbligh9bb92fe2007-09-12 15:54:23 +000023class kernel:
mbligh8e1ab172007-09-13 17:29:56 +000024 @classmethod
25 def select(klass, db, where = {}):
26 fields = ['kernel_idx', 'kernel_hash', 'base', 'printable']
27 kernels = []
28 for row in db.select(','.join(fields), 'kernels', where):
29 kernels.append(klass(db, *row))
30 return kernels
mbligh9bb92fe2007-09-12 15:54:23 +000031
mbligh8e1ab172007-09-13 17:29:56 +000032
33 def __init__(self, db, idx, hash, base, printable):
mbligh9bb92fe2007-09-12 15:54:23 +000034 self.db = db
mbligh8e1ab172007-09-13 17:29:56 +000035 self.idx = idx
mbligh9bb92fe2007-09-12 15:54:23 +000036 self.hash = hash
mbligh8e1ab172007-09-13 17:29:56 +000037 self.base = base
38 self.printable = printable
39 self.patches = [] # THIS SHOULD PULL IN PATCHES!
mbligh9bb92fe2007-09-12 15:54:23 +000040
41
42class test:
mbligh8e1ab172007-09-13 17:29:56 +000043 @classmethod
44 def select(klass, db, where = {}):
45 fields = ['test_idx', 'job_idx', 'test', 'subdir',
46 'kernel_idx', 'status', 'reason', 'machine']
47 tests = []
48 for row in db.select(','.join(fields), 'tests', where):
49 tests.append(klass(db, *row))
50 return tests
51
52
53 def __init__(self, db, test_idx, job_idx, testname, subdir, kernel_idx, status_num, reason, machine):
54 self.idx = test_idx
55 self.job = None
mbligh250300e2007-09-18 00:50:57 +000056 self.job = job(db, job_idx)
mbligh8e1ab172007-09-13 17:29:56 +000057 # self.machine = self.job.machine
58 self.test = testname
59 self.subdir = subdir
60 self.kernel = None
61 # self.kernel = kernel.select(db, {'kernel_idx' : kernel_idx})
62 self.status_num = status_num
63 self.status_word = db.status_word[status_num]
mbligh9bb92fe2007-09-12 15:54:23 +000064 self.reason = reason
mbligh250300e2007-09-18 00:50:57 +000065 self.url = html_root + self.job.tag + '/' + self.subdir
mbligh8e1ab172007-09-13 17:29:56 +000066
mbligh250300e2007-09-18 00:50:57 +000067
68class job:
69 def __init__(self, db, job_idx):
70 where = {'job_idx' : job_idx}
71 rows = db.select('tag, machine', 'jobs', where)
72 if not rows:
73 return None
74 (self.tag, self.machine) = rows[0]
75
mbligh8e1ab172007-09-13 17:29:56 +000076
77# class patch:
78# def __init__(self):
79# self.spec = None
80#
81#
82# class iteration:
83# def __init__(self):
84# self.a = None
85#