예제 #1
0
 def __GetSingleImageTag(self, mainDir, filename, width, height, 
             link = None):
     if (filename == None):
         return "Missing File"
     
     filename = FUtils.GetHtmlRelativePath(filename, mainDir)
     ext = FUtils.GetExtension(filename)
     
     if (link == None):
         link = filename
     else:
         link = FUtils.GetHtmlRelativePath(link, mainDir)
     
     tag = "<a href=\"" + link + "\"><img "
     
     if (FUtils.IsImageFile(ext)):
         tag = tag + "src=\"" + filename + "\" border=\"0\" "
     elif (ext == "dae"):
         tag = tag + "alt=\"Collada File\" border=\"1\" "
     elif (ext == "max"):
         tag = tag + "alt=\"Max File\" border=\"1\" "
     elif (ext == "mb"):
         tag = tag + "alt=\"Maya Binary File\" border=\"1\" "
     elif (ext == "ma"):
         tag = tag + "alt=\"Maya Ascii File\" border=\"1\" "
     else:
         tag = tag + "alt=\"Ext: " + ext + "\" border=\"1\" "
     
     return (tag + "" + "width=\"" + str(width) + 
            "\" height=\"" + str(height) + "\"></a>")
예제 #2
0
    def __OnOk(self, e):
        """Call-back function when OK button is pressed.
        
        It checks to make sure that:
            - there is at least 1 operation
            - there is a non-empty title for the run
            - the title for the run does not conflict with a previous run (or
            the user decides to overwrite
            
        arguments:
            e -- the event generated by the OK button being pressed.
            
        """
        self.title = self.__titleText.GetValue()
        if (self.title == ""):
            self.__ShowWarning("Enter a title for this setting.")
            return

        if (not FUtils.IsValidFilename(self.title)):
            self.__ShowWarning("Not valid title for test procedure; cannot " +
                               "contain the following characters: \n" +
                               FUtils.GetInvalidString())
            return

        for entry in self.__settingCtrls:
            entry[0].SetValue(entry[1].GetValue())

        if (self.IsModal()):
            self.EndModal(wx.ID_OK)
        else:
            self.SetReturnCode(wx.ID_OK)
            self.Show(False)
예제 #3
0
    def __GetCheckedRecursive(self, paths, item, dir, firstChild):
        """Appends to list the paths of checked files in tree from item down.
        
        arguments:
            paths -- The list to put the check paths in.
            item -- The index of the item in tree to determine if goes in list.
            dir -- The current directory of search.
            firstChild -- True if setting image on the first child.
        
        """
        directory, checked = self.__treeCtrl.GetItemPyData(item)
        if ((directory == FSelectDataSetDialog.__FILE)
                and (checked == FSelectDataSetDialog.__CHECKED)):
            # remove the [ ] enclosing brackets and extension
            filename = self.__treeCtrl.GetItemText(item)[1:-1]
            filename = FUtils.GetProperFilename(filename)
            paths.append(FUtils.GetCollapsePath(os.path.join(dir, filename)))

        if (self.__treeCtrl.ItemHasChildren(item)):
            child, cookie = self.__treeCtrl.GetFirstChild(item)
            self.__GetCheckedRecursive(
                paths, child,
                os.path.join(dir, self.__treeCtrl.GetItemText(item)), True)

        if (firstChild):
            sibling = self.__treeCtrl.GetNextSibling(item)
            while (sibling):
                self.__GetCheckedRecursive(paths, sibling, dir, False)
                sibling = self.__treeCtrl.GetNextSibling(sibling)
예제 #4
0
 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
예제 #5
0
    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)
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    def __eq__(self, other):
        if other is None: return False

        if (self.__comments != other.__comments): return False
        if (self.__environment != other.__environment): return False
        if (self.__crashIndices != other.__crashIndices): return False
        if (self.__judgingResults != other.__judgingResults): return False
        if (self.__checksum != other.__checksum): return False

        # Do not compare judging logs.
        # Do not compare time ran.

        if (len(self.__errorCounts) != len(other.__errorCounts)): return False
        for i in range(len(self.__errorCounts)):
            if (self.__errorCounts[i] != other.__errorCounts[i]): return False

        if (len(self.__warningCounts) != len(other.__warningCounts)):
            return False
        for i in range(len(self.__warningCounts)):
            if (self.__warningCounts[i] != other.__warningCounts[i]):
                return False

        # Do not compare log locations.
        if (len(self.__outputLocations) != len(other.__outputLocations)):
            return False
        for i in range(len(self.__outputLocations)):
            # validation
            if ((type(self.__outputLocations[i]) is types.StringType) and
                (type(other.__outputLocations[i]) is types.StringType)):
                continue
            if ((self.__outputLocations[i] == None)
                    and (other.__outputLocations[i] == None)):
                continue
            if ((self.__outputLocations[i] == None)
                    or (other.__outputLocations[i] == None)):
                return False
            if (len(self.__outputLocations[i]) != len(
                    other.__outputLocations[i])):
                return False
            for j in range(len(self.__outputLocations[i])):
                #todo what happens if file not there
                ext = FUtils.GetExtension(self.__outputLocations[i][j])
                if (FUtils.IsImageFile(ext)):
                    compareResult = FGlobals.imageComparator.CompareImages(
                        self.__outputLocations[i][j],
                        other.__outputLocations[i][j])
                    if (not compareResult.GetResult()): return False

        return True
