-
Notifications
You must be signed in to change notification settings - Fork 14
/
single-model.py
executable file
·52 lines (42 loc) · 2.02 KB
/
single-model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys, argparse
import simplejson as json
import shared
parser = argparse.ArgumentParser(description='OpenModelica model testing report generation tool')
parser.add_argument('models', nargs='*')
parser.add_argument('--branch', default='')
args = parser.parse_args()
branch = args.branch.split("/")[-1]
models = args.models
dates = {}
dates_str = {}
fields = ["exectime", "frontend", "backend", "simcode", "templates", "compile", "simulate", "verify"]
entryhead = "<tr><th>Branch</th><th>Total</th><th>Frontend</th><th>Backend</th><th>SimCode</th><th>Templates</th><th>Compilation</th><th>Simulation</th><th>Verification</th>\n"
libs = {}
import cgi, sqlite3, time, datetime
from omcommon import friendlyStr, multiple_replace
conn = sqlite3.connect('sqlite3.db')
cursor = conn.cursor()
try:
cursor.execute("SELECT name FROM [sqlite_master] WHERE type='table' AND name=?", (branch,))
v = cursor.fetchone()[0]
except:
raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)
for model in models:
lines=[]
c=0
libnames = [libname for (libname,) in cursor.execute("SELECT DISTINCT libname FROM [%s] WHERE model=? ORDER BY libname ASC" % (branch), (model,))]
for libname in libnames:
for (finalphase,dint,libversion) in cursor.execute("SELECT finalphase,date,libversion FROM [%s] NATURAL JOIN [libversion] WHERE model=? AND libname=? ORDER BY date ASC" % (branch), (model,libname)):
c+=1
dstr = str(datetime.datetime.fromtimestamp(dint).strftime('%Y-%m-%d %H:%M:%S'))
cursor2 = conn.cursor()
omcversion = cursor2.execute("SELECT omcversion FROM [omcversion] WHERE date=? AND branch=?", (dint,branch)).fetchone()[0]
omcversion = omcversion.replace("OpenModelica ","").replace("OMCompiler ","")
lines.insert(0, "%s %s %s %s" % (dstr,shared.finalphaseName(finalphase),omcversion,libversion.strip()))
if c==0:
raise Exception("No such model: %s" % model)
print("%s - %s" % (libname,model))
print("\n".join(lines))
print("")