Example #1
0
 def extractLogSectionElapsed(sLogContent, tsStart, tsElapsed):
     """
     Returns log section from tsStart and tsElapsed forward (or all if we cannot make sense of it).
     """
     tsStart = db.dbTimestampToZuluDatetime(tsStart)
     tsLast = tsStart + tsElapsed
     return TestSetData.extractLogSection(sLogContent, tsStart, tsLast)
Example #2
0
 def formatTsShort(self, oTs):
     """
     Formats a timestamp (db rep) into a short form.
     """
     oTsZulu = db.dbTimestampToZuluDatetime(oTs)
     sTs = oTsZulu.strftime('%Y-%m-%d %H:%M:%SZ')
     return unicode(sTs).replace('-', u'\u2011').replace(' ', u'\u00a0')
Example #3
0
 def prepCurTs():
     """ Formats the current timestamp. """
     if iCurTs < len(aoTimestamps):
         oTsZulu = db.dbTimestampToZuluDatetime(aoTimestamps[iCurTs])
         return (oTsZulu.strftime('%H:%M:%S.%f'),
                 oTsZulu.strftime('%H_%M_%S_%f'))
     return ('~~|~~|~~|~~~~~~', '~~|~~|~~|~~~~~~')
 def formatTsShort(self, oTs):
     """
     Formats a timestamp (db rep) into a short form.
     """
     oTsZulu = db.dbTimestampToZuluDatetime(oTs)
     sTs = oTsZulu.strftime("%Y-%m-%d %H:%M:%SZ")
     return unicode(sTs).replace("-", u"\u2011").replace(" ", u"\u00a0")
Example #5
0
 def extractLogSectionElapsed(sLogContent, tsStart, tsElapsed):
     """
     Returns log section from tsStart and tsElapsed forward (or all if we cannot make sense of it).
     """
     tsStart = db.dbTimestampToZuluDatetime(tsStart);
     tsLast  = tsStart + tsElapsed;
     return TestSetData.extractLogSection(sLogContent, tsStart, tsLast);
Example #6
0
 def formatTsShort(self, oTs):
     """
     Formats a timestamp (db rep) into a short form.
     """
     oTsZulu = db.dbTimestampToZuluDatetime(oTs);
     sTs = oTsZulu.strftime('%Y-%m-%d %H:%M:%SZ');
     return unicode(sTs).replace('-', u'\u2011').replace(' ', u'\u00a0');
Example #7
0
 def _formatEventTimestampHtml(self, tsEvent, tsLog, idEvent, oTestSet):
     """ Formats an event timestamp with a main log link. """
     tsEvent = db.dbTimestampToZuluDatetime(tsEvent);
     #sFormattedTimestamp = u'%04u\u2011%02u\u2011%02u\u00a0%02u:%02u:%02uZ' \
     #                    % ( tsEvent.year, tsEvent.month, tsEvent.day,
     #                        tsEvent.hour, tsEvent.minute, tsEvent.second,);
     sFormattedTimestamp = u'%02u:%02u:%02uZ' \
                         % ( tsEvent.hour, tsEvent.minute, tsEvent.second,);
     sTitle              = u'#%u - %04u\u2011%02u\u2011%02u\u00a0%02u:%02u:%02u.%06uZ' \
                         % ( idEvent, tsEvent.year, tsEvent.month, tsEvent.day,
                             tsEvent.hour, tsEvent.minute, tsEvent.second, tsEvent.microsecond, );
     tsLog = db.dbTimestampToZuluDatetime(tsLog);
     sFragment = u'%02u_%02u_%02u_%06u' % ( tsLog.hour, tsLog.minute, tsLog.second, tsLog.microsecond);
     return WuiTmLink(sFormattedTimestamp, '',
                      { WuiMain.ksParamAction:             WuiMain.ksActionViewLog,
                        WuiMain.ksParamLogSetId:           oTestSet.idTestSet,  },
                      sFragmentId = sFragment, sTitle = sTitle, fBracketed = False, ).toHtml();
