Last active
July 11, 2021 18:48
-
-
Save kuharan/0fbaec13de24b8f9b08b9c2e559d65f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_html(json_data): | |
html_body = """<html><body><p style="text-align: center;"><span style="text-decoration: underline;"><strong>Data Protector XXXX Cell Manager No Backup Report</strong></span></p> | |
<table style="border-collapse: collapse; width: 9%; height: 85px; margin-left: auto; margin-right: auto;" border="1"> | |
<tbody> | |
<tr style="height: 18px;"> | |
<td style="width: 100%; height: 18px; text-align: left;"><span style="background-color: #258721;">< 1 Day </span></td> | |
</tr> | |
<tr style="height: 18px;"> | |
<td style="width: 100%; height: 18px;"> | |
<div> | |
<div><span style="background-color: #f76300;"><3 Days </span></div> | |
</div> | |
</td> | |
</tr> | |
<tr style="height: 18px;"> | |
<td style="width: 100%; height: 18px;"><span style="background-color: #ff0000;">>= 3 Days </span></td> | |
</tr> | |
</tbody> | |
</table>""" | |
for item in json_data: | |
Y=int(item['time_since_last_sucess_run'].split('-')[0]) | |
M=int(item['time_since_last_sucess_run'].split('-')[1]) | |
D=int(item['time_since_last_sucess_run'].split('-')[2]) | |
h=int(item['time_since_last_sucess_run'].split('-')[3]) | |
m=int(item['time_since_last_sucess_run'].split('-')[4]) | |
duration = "" | |
if Y!=0: | |
duration = duration + str(Y) + ' Years ' | |
if M!=0: | |
duration = duration + str(Y) + ' Months ' | |
if D!=0: | |
duration = duration + str(D) + ' Days ' | |
if h!=0: | |
duration = duration + str(h) + ' hours ' | |
if m!=0: | |
duration = duration + str(m) + ' minutes ' | |
hex_color = "" | |
if D>=3: | |
hex_color='#ff0000' | |
elif D>=1: | |
hex_color='#f76300' | |
else: | |
hex_color='#258721' | |
row = """<p><strong>["""+item['datalist']+"""]</strong> backup has <span style="color: """+hex_color+""";"><strong>[NOT]</strong></span> ran for """+duration+"""<br /><strong>"""+item['name']+""" Backup Completed </strong><a href="mailto:"""+item['owner']+"""">"""+item['owner']+"""</a></p><p> </p>""" | |
html_body = html_body+row | |
html_body = html_body+"</body></html>" | |
with open("output.html", 'w') as f: | |
f.write(html_body) | |
return html_body | |
html_body = create_html(all_completed_runs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment