VirtualBox

Ignore:
Timestamp:
Jun 3, 2016 6:47:31 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107783
Message:

wuitestresults,wuilogviewer: cross reference timestamps and the main log

Location:
trunk/src/VBox/ValidationKit/testmanager/webui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuilogviewer.py

    r61416 r61456  
    3939    """Log viewer."""
    4040
    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):
    4242        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;
    4748
    4849    def _generateNavigation(self, cbFile):
     
    125126               '</div>\n';
    126127
    127     def _displayLog(self, oFile, offFile, cbFile):
     128    def _displayLog(self, oFile, offFile, cbFile, aoTimestamps):
    128129        """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.
    129151        offEnd = offFile + self._cbChunk;
    130152        if offEnd > cbFile:
     
    136158        # numbers while we're at it.
    137159        #
    138         offCur  = 0;
    139         iLine   = 0;
     160        iCurTs           = 0;
     161        (sCurTs, sCurId) = prepCurTs();
     162        offCur           = 0;
     163        iLine            = 0;
    140164        while True:
    141165            sLine   = oFile.readline().decode('utf-8', 'replace');
     
    145169            if offCur >= offFile or len(sLine) == 0:
    146170                break;
     171            while isCurLineAtOrAfterCurTs():
     172                iCurTs += 1;
     173                (sCurTs, sCurId) = prepCurTs();
    147174
    148175        #
    149176        # Got to where we wanted, format the chunk.
    150177        #
    151         asLines = [];
     178        asLines = ['\n<div class="tmlog">\n<pre>\n', ];
    152179        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.
    153189            asLines.append('<a id="L%d" href="#L%d">%05d</a><a id="O%d"></a>%s\n' \
    154190                           % (iLine, iLine, iLine, offLine, webutils.escapeElem(sLine.rstrip())));
     191
     192            # next
    155193            if offCur >= offEnd:
    156194                break;
     
    161199            if len(sLine) == 0:
    162200                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);
    164203
    165204
     
    195234        offFile   = self._iChunk * self._cbChunk;
    196235        if offFile < cbFile:
    197             sHtml += self._displayLog(oFile, offFile, cbFile);
     236            sHtml += self._displayLog(oFile, offFile, cbFile, self._aoTimestamps);
    198237            sHtml += sNaviHtml;
    199238        else:
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuimain.py

    r61424 r61456  
    10171017        oTestSet = TestSetData().initFromDbWithId(self._oDb, idTestSet);
    10181018        if idLogFile == 0:
    1019             oTestFile = TestResultFileDataEx().initFakeMainLog(oTestSet);
     1019            oTestFile    = TestResultFileDataEx().initFakeMainLog(oTestSet);
     1020            aoTimestamps = TestResultLogic(self._oDb).fetchTimestampsForLogViewer(idTestSet);
    10201021        else:
    1021             oTestFile = TestSetLogic(self._oDb).getFile(idTestSet, idLogFile);
     1022            oTestFile    = TestSetLogic(self._oDb).getFile(idTestSet, idLogFile);
     1023            aoTimestamps = [];
    10221024        if oTestFile.sMime not in [ 'text/plain',]:
    10231025            raise WuiException('The log view does not display files of type: %s' % (oTestFile.sMime,));
    10241026
    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);
    10261029        (self._sPageTitle, self._sPageBody) = oContent.show();
    10271030        return True;
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuitestresult.py

    r61453 r61456  
    135135
    136136
     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
    137155    def _recursivelyGenerateEvents(self, oTestResult, sParentName, sLineage, iRow,
    138156                                   iFailure, oTestSet, iDepth):     # pylint: disable=R0914
     
    191209                     ' </tr>\n' \
    192210                   % ( '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),
    194213                       sElapsedGraph,
    195214                       webutils.escapeElem(self.formatIntervalShort(oTestResult.tsElapsed)) if oTestResult.tsElapsed is not None
     
    212231                     ' </tr>\n' \
    213232                   % ( '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),
    215235                       sDisplayName,
    216236                       'running' if oTestResult.tsElapsed is None else '', );
     
    235255                         ' </tr>\n' \
    236256                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
    237                            webutils.escapeElem(self.formatTsShort(oMsg.tsCreated)),
     257                           self._formatEventTimestampHtml(oMsg.tsCreated, oMsg.tsCreated, oMsg.idTestResultMsg, oTestSet),
    238258                           webutils.escapeElem(oMsg.enmLevel),
    239259                           webutils.escapeElem(oMsg.sMsg), );
     
    252272                         ' </tr>\n' \
    253273                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
    254                            webutils.escapeElem(self.formatTsShort(oValue.tsCreated)),
     274                           self._formatEventTimestampHtml(oValue.tsCreated, oValue.tsCreated, oValue.idTestResultValue, oTestSet),
    255275                           webutils.escapeElem(oValue.sName),
    256276                           utils.formatNumber(oValue.lValue).replace(' ', '&nbsp;'),
     
    301321                         ' </tr>\n' \
    302322                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
    303                            webutils.escapeElem(self.formatTsShort(oFile.tsCreated)),
     323                           self._formatEventTimestampHtml(oFile.tsCreated, oFile.tsCreated, oFile.idTestResultFile, oTestSet),
    304324                           '\n'.join(oLink.toHtml() for oLink in aoLinks),);
    305325                iRow += 1;
     
    307327            # Done?
    308328            if oTestResult.tsElapsed is not None:
     329                tsEvent = oTestResult.tsCreated + oTestResult.tsElapsed;
    309330                sHtml += ' <tr class="%s tmtbl-events-final tmtbl-events-lvl%s tmstatusrow-%s" id="E%d">\n' \
    310331                         '  <td>%s</td>\n' \
     
    316337                         ' </tr>\n' \
    317338                       % ( '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),
    319340                           sElapsedGraph,
    320341                           webutils.escapeElem(self.formatIntervalShort(oTestResult.tsElapsed)),
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette