def _convertTime(dt):
    '''
    Coverts the given time to the text representation.
    '''
    if isinstance(dt, (float, int, long)):
        return utils.localTime(dt)[1]
    return utils.timeToString(dt).split(utils.DATE_TIME_SEPARATOR)[1]
 def stopTest(self, result, device):
     '''
     Processes a test stop execution for the XML channel.
     '''
     channels.TestResultFileChannel.stopTest(self, result, device)
     element = self._deviceElement(device, result)
     status = element.find("status")
     if status is None:
         status = _subElement(element, "status", pos=_DEVICE_STATUS_POS)
     status.text = device.status
     _subElement(element, "time", device.time, pos=_DEVICE_TIME_POS)
     if device.errors:
         errors = _subElement(element, "errors")
         for error in device.errors:
             _subElement(errors, "error", error)
     if device.cores:
         cores = _subElement(element, "cores")
         for core in device.cores:
             elem = _subElement(cores, "core")
             _subElement(elem, "path", core.path)
             if self.isVerbose():
                 _subElement(elem, "date",
                             ' '.join(utils.localTime(core.mtime)))
                 _subElement(elem, "size", core.size)
     self.write()
def _convertDate(dt):
    '''
    Coverts the given date to the text representation.
    '''
    if isinstance(dt, (float, int, long)):
        return utils.DATE_TIME_SEPARATOR.join(utils.localTime(dt))
    return utils.timeToString(dt)
Beispiel #4
0
    def showDetails(self, result):
        '''
        Displays details of the given test result.
        '''
        tree = self._treeWidget

        def makeItem(parent,
                     name,
                     value="",
                     color=None,
                     font=None,
                     expand=True,
                     span=False):
            item = QtGui.QTreeWidgetItem(parent)
            nLabel = QtGui.QLabel(tree)
            nLabel.setText(utils.decode(name))
            item.setSizeHint(0, nLabel.sizeHint() + QtCore.QSize(10, 0))
            tree.setItemWidget(item, 0, nLabel)
            if font is not None:
                nLabel.setFont(font)
            if span:
                item.setFirstColumnSpanned(True)
            else:
                vLabel = QtGui.QLabel(tree)
                vLabel.setMinimumWidth(self._treeWidget.sizeHint().width() -
                                       self._treeWidget.columnWidth(0) - 1)
                tree.setItemWidget(item, 1, vLabel)
                if color:
                    vLabel.setText(u"<font color=\"%s\">%s</font>" %
                                   (color.color().name(), utils.decode(value)))
                else:
                    vLabel.setText(utils.decode(value))
                vLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
                item.setSizeHint(
                    1,
                    QtCore.QSize(vLabel.sizeHint().width() + 10,
                                 vLabel.sizeHint().height()))
            if expand:
                item.setExpanded(True)
            return item

        self.clearDetails()
        log.debug("Displaying selected tree item for result '%s'" % result.id)
        makeItem(tree, "Id", result.id)
        makeItem(tree, "Path", result.path)
        makeItem(tree,
                 "Status",
                 result.status,
                 color=STATUS_COLORS[result.status],
                 font=STATUS_FONTS[result.status])
        if result.attrs:
            item = makeItem(tree, "Attributes")
            for name, value in result.attrs.iteritems():
                makeItem(item, name, value)
        if isinstance(result, TestStepResult):
            makeItem(tree, "Function", result.func)
            if result.args:
                item = makeItem(tree, "Arguments")
                for name, value in result.args.iteritems():
                    makeItem(item, name, value)
        if result.devices:
            item = makeItem(tree, "Devices")
            for devResult in result.devices:
                devItem = makeItem(item, devResult.name, span=True)
                if devResult.description is not None:
                    makeItem(devItem, "Description", devResult.description)
                if devResult.address is not None:
                    makeItem(devItem, "Address", devResult.address)
                if devResult.port is not None:
                    makeItem(devItem, "Port", devResult.port)
                if devResult.status is not None:
                    makeItem(devItem,
                             "Status",
                             devResult.status,
                             color=STATUS_COLORS[devResult.status],
                             font=STATUS_FONTS[devResult.status])
                if devResult.errors:
                    errItem = makeItem(devItem, "Errors")
                    for error in devResult.errors:
                        makeItem(errItem, "", error)
                if devResult.cores:
                    coresItem = makeItem(devItem, "Cores")
                    for core in devResult.cores:
                        coreItem = makeItem(coresItem,
                                            core.path,
                                            expand=False,
                                            span=True)
                        makeItem(coreItem, "Size",
                                 "%s" % utils.sizeToString(core.size))
                        makeItem(coreItem, "Date",
                                 " ".join(utils.localTime(core.mtime)))
                if devResult.date:
                    makeItem(devItem, "Date",
                             utils.timeToString(devResult.date))
                if devResult.time:
                    makeItem(devItem, "Time", "%.6fs" % devResult.time)
        self._treeWidget.resizeColumnToContents(0)
        self._treeWidget.resizeColumnToContents(1)
