This patch gets rid of the last bits db initialization within db.py.
Everything is now done in create_db.
This fixes a bug I ran into where a script with read-only access to
db.py tried to connect to a new database. Things would remain broken
(returning silly errors) until a script with read-write access ran
(and finished initialization). IMHO, this is a cleaner way to do
things anyway.
From: Jeremy Orlow <jorlow@google.com>
Signed-off-by: Martin J. Bligh <mbligh@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@740 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/db.py b/tko/db.py
index 1bb0afa..ed6350e 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -32,23 +32,12 @@
# if not present, insert statuses
self.status_idx = {}
self.status_word = {}
- for s in ['NOSTATUS', 'ERROR', 'ABORT', 'FAIL', 'WARN', 'GOOD']:
- idx = self.get_status(s)
- if not idx:
- self.insert('status', {'word' : s})
- idx = self.get_status(s)
- self.status_idx[s] = idx
- self.status_word[idx] = s
+ status_rows = self.select('status_idx, word', 'status', None)
+ for s in status_rows:
+ self.status_idx[s[0]] = s[0]
+ self.status_word[s[0]] = s[1]
- def get_status(self, word):
- rows = self.select('status_idx', 'status', {'word' : word})
- if rows:
- return rows[0][0]
- else:
- return None
-
-
def dprint(self, value):
if self.debug:
sys.stderr.write('SQL: ' + str(value) + '\n')