Example #8
0
 def _formatEventTimestampHtml(self, tsEvent, tsLog, idEvent, oTestSet):
     """ Formats an event timestamp with a main log link. """
     tsEvent = db.dbTimestampToZuluDatetime(tsEvent);
     #sFormattedTimestamp = u'%04u\u2011%02u\u2011%02u\u00a0%02u:%02u:%02uZ' \
     #                    % ( tsEvent.year, tsEvent.month, tsEvent.day,
     #                        tsEvent.hour, tsEvent.minute, tsEvent.second,);
     sFormattedTimestamp = u'%02u:%02u:%02uZ' \
                         % ( tsEvent.hour, tsEvent.minute, tsEvent.second,);
     sTitle              = u'#%u - %04u\u2011%02u\u2011%02u\u00a0%02u:%02u:%02u.%06uZ' \
                         % ( idEvent, tsEvent.year, tsEvent.month, tsEvent.day,
                             tsEvent.hour, tsEvent.minute, tsEvent.second, tsEvent.microsecond, );
     tsLog = db.dbTimestampToZuluDatetime(tsLog);
     sFragment = u'%02u_%02u_%02u_%06u' % ( tsLog.hour, tsLog.minute, tsLog.second, tsLog.microsecond);
     return WuiTmLink(sFormattedTimestamp, '',
                      { WuiMain.ksParamAction:             WuiMain.ksActionViewLog,
                        WuiMain.ksParamLogSetId:           oTestSet.idTestSet,  },
                      sFragmentId = sFragment, sTitle = sTitle, fBracketed = False, ).toHtml();
Example #9
0
    def findLogOffsetForTimestamp(sLogContent,
                                  tsTimestamp,
                                  offStart=0,
                                  fAfter=False):
        """
        Log parsing utility function for finding the offset for the given timestamp.

        We ASSUME the log lines are prefixed with UTC timestamps on the format
        '09:43:55.789353'.

        Return index into the sLogContent string, 0 if not found.
        """
        # Turn tsTimestamp into a string compatible with what we expect to find in the log.
        oTsZulu = db.dbTimestampToZuluDatetime(tsTimestamp)
        sWantedTs = oTsZulu.strftime('%H:%M:%S.%f')
        assert len(sWantedTs) == 15

        # Now loop thru the string, line by line.
        offRet = offStart
        off = offStart
        while True:
            sThisTs = sLogContent[off:off + 15]
            if    len(sThisTs) >= 15 \
              and sThisTs[2]  == ':' \
              and sThisTs[5]  == ':' \
              and sThisTs[8]  == '.' \
              and sThisTs[14] in '0123456789':
                if sThisTs < sWantedTs:
                    offRet = off
                elif sThisTs == sWantedTs:
                    if not fAfter:
                        return off
                    offRet = off
                else:
                    if fAfter:
                        offRet = off
                    break

            # next line.
            off = sLogContent.find('\n', off)
            if off < 0:
                if fAfter:
                    offRet = len(sLogContent)
                break
            off += 1

        return offRet
Example #10
0
    def findLogOffsetForTimestamp(sLogContent, tsTimestamp, offStart = 0, fAfter = False):
        """
        Log parsing utility function for finding the offset for the given timestamp.

        We ASSUME the log lines are prefixed with UTC timestamps on the format
        '09:43:55.789353'.

        Return index into the sLogContent string, 0 if not found.
        """
        # Turn tsTimestamp into a string compatible with what we expect to find in the log.
        oTsZulu   = db.dbTimestampToZuluDatetime(tsTimestamp);
        sWantedTs = oTsZulu.strftime('%H:%M:%S.%f');
        assert len(sWantedTs) == 15;

        # Now loop thru the string, line by line.
        offRet  = offStart;
        off     = offStart;
        while True:
            sThisTs = sLogContent[off : off + 15];
            if    len(sThisTs) >= 15 \
              and sThisTs[2]  == ':' \
              and sThisTs[5]  == ':' \
              and sThisTs[8]  == '.' \
              and sThisTs[14] in '0123456789':
                if sThisTs < sWantedTs:
                    offRet = off;
                elif sThisTs == sWantedTs:
                    if not fAfter:
                        return off;
                    offRet = off;
                else:
                    if fAfter:
                        offRet = off;
                    break;

            # next line.
            off = sLogContent.find('\n', off);
            if off < 0:
                if fAfter:
                    offRet = len(sLogContent);
                break;
            off += 1;

        return offRet;
