mbligh | 9bb92fe | 2007-09-12 15:54:23 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | import os, re, db |
| 3 | |
mbligh | 8e1ab17 | 2007-09-13 17:29:56 +0000 | [diff] [blame] | 4 | # 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. |
mbligh | 9bb92fe | 2007-09-12 15:54:23 +0000 | [diff] [blame] | 10 | |
mbligh | d72c913 | 2007-09-13 22:57:06 +0000 | [diff] [blame] | 11 | status_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 |
mbligh | bfec522 | 2007-09-14 16:58:57 +0000 | [diff] [blame^] | 18 | '' : '#ffffff', # white |
mbligh | d72c913 | 2007-09-13 22:57:06 +0000 | [diff] [blame] | 19 | } |
| 20 | |
mbligh | 9bb92fe | 2007-09-12 15:54:23 +0000 | [diff] [blame] | 21 | class kernel: |
mbligh | 8e1ab17 | 2007-09-13 17:29:56 +0000 | [diff] [blame] | 22 | @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 |
mbligh | 9bb92fe | 2007-09-12 15:54:23 +0000 | [diff] [blame] | 29 | |
mbligh | 8e1ab17 | 2007-09-13 17:29:56 +0000 | [diff] [blame] | 30 | |
| 31 | def __init__(self, db, idx, hash, base, printable): |
mbligh | 9bb92fe | 2007-09-12 15:54:23 +0000 | [diff] [blame] | 32 | self.db = db |
mbligh | 8e1ab17 | 2007-09-13 17:29:56 +0000 | [diff] [blame] | 33 | self.idx = idx |
mbligh | 9bb92fe | 2007-09-12 15:54:23 +0000 | [diff] [blame] | 34 | self.hash = hash |
mbligh | 8e1ab17 | 2007-09-13 17:29:56 +0000 | [diff] [blame] | 35 | self.base = base |
| 36 | self.printable = printable |
| 37 | self.patches = [] # THIS SHOULD PULL IN PATCHES! |
mbligh | 9bb92fe | 2007-09-12 15:54:23 +0000 | [diff] [blame] | 38 | |
| 39 | |
| 40 | class test: |
mbligh | 8e1ab17 | 2007-09-13 17:29:56 +0000 | [diff] [blame] | 41 | @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] |
mbligh | 9bb92fe | 2007-09-12 15:54:23 +0000 | [diff] [blame] | 62 | self.reason = reason |
mbligh | 8e1ab17 | 2007-09-13 17:29:56 +0000 | [diff] [blame] | 63 | |
| 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 | # |