blob: 613022474be9e24e78a0812283fc11c858868ae6 [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
mbligh9bb92fe2007-09-12 15:54:23 +000021class kernel:
mbligh8e1ab172007-09-13 17:29:56 +000022 @classmethod
23 def select(klass, db, where = {}):
24 fields = ['kernel_idx', 'kernel_hash', 'base', 'printable']
25 kernels = []
26 for row in db.select(','.join(fields), 'kernels', where):
27 kernels.append(klass(db, *row))
28 return kernels
mbligh9bb92fe2007-09-12 15:54:23 +000029
mbligh8e1ab172007-09-13 17:29:56 +000030
31 def __init__(self, db, idx, hash, base, printable):
mbligh9bb92fe2007-09-12 15:54:23 +000032 self.db = db
mbligh8e1ab172007-09-13 17:29:56 +000033 self.idx = idx
mbligh9bb92fe2007-09-12 15:54:23 +000034 self.hash = hash
mbligh8e1ab172007-09-13 17:29:56 +000035 self.base = base
36 self.printable = printable
37 self.patches = [] # THIS SHOULD PULL IN PATCHES!
mbligh9bb92fe2007-09-12 15:54:23 +000038
39
40class test:
mbligh8e1ab172007-09-13 17:29:56 +000041 @classmethod
42 def select(klass, db, where = {}):
43 fields = ['test_idx', 'job_idx', 'test', 'subdir',
44 'kernel_idx', 'status', 'reason', 'machine']
45 tests = []
46 for row in db.select(','.join(fields), 'tests', where):
47 tests.append(klass(db, *row))
48 return tests
49
50
51 def __init__(self, db, test_idx, job_idx, testname, subdir, kernel_idx, status_num, reason, machine):
52 self.idx = test_idx
53 self.job = None
54 # self.job = job.select(db, {'job_idx' : job_idx})
55 # self.machine = self.job.machine
56 self.test = testname
57 self.subdir = subdir
58 self.kernel = None
59 # self.kernel = kernel.select(db, {'kernel_idx' : kernel_idx})
60 self.status_num = status_num
61 self.status_word = db.status_word[status_num]
mbligh9bb92fe2007-09-12 15:54:23 +000062 self.reason = reason
mbligh8e1ab172007-09-13 17:29:56 +000063
64
65
66# class patch:
67# def __init__(self):
68# self.spec = None
69#
70#
71# class iteration:
72# def __init__(self):
73# self.a = None
74#