예제 #9
0
    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()
예제 #10
0
    def __GetOpenFunc(self, file, type, grid):
        # Should we open an external loader?
        internalLoad = (type == FImageType.ANIMATION)
        if (type == FImageType.IMAGE):
            extension = FUtils.GetExtension(file).lower()
            if (extension == "png"):
                internalLoad = True
                file = [file]

        if internalLoad:

            def Open(e):
                # Open the internal viewer as a separate process.
                args = ([
                    "\"" + self.__pythonPath + "\"",
                    "\"" + FImageRenderer.__ANIMATION_FRAME_EXECUTABLE + "\""
                ])
                for filename in file:
                    args.append("\"" + filename + "\"")
                os.spawnv(os.P_DETACH, self.__pythonPath, args)
        else:

            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.")

        return Open
예제 #11
0
 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.")
예제 #12
0
    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()
예제 #13
0
    def WriteImport(self, filename, logname, outputDir, settings, isAnimated, cameraRig, lightingRig):
        """WriteImport(filename, logname, outputDir, settings, isAnimated, cameraRig, lightingRig) -> list_of_str

        """
        outputFormat = ".png"

        command = ("\"" + self.configDict["blenderPath"] + "\" -b \"" + self.configDict["blenderEmpty"] + "\" -o ")

        baseName = FUtils.GetProperFilename(filename)
        self.__currentImportProperName = baseName
        outputFilename = os.path.join(outputDir, baseName + "_out" + ".dae")
        self.__currentFilename = outputFilename
        imageFilename = os.path.join(outputDir, "result" + outputFormat)
        self.__currentImageName = imageFilename
        command = (command + "\"" + imageFilename + "\" -P \"" + self.__blenderScript.name + "\" --factory-startup -- \""+ self.configDict["blenderDefaultDae"] +"\" \"" + outputFilename + "\" \"" + imageFilename + "\" \"" + filename+"\"")

        print "***Importing: %s" % (filename)
        print "   Command %s" % (command)

        self.__blenderCommandLine = command

        self.WriteCrashDetect(self.__script, command, logname)

        self.__testImportCount = self.__testImportCount + 1

        return [os.path.normpath(outputFilename)]
예제 #14
0
    def Run(self, appPython, step, op, inStep, filename, settings, isAnimated,
            cameraRig, lightingRig, markerCallBack):
        # First run: calculate the check-sum.
        if (len(self.__checksum) == 0):
            self.__checksum = FUtils.CalculateChecksum(filename)

        # Run the test steps.
        if (self.__initializedSteps.count(step) == 0):
            self.__InitializeRun(appPython, step, op, inStep, filename,
                                 settings, isAnimated, cameraRig, lightingRig,
                                 markerCallBack)
            self.__initializedSteps.append(step)
        else:
            stepName = STEP_PREFIX + str(step)
            outDir = os.path.abspath(
                os.path.join(self.__executionDir, stepName))
            logFilename = stepName + "." + LOG_EXT
            logAbsFilename = os.path.join(outDir, stepName + "." + LOG_EXT)

            if ((inStep == 0) or (self.__outputLocations[inStep] == None)):
                curInputFile = os.path.abspath(filename)
            else:
                curInputFile = os.path.abspath(
                    self.__outputLocations[inStep][-1])

            output = appPython.AddToScript(op, curInputFile, logAbsFilename,
                                           outDir, settings, isAnimated,
                                           cameraRig, lightingRig)

            if markerCallBack != None and len(output) > 0:
                # Some annoying scripts don't give us valid paths.
                if not os.path.isabs(output[0]):
                    markerCallBack(False, os.path.join(outDir, output[0]))
                else:
                    markerCallBack(False, output[0])
