-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_metrics_dashboard.py
72 lines (51 loc) · 2.48 KB
/
build_metrics_dashboard.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
#!/usr/bin/env python3
import os
import re
def main():
# print("started\n")
# Increment the version in the first file
out_string=""
version_string="Service Security Posture Hardening Programme : v"
filename=os.path.dirname(__file__)+"\\SSPHP\SSPHP_metrics\\default\\data\\ui\\views\\ssphp_metrics_dashboard.d\\ssphp_metrics_dashboard_block_1.xml"
with open(filename, "r") as f:
for x in f:
if version_string in x:
#print(x)
v=re.search(r' : v(\d*\.\d*)\<\/description\>', x)
version_old=float(v.group(1))
version_new=f'{version_old+0.01:.2f}'
version_old=f'{version_old:.2f}'
x=x.replace(version_old,version_new)
#print(x)
out_string=out_string+x
with open(filename, "w") as f:
for x in out_string:
f.write(x)
# Process the files
out_string=""
filename=os.path.dirname(__file__)+"\\SSPHP\SSPHP_metrics\\default\\data\\ui\\views\\ssphp_metrics_dashboard.d\\ssphp_metrics_dashboard_block_1.xml"
with open(filename, "r") as f:
for x in f:
out_string=out_string+x
out_string=out_string+"\n\n\n"
iv=[{"detail":"dns","heading":"DNS"},{"detail":"aad","heading":"Azure Active Directory"},{"detail":"azr","heading":"Azure"},{"detail":"m365","heading":"Office 365"},{"detail":"busc","heading":"Business Central"}]
for service_name in iv:
filename=os.path.dirname(__file__)+"\\SSPHP\SSPHP_metrics\\default\\data\\ui\\views\\ssphp_metrics_dashboard.d\\ssphp_metrics_dashboard_block_2.xml"
with open(filename, "r") as f:
for x in f:
x=x.replace("~~~~",service_name["detail"])
x=x.replace("^^^^",service_name["heading"])
out_string=out_string+x
out_string=out_string+"\n\n\n"
filename=os.path.dirname(__file__)+"\\SSPHP\SSPHP_metrics\\default\\data\\ui\\views\\ssphp_metrics_dashboard.d\\ssphp_metrics_dashboard_block_3.xml"
with open(filename, "r") as f:
for x in f:
out_string=out_string+x
out_string=out_string+"\n\n\n"
filename=os.path.dirname(__file__)+"\\SSPHP\SSPHP_metrics\\default\\data\\ui\\views\\ssphp_metrics_dashboard.xml"
with open(filename, "w") as f:
for x in out_string:
f.write(x)
print("\ndone - output file was "+filename+"\nnew version="+version_new)
if __name__ == "__main__":
main()