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/client/bin/job.py b/client/bin/job.py
index fd010e0..ea19344 100755
--- a/client/bin/job.py
+++ b/client/bin/job.py
@@ -230,6 +230,12 @@
 			del dargs['tag']
 			if tag:
 				subdir += '.' + tag
+
+		reraise = False
+		if dargs.has_key('reraise'):
+			reraise = dargs['reraise']
+			del dargs['reraise']
+
 		try:
 			try:
 				self.__runtest(url, tag, args, dargs)
@@ -242,7 +248,10 @@
 				self.record('GOOD', subdir, testname, \
 						'completed successfully')
 		except TestError:
-			return 0
+			if reraise:
+				raise
+			else:
+				return 0
 		except:
 			raise
 		else:
diff --git a/tko/create_db b/tko/create_db
index 310a3be..267cff7 100644
--- a/tko/create_db
+++ b/tko/create_db
@@ -69,3 +69,6 @@
 status_idx int(10) unsigned NOT NULL auto_increment PRIMARY KEY ,		-- numerical status
 word VARCHAR(10)			-- status word
 );
+
+INSERT INTO status (word)
+VALUES ('NOSTATUS'), ('ERROR'), ('ABORT'), ('FAIL'), ('WARN'), ('GOOD');
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')
diff --git a/tko/machine_test_attribute_graph.cgi b/tko/machine_test_attribute_graph.cgi
index 8a16a6b..1fec9f2 100755
--- a/tko/machine_test_attribute_graph.cgi
+++ b/tko/machine_test_attribute_graph.cgi
@@ -18,11 +18,24 @@
 def main():
 	form = cgi.FieldStorage()
 	machine_idx = form["machine"].value
-	benchmark = form["benchmark"].value
-	key = form["key"].value
-
 	machine = frontend.machine.select(db, {'machine_idx' : machine_idx})[0]
 
+	benchmark2 = form["benchmark2"].value
+	key2 = form["key2"].value
+	
+	# for kernel in sort_kernels(data.keys()):
+	#	print "%s %s" % (kernel, str(data[kernel]))
+	title = "%s on %s " % (benchmark2, machine.hostname)
+	data2 = {}
+	where = { 'subdir' : benchmark2, 'machine_idx' : machine.idx }
+	for test in frontend.test.select(db, where):
+		iterations = test.iterations()
+		if iterations.has_key(key2):
+			data2[test.kernel().printable] = iterations[key2]
+
+	benchmark = form["benchmark"].value
+	key = form["key"].value
+	
 	data = {}
 	where = { 'subdir' : benchmark, 'machine_idx' : machine.idx }
 	for test in frontend.test.select(db, where):
@@ -30,11 +43,9 @@
 		if iterations.has_key(key):
 			data[test.kernel().printable] = iterations[key]
 
-	# for kernel in sort_kernels(data.keys()):
-	#	print "%s %s" % (kernel, str(data[kernel]))
-	title = "%s on %s" % (benchmark, machine.hostname)
 	graph = plotgraph.gnuplot(title, 'Kernel', key, xsort = sort_kernels)
-	graph.add_dataset('all kernels', data)
+	graph.add_dataset('data',data)
+	graph.add_dataset('data2',data2)
 	graph.plot(cgi_header = True)