예제 #15
0
 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.")
예제 #16
0
 def __ShowAssetTags(self, filename):
     assetFilename = os.path.abspath(
         FUtils.GetAvailableFilename(ASSET_FILENAME))
     f = open(assetFilename, "w")
     xml.sax.parse(filename, FAssetHandler(f))
     f.close()
     os.system("\"" + assetFilename + "\"")
     os.remove(assetFilename)
예제 #17
0
파일: FMax.py 프로젝트: yazici/COLLADA-CTS
    def WriteImport(self, filename, logname, outputDir, settings, isAnimated,
                    cameraRig, lightingRig):
        """WriteImport(filename, logname, outputDir, settings, isAnimated, cameraRig, lightingRig) -> list_of_str
        
        Implements FApplication.WriteImport()
        
        """
        self.__testCount = self.__testCount + 1
        baseName = FUtils.GetProperFilename(filename)
        self.__currentImportProperName = baseName

        baseName = baseName + FMax.__EXTENSION
        output = (os.path.join(outputDir, baseName)).replace("\\", "\\\\")
        writeableDir = os.path.dirname(filename).replace("\\", "\\\\")
        writeableFilename = filename.replace("\\", "\\\\")
        if (FUtils.GetExtension(filename) == FMax.__EXTENSION[1:]):
            command = "    loadMaxFile my_importfilename useFileUnits:true quiet:true\n"
        else:
            command = "    importFile my_importfilename #noprompt using:OpenCOLLADAImporter\n"

        cfgFilename = os.path.normpath(
            self.configDict["maxColladaExporterFilename"])
        cfgFilename = cfgFilename.replace("\\", "\\\\")

        options = "".join([
            "    setINISetting \"%s\" \"ColladaMax\" \"%s\" \"%s\"\n" %
            (cfgFilename, setting.GetCommand(), setting.GetValue())
            for setting in settings
        ])

        self.__script.write(
            "logfilename = \"" + logname.replace("\\", "\\\\") + "\"\n" +
            "openLog logfilename mode:\"w\" outputOnly:true\n" + "try (\n" +
            "    resetmaxfile #noprompt\n" + options +
            "    sysInfo.currentdir = \"" + writeableDir + "\"\n" +
            "    my_importfilename = \"" + writeableFilename + "\"\n" +
            command + "    saveMaxFile \"" + output + "\"\n" +
            "    print \"Import succeeded with " + writeableFilename + "\"\n" +
            ") catch (\n" + "    print \"Import error     with " +
            writeableFilename + "\"\n" + ")\n" + "flushLog()\n" +
            "closeLog()\n\n")

        return [
            os.path.normpath(baseName),
        ]
예제 #18
0
    def WriteImport(self, filename, logname, outputDir, settings, isAnimated, cameraRig, lightingRig):
        """WriteImport(filename, logname, outputDir, settings, isAnimated, cameraRig, lightingRig) -> list_of_str
        
        Implements FApplication.WriteImport(). Assumes a COLLADA, maya binary,
        or maya ascii file is being imported.
        
        """
        baseName = FUtils.GetProperFilename(filename)
        self.__currentImportProperName = baseName
        output = (os.path.join(outputDir, baseName)).replace("\\", "/")
        filename = filename.replace("\\", "/")
        self.__currentFilename = output + ".mb"
        
        # Generate the import options string.
        options = ""
        for setting in settings:
            value = setting.GetValue().strip()
            if len(value) == 0:
                value = self.FindDefault(FMaya_UIRender.__IMPORT_OPTIONS, setting.GetPrettyName())
            options = (options + setting.GetCommand() + "=" + value + ";")
        
        # Generate the import MEL command.
        extension = FUtils.GetExtension(filename).lower()        
        if (extension == "mb"): 
            command = ("catch(`file -type \"mayaBinary\" -o \"" + filename + "\"`);\n")
        elif (extension == "ma"): 
            command = ("catch(`file -type \"mayaAscii\" -o \"" + filename + "\"`);\n")
        else: 
            command = ("catch(`file -type \"COLLADA importer\" -op \"" + options + "\" -o \"" + filename + "\"`);\n")

        self.__melScript.write(
                "$logname = \"" + logname.replace("\\", "/") + "\";\n" +
                "$descriptor = `cmdFileOutput -o $logname`;\n" +
                "catch(`file -f -new`);\n" +
                command +
                "catch(`file -rename \"" + output + "\"`);\n" +
                "catch(`file -save -type \"mayaBinary\"`);\n" +
                "cmdFileOutput -c $descriptor;\n" + 
                "fixNewlines $logname;\n\n")
        
        self.__testImportCount = self.__testImportCount + 1
        
        return [os.path.normpath(baseName + ".mb"),]