Example #11
0
    def show(self):
        """
        Generates the tooltip.
        Returns (sTitle, HTML).
        """
        sHtml = '<div class="tmvcstimeline tmvcstimelinetooltip">\n'

        oCurDate = None
        for oEntry in self.aoEntries:
            oTsZulu = db.dbTimestampToZuluDatetime(oEntry.tsCreated)
            if oCurDate is None or oCurDate != oTsZulu.date():
                if oCurDate is not None:
                    sHtml += ' </dl>\n'
                oCurDate = oTsZulu.date()
                sHtml += ' <h2>%s:</h2>\n' \
                         ' <dl>\n' \
                       % (oTsZulu.strftime('%Y-%m-%d'),)

            sEntry = '  <dt id="r%s">' % (oEntry.iRevision, )
            sEntry += '<a href="%s">' \
                    % ( webutils.escapeAttr(config.g_ksTracChangsetUrlFmt
                                            % { 'iRevision': oEntry.iRevision, 'sRepository': oEntry.sRepository,}), )

            sEntry += '<span class="tmvcstimeline-time">%s</span>' % (
                oTsZulu.strftime('%H:%MZ'), )
            sEntry += ' Changeset <span class="tmvcstimeline-rev">[%s]</span>' % (
                oEntry.iRevision, )
            sEntry += ' by <span class="tmvcstimeline-author">%s</span>' % (
                webutils.escapeElem(oEntry.sAuthor), )
            sEntry += '</a>\n'
            sEntry += '</dt>\n'
            sEntry += '  <dd>%s</dd>\n' % (webutils.escapeElem(
                oEntry.sMessage), )

            sHtml += sEntry

        if oCurDate is not None:
            sHtml += ' </dl>\n'
        sHtml += '</div>\n'

        return ('VCS History Tooltip', sHtml)
    def show(self):
        """
        Generates the tooltip.
        Returns (sTitle, HTML).
        """
        sHtml  = '<div class="tmvcstimeline tmvcstimelinetooltip">\n';

        oCurDate = None;
        for oEntry in self.aoEntries:
            oTsZulu = db.dbTimestampToZuluDatetime(oEntry.tsCreated);
            if oCurDate is None or oCurDate != oTsZulu.date():
                if oCurDate is not None:
                    sHtml += ' </dl>\n'
                oCurDate = oTsZulu.date();
                sHtml += ' <h2>%s:</h2>\n' \
                         ' <dl>\n' \
                       % (oTsZulu.strftime('%Y-%m-%d'),);

            sEntry  = '  <dt id="r%s">' % (oEntry.iRevision, );
            sEntry += '<a href="%s">' \
                    % ( webutils.escapeAttr(config.g_ksTracChangsetUrlFmt
                                            % { 'iRevision': oEntry.iRevision, 'sRepository': oEntry.sRepository,}), );

            sEntry += '<span class="tmvcstimeline-time">%s</span>' % ( oTsZulu.strftime('%H:%MZ'), );
            sEntry += ' Changeset <span class="tmvcstimeline-rev">[%s]</span>' % ( oEntry.iRevision, );
            sEntry += ' by <span class="tmvcstimeline-author">%s</span>' % ( webutils.escapeElem(oEntry.sAuthor), );
            sEntry += '</a>\n';
            sEntry += '</dt>\n';
            sEntry += '  <dd>%s</dd>\n' % ( webutils.escapeElem(oEntry.sMessage), );

            sHtml += sEntry;

        if oCurDate is not None:
            sHtml += ' </dl>\n';
        sHtml += '</div>\n';

        return ('VCS History Tooltip', sHtml);
 def prepCurTs():
     """ Formats the current timestamp. """
     if iCurTs < len(aoTimestamps):
         oTsZulu = db.dbTimestampToZuluDatetime(aoTimestamps[iCurTs]);
         return (oTsZulu.strftime('%H:%M:%S.%f'), oTsZulu.strftime('%H_%M_%S_%f'));
     return ('~~|~~|~~|~~~~~~', '~~|~~|~~|~~~~~~'); # ASCII chars with high values. Limit hits.
Example #14
0
 def prepCurTs():
     """ Formats the current timestamp. """
     if iCurTs < len(aoTimestamps):
         oTsZulu = db.dbTimestampToZuluDatetime(aoTimestamps[iCurTs]);
         return (oTsZulu.strftime('%H:%M:%S.%f'), oTsZulu.strftime('%H_%M_%S_%f'));
     return ('~~|~~|~~|~~~~~~', '~~|~~|~~|~~~~~~'); # ASCII chars with high values. Limit hits.