mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 04:05:32 +00:00
Updated import.py for new db format
This commit is contained in:
parent
6eda5f4a4f
commit
850d4365f6
@ -7,23 +7,44 @@ import re
|
||||
|
||||
from pysqlite2 import dbapi2 as sqlite
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print "Usage: import.py test_name tinderbox_name < data.txt"
|
||||
if len(sys.argv) < 3 or len(sys.argv) > 4:
|
||||
print "Usage: import.py test_name tinderbox_name [replace] < data.txt"
|
||||
sys.exit()
|
||||
|
||||
(testname, tbox) = sys.argv[1:3]
|
||||
replace = false
|
||||
if len(sys.argv) == 4:
|
||||
replace = true
|
||||
|
||||
db = sqlite.connect("db/" + tbox + ".sqlite")
|
||||
DBPATH = "db/data.sqlite"
|
||||
db = sqlite.connect(DBPATH)
|
||||
|
||||
try:
|
||||
db.execute("CREATE TABLE test_results (test_name STRING, test_time INTEGER, test_value FLOAT, test_data BLOB);")
|
||||
db.execute("CREATE TABLE annotations (anno_time INTEGER, anno_string STRING);")
|
||||
db.execute("CREATE INDEX test_name_idx ON test_results(test_name)")
|
||||
db.execute("CREATE INDEX test_time_idx ON test_results(test_time)")
|
||||
db.execute("CREATE INDEX anno_time_idx ON annotations(anno_time)")
|
||||
db.execute("CREATE TABLE dataset_info (id INTEGER PRIMARY KEY AUTOINCREMENT, machine STRING, test STRING, test_type STRING, extra_data STRING);")
|
||||
db.execute("CREATE TABLE datasets (dataset_id INTEGER, time INTEGER, value FLOAT, extra BLOB);")
|
||||
db.execute("CREATE TABLE annotations (dataset_id INTEGER, time INTEGER, value STRING);")
|
||||
db.execute("CREATE INDEX datasets_id_idx ON datasets(dataset_id);")
|
||||
db.execute("CREATE INDEX datasets_time_idx ON datasets(time);")
|
||||
except:
|
||||
pass
|
||||
|
||||
setid = -1
|
||||
while setid == -1:
|
||||
cur = db.cursor()
|
||||
cur.execute("SELECT id FROM dataset_info WHERE machine=? AND test=? AND test_type=? AND extra=?",
|
||||
(tbox, testname, "perf", "branch="+branch))
|
||||
res = cur.fetchall()
|
||||
cur.close()
|
||||
|
||||
if len(res) == 0:
|
||||
db.execute("INSERT INTO dataset_info (machine, test, test_type, extra) VALUES (?,?,?,?)",
|
||||
(tbox, testname, "perf", "branch="+branch))
|
||||
else:
|
||||
setid = res[0]
|
||||
|
||||
if replace:
|
||||
db.execute("DELETE FROM datasets WHERE dataset_id = ?", (setid))
|
||||
|
||||
count = 0
|
||||
line = sys.stdin.readline()
|
||||
while line is not None:
|
||||
@ -40,7 +61,7 @@ while line is not None:
|
||||
|
||||
timeval = time.mktime(map(int, string.split(datestr, ":")) + [0, 0, 0])
|
||||
|
||||
db.execute("INSERT INTO test_results VALUES (?, ?, ?, ?)", (testname, timeval, val, data))
|
||||
db.execute("INSERT INTO datasets (dataset_id,time,value,extra) VALUES (?,?,?,?)", (setid, timeval, val, data))
|
||||
count = count + 1
|
||||
line = sys.stdin.readline()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user