-
Notifications
You must be signed in to change notification settings - Fork 2
/
bundle_hound.py
91 lines (36 loc) · 1.22 KB
/
bundle_hound.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python3
import certifi
import json
import pprint
import sys
import urllib3
from pprint import PrettyPrinter
from urllib.request import urlopen
def main():
"""
Validates bundles' metadata by checking if titles, descriptions,
and tags are empty and reports results.
"""
http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED',ca_certs=certifi.where())
req = http.request(
'GET',
"https://download.clearlinux.org/releases/current/assets/bundles/bundles.json",
timeout=10.0)
if req.status != 200:
print(f'[Error] Connection: {req.status} {req.reason}')
sys.exit(2)
json_data = json.loads(req.data.decode('utf-8'))
bundles = json_data["bundles"]
missing = [ b['title'] for b in bundles if not b['description'] or not b['tags'] ]
if missing:
print("Bundles missing metadata:")
pprint.pprint(f"{missing}", width=1)
print("")
no_title = [ b for b in bundles if not b['title'] ]
if no_title:
print("Bundles missing title:")
pprint.pprint(no_title)
if missing or no_title:
sys.exit(1)
if __name__ == "__main__":
main()