Commits

Akeem Wells authored be24f9c9793
Update weblog to have line wrapping on Safari and Firefox browsers
No tags

casatestutils/casatestutils/weblog.py

Modified
1 1 import os
2 2 import logging
3 +import re
3 4
4 5 logging.debug("Importing CASAtools")
5 6 import casatools
6 7 tb = casatools.table()
7 8
8 9 class Weblog():
9 10 def __init__(self, taskname, localdict):
10 11 self.localdict = localdict
11 12 self.taskname = taskname
12 13 self.test_counter = 1
93 94 self.html.write(' font-size: 40px;' + '\n')
94 95 self.html.write(' font-weight: bold;' + '\n')
95 96 self.html.write(' transition: 0.3s;' + '\n')
96 97 self.html.write('}' + '\n')
97 98 self.html.write('.close:hover,' + '\n')
98 99 self.html.write('.close:focus {' + '\n')
99 100 self.html.write(' color: #bbb;' + '\n')
100 101 self.html.write(' text-decoration: none;' + '\n')
101 102 self.html.write(' cursor: pointer;' + '\n')
102 103 self.html.write('}' + '\n')
104 +
105 + self.html.write('.wrap {' + '\n')
106 + self.html.write(' text-wrap: wrap; text-wrap-style: wrap;flex: 1 0 auto;' + '\n')
107 + self.html.write('}' + '\n')
108 +
109 +
103 110 self.html.write('/* 100% Image Width on Smaller Screens */' + '\n')
104 111 self.html.write('@media only screen and (max-width: 700px){' + '\n')
105 112 self.html.write(' .modal-content {' + '\n')
106 113 self.html.write(' width: 100%;' + '\n')
107 114 self.html.write(' }' + '\n')
108 115 self.html.write('} ' + '\n')
109 116
110 117
111 118
112 119 def generate_status_table_style(self,dictionary):
232 239 self.html.write('<i><sub>{}</sub></i>'.format(dictionary[key]['description'])+ '\n')
233 240 self.html.write('<p><b>Elapsed Time:</b> {} Seconds</p>'.format(dictionary[key]['runtime'])+ '\n')
234 241 self.html.write('<p><b>Status:</b> {}</p>'.format("PASS" if dictionary[key]['status'] == True else "FAIL" )+ '\n')
235 242 self.html.write('<p><b>Task Executions:</b></p>'+ '\n')
236 243
237 244 def write_inline_list(self, array):
238 245 with open("test_{}_weblog.html".format(self.taskname.lower()), 'a+') as self.html:
239 246 self.html.write('<ul>' + '\n')
240 247 for item in array:
241 248 if isinstance(item,str):
242 - self.html.write('<li>{}</li>'.format(item.replace('\\,','\n')) + '\n')
249 + item = re.sub(r",(?=(?:[^'\"]*[\"'][^\"]*[\"'])*[^\"']*$)", ", ", item)
250 + self.html.write('<li class="wrap">{}</li>'.format(item.replace('\\,','\n')) + '\n')
243 251 else:
244 - self.html.write('<li>{}</li>'.format(item) + '\n')
252 + self.html.write('<li class="wrap">{}</li>'.format(item) + '\n')
245 253 if str(item).endswith(".png"):
246 254 self.html.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>'+ '\n')
247 255 self.html.write('<img class="myImg" src="{}" alt="{}" height="300" width="300">'.format(item, item) + '\n')
248 256 self.html.write('<div id="myModal" class="modal">'+ '\n')
249 257 self.html.write(' <span class="close" onclick="document.getElementById(\'myModal\').style.display=\'none\'">&times;</span>' + '\n')
250 258 self.html.write(' <img class="modal-content" id="img01">' + '\n')
251 259 self.html.write(' <div id="caption"></div>' + '\n')
252 260 self.html.write('</div>' + '\n')
253 261 self.html.write('</img>' + '\n')
254 262 self.html.write('</ul>' + '\n')
280 288
281 289
282 290 def generate_weblog(self,show_passed):
283 291 logging.debug("Generating Weblog: {}".format(self.taskname))
284 292 Weblog(self.taskname, self.localdict).generate_header("Test {}".format(self.taskname))
285 293 Weblog(self.taskname, self.localdict).generate_status_table_style(self.localdict)
286 294 Weblog(self.taskname, self.localdict).generate_status_table(self.localdict, show_passed)
287 295 Weblog(self.taskname, self.localdict).generate_summary_box(self.localdict, show_passed)
288 296 Weblog(self.taskname, self.localdict).generate_tail(self.localdict)
289 297
298 +

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut