Changeset 61456 in vbox for trunk/src/VBox/ValidationKit/testmanager/webui
- Timestamp:
- Jun 3, 2016 6:47:31 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107783
- Location:
- trunk/src/VBox/ValidationKit/testmanager/webui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/webui/wuilogviewer.py
r61416 r61456 39 39 """Log viewer.""" 40 40 41 def __init__(self, oTestSet, oLogFile, cbChunk, iChunk, oDisp = None, fnDPrint = None):41 def __init__(self, oTestSet, oLogFile, cbChunk, iChunk, aoTimestamps, oDisp = None, fnDPrint = None): 42 42 WuiContentBase.__init__(self, oDisp = oDisp, fnDPrint = fnDPrint); 43 self._oTestSet = oTestSet; 44 self._oLogFile = oLogFile; 45 self._cbChunk = cbChunk; 46 self._iChunk = iChunk; 43 self._oTestSet = oTestSet; 44 self._oLogFile = oLogFile; 45 self._cbChunk = cbChunk; 46 self._iChunk = iChunk; 47 self._aoTimestamps = aoTimestamps; 47 48 48 49 def _generateNavigation(self, cbFile): … … 125 126 '</div>\n'; 126 127 127 def _displayLog(self, oFile, offFile, cbFile ):128 def _displayLog(self, oFile, offFile, cbFile, aoTimestamps): 128 129 """Displays the current section of the log file.""" 130 from testmanager.core import db; 131 132 def prepCurTs(): 133 """ Formats the current timestamp. """ 134 if iCurTs < len(aoTimestamps): 135 oTsZulu = db.dbTimestampToZuluDatetime(aoTimestamps[iCurTs]); 136 return (oTsZulu.strftime('%H:%M:%S.%f'), oTsZulu.strftime('%H_%M_%S_%f')); 137 return '~~|~~|~~|~~~~~~'; # ASCII chars with high values. Limit hits. 138 139 def isCurLineAtOrAfterCurTs(): 140 """ Checks if the current line starts with a timestamp that is after the current one. """ 141 if len(sLine) >= 15 \ 142 and sLine[2] == ':' \ 143 and sLine[5] == ':' \ 144 and sLine[8] == '.' \ 145 and sLine[14] in '0123456789': 146 if sLine[:15] >= sCurTs and iCurTs < len(aoTimestamps): 147 return True; 148 return False; 149 150 # Figure the end offset. 129 151 offEnd = offFile + self._cbChunk; 130 152 if offEnd > cbFile: … … 136 158 # numbers while we're at it. 137 159 # 138 offCur = 0; 139 iLine = 0; 160 iCurTs = 0; 161 (sCurTs, sCurId) = prepCurTs(); 162 offCur = 0; 163 iLine = 0; 140 164 while True: 141 165 sLine = oFile.readline().decode('utf-8', 'replace'); … … 145 169 if offCur >= offFile or len(sLine) == 0: 146 170 break; 171 while isCurLineAtOrAfterCurTs(): 172 iCurTs += 1; 173 (sCurTs, sCurId) = prepCurTs(); 147 174 148 175 # 149 176 # Got to where we wanted, format the chunk. 150 177 # 151 asLines = [ ];178 asLines = ['\n<div class="tmlog">\n<pre>\n', ]; 152 179 while True: 180 # The timestamp IDs. 181 sPrevTs = ''; 182 while isCurLineAtOrAfterCurTs(): 183 if sPrevTs != sCurTs: 184 asLines.append('<a id="%s"></a>' % (sCurId,)); 185 iCurTs += 1; 186 (sCurTs, sCurId) = prepCurTs(); 187 188 # The line. 153 189 asLines.append('<a id="L%d" href="#L%d">%05d</a><a id="O%d"></a>%s\n' \ 154 190 % (iLine, iLine, iLine, offLine, webutils.escapeElem(sLine.rstrip()))); 191 192 # next 155 193 if offCur >= offEnd: 156 194 break; … … 161 199 if len(sLine) == 0: 162 200 break; 163 return '\n<div class="tmlog">\n<pre>\n' + ''.join(asLines) + '<pre/></div>\n'; 201 asLines.append('<pre/></div>\n'); 202 return ''.join(asLines); 164 203 165 204 … … 195 234 offFile = self._iChunk * self._cbChunk; 196 235 if offFile < cbFile: 197 sHtml += self._displayLog(oFile, offFile, cbFile );236 sHtml += self._displayLog(oFile, offFile, cbFile, self._aoTimestamps); 198 237 sHtml += sNaviHtml; 199 238 else: -
trunk/src/VBox/ValidationKit/testmanager/webui/wuimain.py
r61424 r61456 1017 1017 oTestSet = TestSetData().initFromDbWithId(self._oDb, idTestSet); 1018 1018 if idLogFile == 0: 1019 oTestFile = TestResultFileDataEx().initFakeMainLog(oTestSet); 1019 oTestFile = TestResultFileDataEx().initFakeMainLog(oTestSet); 1020 aoTimestamps = TestResultLogic(self._oDb).fetchTimestampsForLogViewer(idTestSet); 1020 1021 else: 1021 oTestFile = TestSetLogic(self._oDb).getFile(idTestSet, idLogFile); 1022 oTestFile = TestSetLogic(self._oDb).getFile(idTestSet, idLogFile); 1023 aoTimestamps = []; 1022 1024 if oTestFile.sMime not in [ 'text/plain',]: 1023 1025 raise WuiException('The log view does not display files of type: %s' % (oTestFile.sMime,)); 1024 1026 1025 oContent = WuiLogViewer(oTestSet, oTestFile, cbChunk, iChunk, oDisp = self, fnDPrint = self._oSrvGlue.dprint); 1027 oContent = WuiLogViewer(oTestSet, oTestFile, cbChunk, iChunk, aoTimestamps, 1028 oDisp = self, fnDPrint = self._oSrvGlue.dprint); 1026 1029 (self._sPageTitle, self._sPageBody) = oContent.show(); 1027 1030 return True; -
trunk/src/VBox/ValidationKit/testmanager/webui/wuitestresult.py
r61453 r61456 135 135 136 136 137 def _formatEventTimestampHtml(self, tsEvent, tsLog, idEvent, oTestSet): 138 """ Formats an event timestamp with a main log link. """ 139 tsEvent = db.dbTimestampToZuluDatetime(tsEvent); 140 #sFormattedTimestamp = u'%04u\u2011%02u\u2011%02u\u00a0%02u:%02u:%02uZ' \ 141 # % ( tsEvent.year, tsEvent.month, tsEvent.day, 142 # tsEvent.hour, tsEvent.minute, tsEvent.second,); 143 sFormattedTimestamp = u'%02u:%02u:%02uZ' \ 144 % ( tsEvent.hour, tsEvent.minute, tsEvent.second,); 145 sTitle = u'#%u - %04u\u2011%02u\u2011%02u\u00a0%02u:%02u:%02u.%06uZ' \ 146 % ( idEvent, tsEvent.year, tsEvent.month, tsEvent.day, 147 tsEvent.hour, tsEvent.minute, tsEvent.second, tsEvent.microsecond, ); 148 tsLog = db.dbTimestampToZuluDatetime(tsLog); 149 sFragment = u'%02u_%02u_%02u_%06u' % ( tsLog.hour, tsLog.minute, tsLog.second, tsLog.microsecond); 150 return WuiTmLink(sFormattedTimestamp, '', 151 { WuiMain.ksParamAction: WuiMain.ksActionViewLog, 152 WuiMain.ksParamLogSetId: oTestSet.idTestSet, }, 153 sFragmentId = sFragment, sTitle = sTitle, fBracketed = False, ).toHtml(); 154 137 155 def _recursivelyGenerateEvents(self, oTestResult, sParentName, sLineage, iRow, 138 156 iFailure, oTestSet, iDepth): # pylint: disable=R0914 … … 191 209 ' </tr>\n' \ 192 210 % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, oTestResult.enmStatus, oTestResult.idTestResult, 193 oTestResult.idTestResult, webutils.escapeElem(self.formatTsShort(tsEvent)), 211 oTestResult.idTestResult, 212 self._formatEventTimestampHtml(tsEvent, oTestResult.tsCreated, oTestResult.idTestResult, oTestSet), 194 213 sElapsedGraph, 195 214 webutils.escapeElem(self.formatIntervalShort(oTestResult.tsElapsed)) if oTestResult.tsElapsed is not None … … 212 231 ' </tr>\n' \ 213 232 % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, 214 webutils.escapeElem(self.formatTsShort(oTestResult.tsCreated)), ## @todo more timeline stuff later. 233 self._formatEventTimestampHtml(oTestResult.tsCreated, oTestResult.tsCreated, 234 oTestResult.idTestResult, oTestSet), 215 235 sDisplayName, 216 236 'running' if oTestResult.tsElapsed is None else '', ); … … 235 255 ' </tr>\n' \ 236 256 % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, 237 webutils.escapeElem(self.formatTsShort(oMsg.tsCreated)),257 self._formatEventTimestampHtml(oMsg.tsCreated, oMsg.tsCreated, oMsg.idTestResultMsg, oTestSet), 238 258 webutils.escapeElem(oMsg.enmLevel), 239 259 webutils.escapeElem(oMsg.sMsg), ); … … 252 272 ' </tr>\n' \ 253 273 % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, 254 webutils.escapeElem(self.formatTsShort(oValue.tsCreated)),274 self._formatEventTimestampHtml(oValue.tsCreated, oValue.tsCreated, oValue.idTestResultValue, oTestSet), 255 275 webutils.escapeElem(oValue.sName), 256 276 utils.formatNumber(oValue.lValue).replace(' ', ' '), … … 301 321 ' </tr>\n' \ 302 322 % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, 303 webutils.escapeElem(self.formatTsShort(oFile.tsCreated)),323 self._formatEventTimestampHtml(oFile.tsCreated, oFile.tsCreated, oFile.idTestResultFile, oTestSet), 304 324 '\n'.join(oLink.toHtml() for oLink in aoLinks),); 305 325 iRow += 1; … … 307 327 # Done? 308 328 if oTestResult.tsElapsed is not None: 329 tsEvent = oTestResult.tsCreated + oTestResult.tsElapsed; 309 330 sHtml += ' <tr class="%s tmtbl-events-final tmtbl-events-lvl%s tmstatusrow-%s" id="E%d">\n' \ 310 331 ' <td>%s</td>\n' \ … … 316 337 ' </tr>\n' \ 317 338 % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, oTestResult.enmStatus, oTestResult.idTestResult, 318 webutils.escapeElem(self.formatTsShort(oTestResult.tsCreated + oTestResult.tsElapsed)),339 self._formatEventTimestampHtml(tsEvent, tsEvent, oTestResult.idTestResult, oTestSet), 319 340 sElapsedGraph, 320 341 webutils.escapeElem(self.formatIntervalShort(oTestResult.tsElapsed)),
Note:
See TracChangeset
for help on using the changeset viewer.