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
|
#!/usr/bin/python
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
import icommon
def find_info_where(package_info, clause):
ret = []
for info in package_info:
if clause(info):
ret.append(info)
return ret
def get_info():
db = icommon.StatusDatabase(icommon.sqlite_file)
return db.summarise_failures()[1]
def update_failed_counts(package_info, cb):
outstanding = find_info_where(package_info, lambda x: x.queued)
running = find_info_where(package_info, lambda x: x.running)
failed = len(package_info) - len(outstanding) - len(running)
cb(len(outstanding), failed)
def get_main_packages():
db = icommon.PackageDatabase(icommon.sqlite_package_file)
return db.list_packages_in_main()
def filter_packages(filter_set, package_info):
return find_info_where(package_info, lambda x: x.name in filter_set)
def main():
package_info = get_info()
db = icommon.HistoryDatabase(icommon.sqlite_history_file)
update_failed_counts(package_info, db.set_counts)
main_packages = get_main_packages()
main_package_info = filter_packages(main_packages, package_info)
update_failed_counts(main_package_info, db.set_main_counts)
if __name__ == '__main__':
main()
|