def __GetDataSets(self, concatRegEx=[]): if (self.__mode == FSelectDataSetDialog.__TREE): paths = [] rootItem = self.__treeCtrl.GetRootItem() if (rootItem.IsOk()): for childItem, childDataSetDir in self.__visibleRoot: dir = os.path.dirname(os.path.abspath(childDataSetDir)) dir = FUtils.GetRelativePath(dir, os.getcwd()) self.__GetCheckedRecursive(paths, childItem, dir, False) regEx = [] if (len(paths) != 0): regEx.append("") if (concatRegEx == []): concatRegEx.append("") curIndex = 0 concatCurIndex = len(concatRegEx) - 1 for path in paths: relPath = FUtils.NormalizeRegEx( FUtils.GetRelativePath(path, MAIN_FOLDER)) newRegEx = regEx[curIndex] + relPath + "|" concatNewRegEx = (concatRegEx[concatCurIndex] + relPath + "|") if (len(newRegEx) < 30000): regEx[curIndex] = newRegEx else: regEx[curIndex] = regEx[curIndex][:-1] regEx.append(relPath + "|") curIndex = curIndex + 1 if (len(concatNewRegEx) < 30000): concatRegEx[concatCurIndex] = concatNewRegEx else: concatRegEx[concatCurIndex] = concatRegEx[ concatCurIndex][:-1] concatRegEx.append(relPath + "|") concatCurIndex = concatCurIndex + 1 regEx[curIndex] = regEx[curIndex][:-1] concatRegEx[concatCurIndex] = concatRegEx[concatCurIndex][:-1] else: regEx = self.__GetRegEx() paths, items = self.__GetPathsAndItems(regEx) if (regEx == ""): regEx = [] else: if (len(concatRegEx) == 0): concatRegEx.append("") concatNewRegEx = concatRegEx[-1] + regEx if (len(concatNewRegEx) < 30000): concatRegEx[-1] = concatNewRegEx else: # the text control only allows up to 30k characters concatRegEx.append(regEx) regEx = [regEx] return (paths, regEx)
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 RemoveTest(self, key): deletedSettings = self.__testList[key].GetSettings() for regExId in self.GetRegExIdGenerator(): if (deletedSettings == self.GetRegExSettings(regExId)): ignoredRegEx = self.GetIgnoredRegExList(regExId) if (len(ignoredRegEx) == 0): ignoredRegEx.append("") displayedFilename = FUtils.GetRelativePath( self.__testList[key].GetDataSetPath(), MAIN_FOLDER) regExPath = FUtils.NormalizeRegEx(displayedFilename) newIgnored = ignoredRegEx[-1] if (newIgnored != ""): newIgnored = newIgnored + "|" newIgnored = newIgnored + regExPath if (len(newIgnored) < 30000): ignoredRegEx[-1] = newIgnored else: ignoredRegEx.append(regExPath) self.SetIgnoredRegEx(regExId, ignoredRegEx) try: testDir = os.path.join(self.__procedureDir, TEST_PREFIX + str(key)) shutil.rmtree(testDir) except Exception, e: pass
def __UpdateStep(self, execution): if (not self.__CheckExecution(self.__curTestProcedure, self.__curTest, execution)): raise ValueError, "An invalid execution came in" stepList = [] self.__animationSteps = [] relExecutionDir = os.path.join(RUNS_FOLDER, self.__curTestProcedure, self.__curTest, execution) relExecutionPath = os.path.join(relExecutionDir, EXECUTION_FILENAME) # dangerous method call -- optimization only execution = self.Load(relExecutionPath) for step, app, op, settings in ( self.__curTestProcedureObject.GetStepGenerator()): if ((self.__type == FImageType.IMAGE) or (self.__type == FImageType.ANIMATION)): output = execution.GetOutputLocation(step) if (output == None): continue if (not type(output) is types.ListType): continue #validation miniList = [] for entry in output: miniList.append( FUtils.GetRelativePath(entry, relExecutionDir)) self.__animationSteps.append(miniList) stepList.append( FUtils.GetRelativePath(os.path.dirname(output[-1]), relExecutionDir)) elif (self.__type == FImageType.LOG): output = execution.GetLog(step) if (output == None): continue stepList.append(FUtils.GetRelativePath(output, relExecutionDir)) self.__stepCombo.Clear() self.__stepCombo.AppendItems(stepList)
def __PopulateTreeRecurse(self, tree, child, path, fullPath): """Recursively adds entries to the tree. It assumes that the tree has a root already. It will add folders and files to the tree from path to the child along with the icon next to the text. Data sets are defined once there is a file inside a folder with the same proper name as the file. The tree marks data sets by enclosing them in square brackets. arguments: tree -- The TreeCtrl (or subtree) to fill in. child -- The index of the item in the tree to add more items to. path -- The path of where to get the items. """ file, dirs = self.GetValidFileAndDirs(path) if (file != None): newChild = tree.AppendItem(child, "[" + os.path.basename(file) + "]") self.__allPaths.append((os.path.normpath(file), newChild)) tree.SetPyData(newChild, [ FSelectDataSetDialog.__FILE, FSelectDataSetDialog.__UNCHECKED ]) tree.SetItemImage(newChild, self.__iconUnchecked, wx.TreeItemIcon_Normal) return newChild if (fullPath): newChild = tree.AppendItem( child, FUtils.GetRelativePath(path, MAIN_FOLDER)) else: newChild = tree.AppendItem(child, os.path.basename(path)) tree.SetPyData( newChild, [FSelectDataSetDialog.__FOLDER, FSelectDataSetDialog.__UNCHECKED]) tree.SetItemImage(newChild, self.__iconUnchecked, wx.TreeItemIcon_Normal) for dir in dirs: self.__PopulateTreeRecurse(tree, newChild, dir, False) return newChild
def __OnMakeDefault(self, e): e.Skip() # Rewrite the default blessed file to include these local filenames. blessedDir = os.path.join(self.__dataSetPath, BLESSED_DIR) defaultContainerFilename = os.path.join(blessedDir, BLESSED_DEFAULT_FILE) blessFile = open(defaultContainerFilename, "w") if (self.__filenames != None) and (len(self.__filenames) > 0): for filename in self.__filenames: relativeFilename = FUtils.GetRelativePath(filename, blessedDir) blessFile.write(relativeFilename) blessFile.write("\n") else: pass # Intentionally leave empty. Can we actually get here in the UI? blessFile.close() if (self.__callback != None): self.__callback(True)