def __OnSaveAs(self, e): # contains some of the same code as in FRunConfigDialog if (not os.path.isdir(RUNS_FOLDER)): print("<FTestSuiteGUI> No test procedures directory... " + "this is weird... returning") return dialog = wx.TextEntryDialog(self, "Name to save test procedure.", "Save Test Procedure As", "", wx.OK | wx.CANCEL | wx.CENTER) while (True): if (dialog.ShowModal() == wx.ID_OK): value = dialog.GetValue() if (value == ""): FUtils.ShowWarning(self, "Enter a non empty name.") continue if (value == self.__testProcedure.GetName()): FUtils.ShowWarning( self, "Entered name is same as current name.") continue if (not FUtils.IsValidFilename(value)): FUtils.ShowWarning( self, "Not valid title for test " + "procedure; cannot contain the following " + "characters: \n" + FUtils.GetInvalidString()) continue if (os.path.isdir(os.path.join(RUNS_FOLDER, value))): message = ("A test procedure with name \"" + value + "\" already exists. Overwrite?") if (not FUtils.ShowConfirmation(self, message, False)): continue break else: return busyInfo = wx.BusyInfo("Saving test procedure. Please wait...") src = os.path.normpath( os.path.join(RUNS_FOLDER, self.__testProcedure.GetName())) dest = os.path.normpath(os.path.join(RUNS_FOLDER, value)) if (os.path.isdir(dest)): try: print "removing " + dest shutil.rmtree(dest) except OSError, e: text = (str(dest) + " is in use. Select another name for " + "the run or close any application using that " + "directory.") self.__ShowWarning(text) return
def __OnOk(self, e): e.Skip() if (not self.__width.GetValue().isdigit()): FUtils.ShowWarning(self, "Width is not a number") return if (not self.__height.GetValue().isdigit()): FUtils.ShowWarning(self, "Height is not a number") return if (self.IsModal()): self.EndModal(wx.ID_OK) else: self.SetReturnCode(wx.ID_OK) self.Show(False)
def __OnCompare(self, e): keys = self.__grid.GetSelectedKeys() if (len(keys) != 1): FUtils.ShowWarning(self, "Select only 1 execution.") return test = self.__testProcedure.GetTest(keys[0]) if (test.GetCurrentExecution() == None): FUtils.ShowWarning(self, "Test not ran.") return compareDialog = FCompareSetupDialog( self, FImageType.EXECUTION, self.__testProcedure.GetName(), os.path.basename(test.GetTestDir()), os.path.basename(test.GetCurrentExecutionDir())) if (compareDialog.ShowModal() == wx.ID_OK): path = compareDialog.GetPath() if (path != None): blessed = compareDialog.GetShowBlessed() dialogTestProcedure = compareDialog.GetTestProcedure() self.__WarnIfOpened(dialogTestProcedure) testFilename = os.path.join(RUNS_FOLDER, dialogTestProcedure, compareDialog.GetTest(), TEST_FILENAME) tuples = [] if (blessed): blessedExecution = test.GetBlessedExecution( self.__testProcedure) if (blessedExecution != None): tuples.append((test, blessedExecution)) tuples.append((self.Load(testFilename), self.Load(path))) tuples.append((test, test.GetCurrentExecution())) self.__grid.PartialRefreshRemove(test) dialog = FExecutionDialog(self, "Execution Comparison", self.__testProcedure, tuples, self.__animateAll, self.configDict["feelingViewerGUI"], self.configDict["pythonExecutable"], self.__GetPreferences()) dialog.ShowModal() self.__grid.PartialRefreshAdd(test) self.__grid.PartialRefreshDone()
def __OnContextShowPrevious(self, e): keys = self.__grid.GetSelectedKeys() if (len(keys) != 1): FUtils.ShowWarning(self, "Select only 1 execution.") return test = self.__testProcedure.GetTest(keys[0]) self.__grid.PartialRefreshRemove(test) executions = test.GetHistory() tuples = [] for execution in executions: tuples.append((test, execution)) self.__WarnIfOpened(self.__testProcedure.GetName()) frame = FExecutionDialog(self, "Previous Execution", self.__testProcedure, tuples, self.__animateAll, self.configDict["feelingViewerGUI"], self.configDict["pythonExecutable"], self.__GetPreferences()) frame.ShowModal() frame.Destroy() self.__grid.PartialRefreshAdd(test) self.__grid.PartialRefreshDone()
def Open(e): # Open the default viewer for this file. if (os.path.isfile(file)): # XXX: this is windows only os.startfile("\"" + file + "\"") else: FUtils.ShowWarning(grid.GetParent(), "Missing File.")
def __OnUpdate(self, e): try: self.__UnCheckTree() paths, items = self.__GetPathsAndItems(self.__GetRegEx()) for item in items: self.__Check(self.__treeCtrl, item) except re.error, e: FUtils.ShowWarning(self, "Bad regular expression.")
def OpenTestProcedure(self, filename): testProcedure = self.__BusyInfoOpenTestProcedure(filename) recovered = testProcedure.GetRecoveredTestIds() if (recovered != ""): FUtils.ShowWarning( self, "Encountered unfinished test " + "executions. Recovering to previous finished execution " + "for these tests:\n\n" + recovered) for regExId in testProcedure.GetRegExIdGenerator(): dataSets = self.__BusyInfoCheckForNewTests(testProcedure, regExId) if (len(dataSets) == 0): continue displayDataSets = "" for dataSet in dataSets: displayDataSets = ( displayDataSets + FUtils.GetRelativePath(dataSet, MAIN_FOLDER) + "\n") if (FUtils.ShowConfirmation( self, "Found these missing data sets for " + "Regular Expression " + str(regExId) + ": \n" + testProcedure.GetRegExString(regExId) + "\n\n\n" + displayDataSets + "\n\n" + "Do you want to add them to the test procedure? " + "Selecting \"No\" will also ignore them from future " + "confirmations.", False)): settings = testProcedure.GetRegExSettings(regExId) for dataSet in dataSets: testProcedure.AddTest(dataSet, settings) else: ignored = testProcedure.GetIgnoredRegExList(regExId) if (len(ignored) == 0): ignored.append("") # len(dataSet) != 0 for dataSet in dataSets: displayedFilename = FUtils.GetRelativePath( dataSet, MAIN_FOLDER) regExPath = FUtils.NormalizeRegEx(displayedFilename) newIgnored = ignored[-1] if (newIgnored != ""): newIgnored = newIgnored + "|" newIgnored = newIgnored + regExPath if (len(newIgnored) < 30000): ignored[-1] = newIgnored else: ignored.append(regExPath) testProcedure.SetRegEx(regExId, testProcedure.GetRegExList(regExId), ignored) busyInfo = wx.BusyInfo("Opening test procedure: Creating grid. " + "Please wait...") child = RunTable(self.__MDIparent, wx.ID_ANY, testProcedure) child.Maximize(True) child.Show(True)
def __WarnIfOpened(self, name): loadedTestProcedures = self.GetParent().GetLoadedTestProcedure(name) for mdiId, testProcedure in loadedTestProcedures: if ((mdiId != self.__mdiId) and (testProcedure != None)): FUtils.ShowWarning( self, "Another window is using " + "the selected test procedure. If you make " + "changes in the comparison, you will need " + "to reload to synchronize the displayed " + "values.") break
def __OnViewSettings(self, e): if (len(self.__grid.GetSelectedKeys()) == 0): return if (len(self.__grid.GetSelectedKeys()) > 1): FUtils.ShowWarning(self, "Select only one test to view settings.") return key = self.__grid.GetSelectedKeys()[0] setting = self.__testProcedure.GetTest(key).GetSettings() FSettingDialog(self, self.__testProcedure, self.applicationMap, False, setting).ShowModal()
def Compare(e): if (self.__diffCommand == ""): FUtils.ShowWarning(grid.GetParent(), "No diff program selected") return dialog = FCompareSetupDialog(grid, FCompareSetupDialog.LOG, logEntry[3], logEntry[2], logEntry[1]) if (dialog.ShowModal() == wx.ID_OK): command = self.__diffCommand.replace( "%base", "\"" + os.path.abspath(logEntry[0]) + "\"") command = command.replace( "%mine", "\"" + os.path.abspath(dialog.GetPath()) + "\"") os.system("\"" + command + "\"")
def __OnContextViewBlessed(self, e): if (len(self.__grid.GetSelectedKeys()) == 0): return if (len(self.__grid.GetSelectedKeys()) > 1): FUtils.ShowWarning(self, "Select only one test to view settings.") return key = self.__grid.GetSelectedKeys()[0] test = self.__testProcedure.GetTest(key) # FBlessedViewerDialog may unbless. self.__grid.PartialRefreshRemove(test) FBlessedViewerDialog(self, test.GetDataSetPath()).ShowModal() self.__grid.PartialRefreshAdd(test) self.__grid.PartialRefreshDone()
def Compare(e): if (self.__diffCommand == ""): FUtils.ShowWarning(grid.GetParent(), "No diff program selected") return dialog = FCompareSetupDialog( grid, FCompareSetupDialog.LOG, self.__testProcedure.GetName(), os.path.basename(imageData.GetTest().GetTestDir()), imageData.GetExecutionName()) if (dialog.ShowModal() == wx.ID_OK): command = self.__diffCommand.replace( "%base", "\"" + renderedArea.GetFilename() + "\"") command = command.replace( "%mine", "\"" + os.path.abspath(dialog.GetPath()) + "\"") os.system("\"" + command + "\"")
def __OnOk(self, e): """Call-back function when OK button is pressed. arguments: e -- the event generated by the OK button being pressed. """ if (not self.__settingsSizer.IsSettingOk()): FUtils.ShowWarning(self, "There's an invalid setting.") return if (self.IsModal()): self.EndModal(wx.ID_OK) else: self.SetReturnCode(wx.ID_OK) self.Show(False)
def __OnFinish(self, e): settings = self.__settingsPage.GetSettings() regExId = self.__testProcedure.GetRegExId(settings) if (regExId == -1): concatRegEx = [] else: concatRegEx = copy.deepcopy( self.__testProcedure.GetRegExList(regExId)) if (concatRegEx[-1] != ""): concatRegEx[-1] = concatRegEx[-1] + "|" try: paths, regEx = self.__GetDataSets(concatRegEx) except re.error, ex: FUtils.ShowWarning(self, "Bad regular expression.") e.Veto() return
def __OnUnbless(self, e): e.Skip() # Delete the blessed image files. for filename in self.__filenames: os.remove(filename) foundFile = False for element in os.listdir(os.path.dirname(filename)): if (element != ".svn"): foundFile = True break if (not foundFile): deleteDirectory = os.path.abspath(os.path.dirname(filename)) try: shutil.rmtree(deleteDirectory) except OSError, e: FUtils.ShowWarning( self, "Unable to delete " + deleteDirectory + ".\n" + "Error:\n" + str(e) + "\n Please delete directory manually.")
def __OnPageChanging(self, e): if (not self.__settingsSizer.IsSettingOk()): FUtils.ShowWarning(self, "There's an invalid setting.") e.Veto() else: e.Skip()