Skip to content

Commit 1e3d4a8

Browse files
authored
do not fail on non existing branches, add them to the email (#101)
* do not fail on non existing branches, add them to the email * properly change color to red
1 parent 684b251 commit 1e3d4a8

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

all-plots.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,19 @@ def plotLibrary(branch, libname, xs, total, frontend,backend,simcode,template,co
9999
for branch in branches:
100100
try:
101101
cursor.execute("SELECT name FROM [sqlite_master] WHERE type='table' AND name=?", (branch,))
102-
v = cursor.fetchone()[0]
102+
one = cursor.fetchone()
103+
if one == None:
104+
print("No such table '%s'; specify it using --branch=XXX when running test.py" % branch)
105+
# ignore this table and continue
106+
continue
107+
else:
108+
v = one[0]
103109
except:
104-
raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)
105-
106-
for branch in branches:
110+
# raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)
111+
print("No such table '%s'; specify it using --branch=XXX when running test.py" % branch)
112+
# ignore this table and continue
113+
continue
114+
107115
cursor.execute('''CREATE INDEX IF NOT EXISTS [idx_%s_date] ON [%s](date)''' % (branch,branch))
108116
libs = {}
109117
for (date,libname,total,frontend,backend,simcode,template,compile,simulate,verify) in cursor.execute("""SELECT date,libname,COUNT(finalphase),COUNT(finalphase>=1 or null),COUNT(finalphase>=2 or null),COUNT(finalphase>=3 or null),COUNT(finalphase>=4 or null),COUNT(finalphase>=5 or null),COUNT(finalphase>=6 or null),COUNT(finalphase>=7 or null)

all-reports.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,26 @@ def libraryLink(branch, libname):
6666
def modelLink(libname, modelname, extension, text):
6767
return '<a href="%s/%s/%s/files/%s_%s.%s">%s</a>' % (baseurl,branch,libname,libname,modelname,extension,text)
6868

69+
missing_branches = []
6970
emails_to_send = {}
7071
for branch in branches:
7172
try:
7273
cursor.execute("SELECT name FROM [sqlite_master] WHERE type='table' AND name=?", (branch,))
73-
v = cursor.fetchone()[0]
74-
except:
75-
raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)
74+
one = cursor.fetchone()
75+
if one == None:
76+
print("No such table '%s'; specify it using --branch=XXX when running test.py" % branch)
77+
# ignore this table and continue
78+
missing_branches.append(branch)
79+
continue
80+
else:
81+
v = one[0]
82+
except:
83+
#raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)
84+
print("No such table '%s'; specify it using --branch=XXX when running test.py" % branch)
85+
# ignore this table and continue
86+
missing_branches.append(branch)
87+
continue
88+
7689
cursor.execute('''CREATE INDEX IF NOT EXISTS [idx_%s_date] ON [%s](date)''' % (branch,branch))
7790
cursor.execute("SELECT date,omcversion FROM [omcversion] WHERE branch LIKE ? COLLATE NOCASE ORDER BY date ASC", (branch,))
7891
entries = cursor.fetchall()
@@ -256,23 +269,32 @@ def modelLink(libname, modelname, extension, text):
256269
from email.headerregistry import Address
257270
from email.utils import make_msgid
258271

272+
missing_plain = ""
273+
missing_html = ""
274+
if missing_branches:
275+
missing_plain = ", ".join(missing_branches)
276+
missing_plain = "Report asks for missing branches which we ignored: %s\n" % missing_plain
277+
missing_html = ("%s %s %s" % ("<p style=\"color:red;\">", missing_plain, "</p"))
278+
259279
for email in sorted(emails_to_send.keys()):
260280
msg = EmailMessage()
261281
msg['Subject'] = 'OpenModelica Library Testing Regressions'
262282
msg['From'] = Address("OM Hudson", "openmodelicabuilds", "ida.liu.se")
263283
msg['To'] = email
264284
msg.set_content("""\
285+
%s
265286
The following reports contain regressions your account was involved with:
266-
""" + "\n".join(reversed(emails_to_send[email]["plain"])))
287+
""" % missing_plain + "\n".join(reversed(emails_to_send[email]["plain"])))
267288
msg.add_alternative("""\
268289
<html lang="en">
269290
<head></head>
270291
<body>
292+
%s
271293
<p>The following reports contain regressions your account was involved with:</p>
272294
%s
273295
</body>
274296
</html>
275-
""" % "\n".join(reversed(emails_to_send[email]["html"])), subtype='html')
297+
""" % (missing_html, "\n".join(reversed(emails_to_send[email]["html"]))), subtype='html')
276298
with smtplib.SMTP('smtp.office365.com') as s:
277299
s.starttls()
278300
s.ehlo()

0 commit comments

Comments
 (0)