def addCutMark(self,frame,cutEntry,rowIndex): item = QListWidgetItem() img = CVImage(frame).scaled(self.ui_VideoFrame.imageRatio*SIZE_ICON, SIZE_ICON) pix = QtGui.QPixmap.fromImage(img) item.setIcon(QIcon(pix)) if cutEntry.isStartMode(): item.setBackgroundColor(QColor(224,255,224)) else: item.setBackgroundColor(QColor(255,224,224)) self.ui_List.insertItem(rowIndex,item) text = "%s <br> F: %s<br> T: %s" %(cutEntry.modeString,str(cutEntry.frameNumber),str(cutEntry.getTimeString())) marker = QLabel(text) marker.setWordWrap(True) marker.layout() self.ui_List.setItemWidget(item,marker) self.ui_List.setIconSize(QSize(SIZE_ICON,SIZE_ICON)) #Forces an update! self.ui_List.setCurrentItem(item)
def testFinished(self, id): # build the gui item from the test object currentTest = self.tm.tests[id] red = QtGui.QColor(255,64,0) green = QtGui.QColor(121,158,0) yellow = QtGui.QColor(205,249,62) item = QtGui.QStandardItem(currentTest.name) item.setToolTip(currentTest.description) if currentTest.state is "Success": item.setBackground(green) item.setIcon(QtGui.QIcon(os.getcwd() + "/icns/success.png")) elif currentTest.state is "Failure": item.setBackground(red) item.setIcon(QtGui.QIcon(os.getcwd() + "/icns/failure.png")) elif currentTest.state is "Warning": item.setBackground(yellow) item.setIcon(QtGui.QIcon(os.getcwd() + "/icns/warning.png")) currentTest.setResultWidget(item) self.model.appendRow(item) dw = DetailsWindow() dw.setWindowTitle("Details for %s" % currentTest.name) for detail in currentTest.details: item = QListWidgetItem(detail) if detail.startswith("Failure"): item.setBackgroundColor(red) elif detail.startswith("Warning"): item.setBackgroundColor(yellow) elif detail.startswith("Success"): item.setBackgroundColor(green) dw.addDetail(item) currentTest.setDetailsWindow(dw) self.ui.results_GroupBox.setTitle("Results (click to view details)")
def demoButtonHandler(self): if not self.validate_inputs(): return # needed so that the click listener can find the correct id's for test_id in range(len(self.checkboxes)): if self.checkboxes[test_id].isChecked(): self.allthetests.append(test_id+1) red = QtGui.QColor(255,64,0) green = QtGui.QColor(121,158,0) yellow = QtGui.QColor(205,249,62) self.lockUi(True) # create a bunch of demo test objects self.demoTests = [] self.demoTests.append(TestICMP(1, "ICMPv6 Filtering", "", None, self)) self.demoTests.append(TestRoutingHeader(2, "Routing Header Test", "", None, self)) self.demoTests.append(TestHeaderChain(3, "Header Chain Test", "", None, self)) self.demoTests.append(TestOverlappingFragments(4, "Overlapping Fragments Test", "", None, self)) self.demoTests.append(TestTinyFramgents(5, "Tiny Fragments Test", "", None, self)) self.demoTests.append(TestTinyFramgentsTimeout(6, "Tiny Fragments Timeout", "", None, self)) self.demoTests.append(TestExcessiveHBHOptions(7, "Excessive Extension Options Test", "", None, self)) self.demoTests.append(TestPadNCovertChannel(8, "PadN Covert Channel Test", "", None, self)) self.demoTests.append(TestAddressScopes(9, "Address Scopes Test", "", None, self)) # create a list of fake results fakeICMP = [self.fakeResult("Test1Type1"), self.fakeResult("Test1Type2"), self.fakeResult("Test1Type3Code0"), self.fakeResult("Test1Type4Code1"), self.fakeResult("Test1Type4Code2"), self.fakeResult("Test1Type128"), self.fakeResult("Test1Type129")] fakeRH = [self.fakeResult("Test2Step1"), self.fakeResult("Test2Step4"), self.fakeResult("Test2Step5")] fakeHC = [] for step in range(1,8): fakeHC.append(self.fakeResult("Test3Step%d" % step)) fakeOverlap = [self.fakeResult("Test4Step1")] fakeTiny = [] fakeTimeout = [] fakeExcess = [self.fakeResult("Test6Step2"), self.fakeResult("Test6Step3"), self.fakeResult("Test6Step4"), self.fakeResult("Test6Step5"), self.fakeResult("Test6Step6"), self.fakeResult("Test6Step8")] fakePadN = [] for step in range(1,5): fakePadN.append(self.fakeResult("Test7Step%d" % step)) fakeAddress = [] fakeResults = [ fakeICMP, fakeRH, fakeHC, fakeOverlap, fakeTiny, fakeTimeout, fakeExcess, fakePadN, fakeAddress] sleepTimes = [5, 1, 1, 1, 1, 0, 1, 1, 3] # iterate over all tests, call evaluate for each. # build gui items and set colors according to the results for test in self.demoTests: self.update_status.emit("Executing test: %s %s" % (test.name, test.statusbar_detail)) self.repaint() time.sleep(sleepTimes[test.id - 1]) item = QtGui.QStandardItem(test.name) item.setToolTip(test.description) results = test.evaluate(fakeResults[test.id -1 ]) state = "Success" for result in results: if "Warning!" in (result[:8]): state = "Warning" if "Failure!" in (result[:8]): state = "Failure" break if state is "Success": item.setBackground(green) item.setIcon(QtGui.QIcon(os.getcwd() + "/icns/success.png")) elif state is "Failure": item.setBackground(red) item.setIcon(QtGui.QIcon(os.getcwd() + "/icns/failure.png")) elif state is "Warning": item.setBackground(yellow) item.setIcon(QtGui.QIcon(os.getcwd() + "/icns/warning.png")) if test.id == 6: item.setBackground(yellow) item.setIcon(QtGui.QIcon(os.getcwd() + "/icns/warning.png")) self.model.appendRow(item) self.repaint() dw = DetailsWindow() dw.setWindowTitle("Details for %s" % test.name) if test.id == 6: item = QListWidgetItem("Information: Since Tiny Fragments can't traverse your firewall, there is no point in determining the timeout for such fragments. This test is therefore skipped!") dw. addDetail(item) test.setDetailsWindow(dw) continue for r in results: item = QListWidgetItem(r) if r.startswith("Failure"): item.setBackgroundColor(red) if r.startswith("Warning"): item.setBackgroundColor(yellow) if r.startswith("Success"): item.setBackgroundColor(green) dw.addDetail(item) test.setDetailsWindow(dw) self.repaint()