blob: 2fa5b68aa6e509579d3e7cf6ba755944d2f10f5d [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
14 'FAIL' : '#fff666', # red
15 'ABORT' : '#ff6666', # red
16 'ERROR' : '#ff6666', # red
17 'NOSTATUS' : '#ffffff', # white
18}
19
mbligh9bb92fe2007-09-12 15:54:23 +000020class kernel:
mbligh8e1ab172007-09-13 17:29:56 +000021 @classmethod
22 def select(klass, db, where = {}):
23 fields = ['kernel_idx', 'kernel_hash', 'base', 'printable']
24 kernels = []
25 for row in db.select(','.join(fields), 'kernels', where):
26 kernels.append(klass(db, *row))
27 return kernels
mbligh9bb92fe2007-09-12 15:54:23 +000028
mbligh8e1ab172007-09-13 17:29:56 +000029
30 def __init__(self, db, idx, hash, base, printable):
mbligh9bb92fe2007-09-12 15:54:23 +000031 self.db = db
mbligh8e1ab172007-09-13 17:29:56 +000032 self.idx = idx
mbligh9bb92fe2007-09-12 15:54:23 +000033 self.hash = hash
mbligh8e1ab172007-09-13 17:29:56 +000034 self.base = base
35 self.printable = printable
36 self.patches = [] # THIS SHOULD PULL IN PATCHES!
mbligh9bb92fe2007-09-12 15:54:23 +000037
38
39class test:
mbligh8e1ab172007-09-13 17:29:56 +000040 @classmethod
41 def select(klass, db, where = {}):
42 fields = ['test_idx', 'job_idx', 'test', 'subdir',
43 'kernel_idx', 'status', 'reason', 'machine']
44 tests = []
45 for row in db.select(','.join(fields), 'tests', where):
46 tests.append(klass(db, *row))
47 return tests
48
49
50 def __init__(self, db, test_idx, job_idx, testname, subdir, kernel_idx, status_num, reason, machine):
51 self.idx = test_idx
52 self.job = None
53 # self.job = job.select(db, {'job_idx' : job_idx})
54 # self.machine = self.job.machine
55 self.test = testname
56 self.subdir = subdir
57 self.kernel = None
58 # self.kernel = kernel.select(db, {'kernel_idx' : kernel_idx})
59 self.status_num = status_num
60 self.status_word = db.status_word[status_num]
mbligh9bb92fe2007-09-12 15:54:23 +000061 self.reason = reason
mbligh8e1ab172007-09-13 17:29:56 +000062
63
64
65# class patch:
66# def __init__(self):
67# self.spec = None
68#
69#
70# class iteration:
71# def __init__(self):
72# self.a = None
73#