Beispiel #5
0
    def showDetails(self, result):
        '''
        Displays details of the given test result.
        '''
        tree = self._treeWidget

        def makeItem(parent, name, value="", color=None, font=None,
                     expand=True, span=False):
            item = QtGui.QTreeWidgetItem(parent)
            nLabel = QtGui.QLabel(tree)
            nLabel.setText(utils.decode(name))
            item.setSizeHint(0, nLabel.sizeHint() + QtCore.QSize(10, 0))
            tree.setItemWidget(item, 0, nLabel)
            if font is not None:
                nLabel.setFont(font)
            if span:
                item.setFirstColumnSpanned(True)
            else:
                vLabel = QtGui.QLabel(tree)
                vLabel.setMinimumWidth(self._treeWidget.sizeHint().width() -
                                       self._treeWidget.columnWidth(0) - 1)
                tree.setItemWidget(item, 1, vLabel)
                if color:
                    vLabel.setText(u"<font color=\"%s\">%s</font>"
                                   % (color.color().name(),
                                      utils.decode(value)))
                else:
                    vLabel.setText(utils.decode(value))
                vLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
                item.setSizeHint(1, QtCore.QSize(vLabel.sizeHint().width() + 10,
                                                 vLabel.sizeHint().height()))
            if expand:
                item.setExpanded(True)
            return item

        self.clearDetails()
        log.debug("Displaying selected tree item for result '%s'" % result.id)
        makeItem(tree, "Id", result.id)
        makeItem(tree, "Path", result.path)
        makeItem(tree, "Status", result.status,
                 color=STATUS_COLORS[result.status],
                 font=STATUS_FONTS[result.status])
        if result.attrs:
            item = makeItem(tree, "Attributes")
            for name, value in result.attrs.iteritems():
                makeItem(item, name, value)
        if isinstance(result, TestStepResult):
            makeItem(tree, "Function", result.func)
            if result.args:
                item = makeItem(tree, "Arguments")
                for name, value in result.args.iteritems():
                    makeItem(item, name, value)
        if result.devices:
            item = makeItem(tree, "Devices")
            for devResult in result.devices:
                devItem = makeItem(item, devResult.name, span=True)
                if devResult.description is not None:
                    makeItem(devItem, "Description", devResult.description)
                if devResult.address is not None:
                    makeItem(devItem, "Address", devResult.address)
                if devResult.port is not None:
                    makeItem(devItem, "Port", devResult.port)
                if devResult.status is not None:
                    makeItem(devItem, "Status", devResult.status,
                             color=STATUS_COLORS[devResult.status],
                             font=STATUS_FONTS[devResult.status])
                if devResult.errors:
                    errItem = makeItem(devItem, "Errors")
                    for error in devResult.errors:
                        makeItem(errItem, "", error)
                if devResult.cores:
                    coresItem = makeItem(devItem, "Cores")
                    for core in devResult.cores:
                        coreItem = makeItem(coresItem, core.path, expand=False,
                                            span=True)
                        makeItem(coreItem, "Size",
                                 "%s" % utils.sizeToString(core.size))
                        makeItem(coreItem, "Date",
                                 " ".join(utils.localTime(core.mtime)))
                if devResult.date:
                    makeItem(devItem, "Date",
                             utils.timeToString(devResult.date))
                if devResult.time:
                    makeItem(devItem, "Time", "%.6fs" % devResult.time)
        self._treeWidget.resizeColumnToContents(0)
        self._treeWidget.resizeColumnToContents(1)