예제 #19
0
    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()
예제 #20
0
    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
예제 #21
0
    def __GetImage(self, filename):
        if (not os.path.isfile(filename)):
            return wx.ImageFromBitmap(
                wx.ArtProvider.GetBitmap(wx.ART_MISSING_IMAGE, wx.ART_OTHER,
                                         (48, 48)))

        if (self.__IsRecognizable(filename)):
            return wx.Image(filename, wx.BITMAP_TYPE_ANY)

        bitmap = wx.EmptyBitmap(FImageData.__BITMAP_WIDTH,
                                FImageData.__BITMAP_HEIGHT)
        dc = wx.MemoryDC()
        dc.SelectObject(bitmap)
        dc.SetBackground(wx.WHITE_BRUSH)
        dc.Clear()

        dc.SetPen(wx.BLACK_PEN)
        bitmapWidth = FImageData.__BITMAP_WIDTH - 2
        bitmapHeight = FImageData.__BITMAP_HEIGHT - 2
        dc.DrawRectangle(0, 0, bitmapWidth, bitmapHeight)

        dc.SetBackgroundMode(wx.TRANSPARENT)
        dc.SetTextBackground(wx.WHITE)
        dc.SetTextForeground(wx.BLACK)

        font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        font.SetWeight(wx.BOLD)
        dc.SetFont(font)

        ext = FUtils.GetExtension(filename)
        if (ext == "dae"):
            text = "Collada File"
        elif (ext == "max"):
            text = "Max File"
        elif (ext == "ma"):
            text = "Maya Ascii File"
        elif (ext == "mb"):
            text = "Maya Binary File"
        else:
            text = ext + " File"
        width1, height1 = dc.GetTextExtent(text)
        width2, height2 = dc.GetTextExtent("(No Preview)")
        width = max(width1, width2)
        height = height1 + height2 + FImageData.__HEIGHT_SPACING

        textY = (bitmapHeight - height) / 2

        dc.DrawText(text, (bitmapWidth - width1) / 2, textY)
        dc.DrawText("(No Preview)", (bitmapWidth - width2) / 2,
                    textY + height1 + FImageData.__HEIGHT_SPACING)

        return bitmap.ConvertToImage()
예제 #22
0
    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)
예제 #23
0
    def __GetPathsAndItems(self, regEx):
        dir = FUtils.NormalizeRegEx(os.path.normpath(MAIN_FOLDER))
        pattern = re.compile(dir + "[/\\\\]" + regEx + "$")

        paths = []
        items = []
        for path, item in self.__allPaths:
            match = pattern.match(path)
            if (match != None):
                if (match.group() == path):
                    paths.append(os.path.dirname(path))
                    items.append(item)
        return (paths, items)
예제 #24
0
        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 + "\"")
예제 #25
0
    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()
예제 #26
0
    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
예제 #27
0
        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 + "\"")
예제 #28
0
    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)
예제 #29
0
    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
예제 #30
0
    def RunApplication(self, command, workingDir):
        """RunApplication(command, workingDir) -> int
        
        Runs the command in another process. (It should *not* be overriden by 
        any implemenations of application specific scripts)
        
        If detectCrash is "True" in the configuration file, then it will run 
        the command with the timeout specified in the configuration file. The 
        timeout is the amount of time without I/O that is allowed before 
        considering that there is a crash and then will kill the process. The
        return value will be 1 if a crash was detected and needed to kill 
        the command. The return value will be the return value of the command 
        if it finished.
        
        If detectCrash is not "True" in the configuration file, it will run and
        wait for the command to return. The return value will be 0.
        
        arguments:
            command
                string representing the command to execute.
            workingDir
                string corresponding to the directory that the script files 
                should be placed. This is a temporay directory and files placed
                in here should not be assumed to remain across different
                runnings of tests.
        
        """
        dccFilename = os.path.join(workingDir, "temporaryDCCProcess.py")
        dccFilename = FUtils.GetAvailableFilename(dccFilename)

        file = open(dccFilename, "w")
        self.WriteCrashDetectBegin(file)
        self.WriteCrashDetect(file, command)
        if (self.configDict["detectCrash"] == "True"):
            file.write("sys.exit(p.poll())\n")
        file.close()

        returnValue = subprocess.call("\"" +
                                      self.configDict["pythonExecutable"] +
                                      "\" \"" + dccFilename + "\"")

        os.remove(dccFilename)
        return returnValue