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/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)