-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathclean-empty-omcversion-dates.py
More file actions
executable file
·43 lines (37 loc) · 1.16 KB
/
Copy pathclean-empty-omcversion-dates.py
File metadata and controls
executable file
·43 lines (37 loc) · 1.16 KB
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
#!/usr/bin/env python3
import argparse, sys
import resultsdb
from datetime import datetime
parser = argparse.ArgumentParser(description='OpenModelica library testing tool')
resultsdb.addArgument(parser)
args = parser.parse_args()
db = resultsdb.connect(args.db)
cursor = db.cursor()
entries = cursor.execute("SELECT date,branch FROM omcversion").fetchall()
dropped=0
branches=set()
branchDates = {}
for (date,branch) in entries:
branches.add(branch)
if branch not in branchDates:
branchDates[branch] = set()
branchDates[branch].add(date)
for branch in branches:
# The shared database holds the branches of every machine, including ones
# this one never created a result table for.
if not db.tableExists(branch):
continue
data=cursor.execute("SELECT DISTINCT date FROM %s" % db.quote(branch)).fetchall()
for (date,) in data:
try:
branchDates[branch].remove(date)
except KeyError:
pass
for date in branchDates[branch]:
print("Dropping empty omcversion entry (%d,%s)" % (date,branch))
cursor.execute("DELETE FROM omcversion WHERE date=? AND branch=?", (date,branch))
dropped += 1
db.commit()
if dropped>0:
db.vacuum()
db.close()