mbligh | e9cf9d4 | 2007-08-31 08:56:00 +0000 | [diff] [blame^] | 1 | import sqlite, re |
mbligh | d5c33db | 2006-10-08 21:34:16 +0000 | [diff] [blame] | 2 | |
| 3 | class db: |
| 4 | def __init__(self): |
| 5 | self.con = sqlite.connect('tko_db') |
| 6 | self.cur = self.con.cursor() |
| 7 | |
| 8 | |
| 9 | def select(self, cmd): |
mbligh | 056d0d3 | 2006-10-08 22:31:10 +0000 | [diff] [blame] | 10 | print 'select ' + cmd |
mbligh | d5c33db | 2006-10-08 21:34:16 +0000 | [diff] [blame] | 11 | self.cur.execute('select ' + cmd) |
| 12 | return self.cur.fetchall() |
| 13 | |
mbligh | 056d0d3 | 2006-10-08 22:31:10 +0000 | [diff] [blame] | 14 | |
| 15 | def insert_job(self, tag, job): |
mbligh | e9cf9d4 | 2007-08-31 08:56:00 +0000 | [diff] [blame^] | 16 | # is kernel version in tree? |
mbligh | 056d0d3 | 2006-10-08 22:31:10 +0000 | [diff] [blame] | 17 | command = 'insert into jobs ' + \ |
mbligh | e9cf9d4 | 2007-08-31 08:56:00 +0000 | [diff] [blame^] | 18 | '(tag, machine) ' + \ |
| 19 | 'values (%s, %s) ' |
| 20 | print command |
| 21 | values = (tag, 'UNKNOWN') |
mbligh | 056d0d3 | 2006-10-08 22:31:10 +0000 | [diff] [blame] | 22 | self.cur.execute(command, values) |
mbligh | e9cf9d4 | 2007-08-31 08:56:00 +0000 | [diff] [blame^] | 23 | self.con.commit() |
| 24 | # Select it back from the job table and find the uniq key |
| 25 | |
| 26 | |
| 27 | def insert_test(self, job, |
| 28 | def lookup_kernel_version(base, patches): |
| 29 | command = 'select kversion from kversions where base = %s' |
| 30 | |
| 31 | |
| 32 | def insert_kernel_version(base, patches): |
| 33 | base = re.sub(r'\+.*', '', printable) |
| 34 | command = 'select kversion from kversions where printable = %s' |
| 35 | self.cur.execute(command, tag) |
| 36 | results = self.cur.fetchall() |
| 37 | if results: |
| 38 | return results[0] |
| 39 | command = 'insert into kversions (printable, base) ' + \ |
| 40 | 'values (%s, %s)' |
| 41 | self.cur.execute(command, (printable, base)) |
| 42 | self.con.commit() |
mbligh | 056d0d3 | 2006-10-08 22:31:10 +0000 | [diff] [blame] | 43 | |
| 44 | |
| 45 | def find_job(self, tag): |
mbligh | 529f2f3 | 2007-08-30 11:22:50 +0000 | [diff] [blame] | 46 | command = 'select * from jobs where tag = %s' |
mbligh | 056d0d3 | 2006-10-08 22:31:10 +0000 | [diff] [blame] | 47 | self.cur.execute(command, tag) |
| 48 | return self.cur.fetchall() |