示例#1
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)
示例#2
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)]
示例#3
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()
        
        """
        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),
        ]
示例#4
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"),]
示例#5
0
 def GetValidFileAndDirs(self, path):
     basePath = os.path.basename(path)
     dirs = []
     files = []
     for entry in os.listdir(path):
         fullPath = os.path.join(path, entry)
         if (os.path.isdir(fullPath) and (entry[0] != ".")):
             dirs.append(fullPath)
         elif (os.path.isfile(fullPath) and 
                 (FUtils.GetProperFilename(entry) == basePath)):
             files.append(fullPath)
     
     if (len(files) > 0):
         file = files[0] # there should only be 1 file with same proper name
     else:
         file = None
     
     dirs.sort()
     
     return (file, dirs)
示例#6
0
    def WriteImport(self, filename, logname, outputDir, settings, isAnimated,
                    cameraRig, lightingRig):
        """WriteRender(logname, outputDir, settings, isAnimated, cameraRig, lightingRig) -> list_of_str
        
        Implements FApplication.WriteImport().
        
        """
        self.__testCount = self.__testCount + 1
        name_only = FUtils.GetProperFilename(filename)
        self.__currentImportProperName = name_only
        output = (os.path.join(outputDir, name_only)) + self.__EXTENSION

        self.__script.write("if ctsImportFile(r\"" + filename + "\",\"" +
                            name_only + "\",r\"" + logname + "\",r\"" +
                            output + "\"):\n" + "    print \"" + name_only +
                            "\",\"loaded.\"\n")

        return [
            output,
        ]
示例#7
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"

        extension = os.path.basename(filename).rsplit(".", 1)[1]

        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 \"OpenCOLLADA importer\" -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"),
        ]
示例#8
0
    def __OnLeftDown(self, e):
        """Test to see if clicked on a checkbox.
        
        arguments:
            e -- The Event that was generated from the mouse click.
        
        """
        item, where = e.GetEventObject().HitTest(e.GetPosition())

        if (where & wx.TREE_HITTEST_ONITEMICON):
            if (self.__mode == FSelectDataSetDialog.__TREE):
                self.__Check(e.GetEventObject(), item)
        elif (where & wx.TREE_HITTEST_ONITEMLABEL):
            directory, checked = self.__treeCtrl.GetItemPyData(item)
            if (directory != FSelectDataSetDialog.__FILE): return

            path = self.__treeCtrl.GetItemText(item)[1:-1]
            dataSetDirectory = FUtils.GetProperFilename(path)
            path = os.path.join(dataSetDirectory, path)
            parent = self.__treeCtrl.GetItemParent(item)
            while (parent != self.__treeCtrl.GetRootItem()):
                path = os.path.join(self.__treeCtrl.GetItemText(parent), path)
                parent = self.__treeCtrl.GetItemParent(parent)
            path = os.path.join(MAIN_FOLDER, path)

            comments = ""

            if (os.path.isfile(path)
                    and FCOLLADAParser.IsCOLLADADocument(path)):
                (title, subject,
                 keyword) = FCOLLADAParser.GetCOLLADAAssetInformation(path)
                comments = "[%s] Keywords: %s\nDescription: %s" % (
                    title, keyword, subject)

            self.__commentsCtrl.SetValue(comments)

        e.Skip()
示例#9
0
    def __init__(self):
        FSerializer.__init__(self)

        # Read in and parse the configuration file.
        configDict = {}
        if (os.path.isfile(CONFIGURATION_FILE)):
            f = open(CONFIGURATION_FILE)
            line = f.readline()
            while (line):
                while (line.count("\t\t") > 0):
                    line = line.replace("\t\t", "\t")
                key, value = line.split("\t", 1)
                if (configDict.has_key(key)):
                    print("Warning: Ignoring redefinition of configuration " +
                          "key: " + key + ".")
                    continue
                configDict[key] = value.strip()  # remove \n
                line = f.readline()
            f.close

        # Further parse the badge levels configuration.
        FGlobals.badgeLevels = []
        if configDict.has_key("badgeLevels"):
            wantedBadgeList = configDict["badgeLevels"].split(",")
            for badge in wantedBadgeList:
                # Strip extra whitespaces and enforce title-case.
                level = badge.strip().title()
                if (len(level) > 0):
                    FGlobals.badgeLevels.append(level)

        # Further parse the adopter package status
        FGlobals.adoptersPackage = False
        if configDict.has_key("adoptersPackage"):
            FGlobals.adoptersPackage = configDict["adoptersPackage"]
            print "IsAdopters %s" % (FGlobals.adoptersPackage)

        # import the application specific scripts
        self.applicationMap = {}
        if (os.path.isdir(SCRIPTS_DIR)):
            for entry in os.listdir(SCRIPTS_DIR):
                filename = os.path.normpath(os.path.join(SCRIPTS_DIR, entry))
                if ((not os.path.isfile(filename))
                        or (FUtils.GetExtension(filename) != "py")
                        or (entry == "__init__.py")
                        or (entry == ABSTRACT_APPLICATION)):
                    continue

                properName = FUtils.GetProperFilename(entry)
                exec("from Scripts." + properName + " import *")
                exec("application = " + properName + "(configDict)")
                prettyName = application.GetPrettyName()

                if (self.applicationMap.has_key(prettyName)):
                    print("Warning: Ignoring redefinition of application \"" +
                          prettyName + "\" from \"" + entry + "\"")
                    continue

                self.applicationMap[prettyName] = application

        # import the image comparator
        comparatorFile = os.path.abspath(
            os.path.normpath(
                os.path.join(IMAGE_COMPARATORS_DIR,
                             configDict[IMAGE_COMPARATORS_LABEL] + ".py")))
        if (os.path.isfile(comparatorFile)):
            comparatorName = configDict[IMAGE_COMPARATORS_LABEL]
        else:
            print comparatorFile + " not found. Defaulting to byte comparator."
            comparatorName = "FByteComparator"  # default comparator

        exec("from ImageComparators." + comparatorName + " import *")
        exec("FGlobals.imageComparator = " + comparatorName + "(configDict)")

        self.configDict = configDict
示例#10
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()
     
     """
     outputFormat = ".png"
     
     command = ("\"" + self.configDict["feelingViewerCLI"] + "\" ")
     for setting in settings:
         prettyName = setting.GetPrettyName()
         if (prettyName == FViewer.__IMPORT_ANIMATION_START):
             if (not isAnimated):
                 continue
             start = self.GetSettingValueAs(FViewer.__IMPORT_OPTIONS, 
                                            setting, float)
         elif (prettyName == FViewer.__IMPORT_ANIMATION_END):
             if (not isAnimated):
                 continue
             end = self.GetSettingValueAs(FViewer.__IMPORT_OPTIONS, 
                                          setting, float)
         elif (prettyName == FViewer.__IMPORT_ANIMATION_FRAMES):
             if (not isAnimated):
                 continue
             frameCount = self.GetSettingValueAs(FViewer.__IMPORT_OPTIONS,
                                                 setting, int)
         elif (prettyName == FViewer.__IMPORT_STILL_START):
             if (isAnimated):
                 continue
             start = self.GetSettingValueAs(FViewer.__IMPORT_OPTIONS, 
                                            setting, float)
         elif (prettyName == FViewer.__IMPORT_STILL_END):
             if (isAnimated):
                 continue
             end = self.GetSettingValueAs(FViewer.__IMPORT_OPTIONS, 
                                          setting, float)
         elif (prettyName == FViewer.__IMPORT_STILL_FRAMES):
             if (isAnimated):
                 continue
             frameCount = self.GetSettingValueAs(FViewer.__IMPORT_OPTIONS,
                                                 setting, int)
         elif (prettyName == FViewer.__IMPORT_OUTPUT_FORMAT):
             value = setting.GetValue().strip()
             if (value == ""):
                 value = self.FindDefault(FViewer.__IMPORT_OPTIONS, 
                                          FViewer.__IMPORT_OUTPUT_FORMAT)
             outputFormat = "." + value
             continue
         elif (prettyName == FViewer.__IMPORT_CAMERA):
             value = setting.GetValue().strip()
             # use default camera
             if (value == ""): continue
         
         value = setting.GetValue().strip()
         if (value == ""):
             value = self.FindDefault(FViewer.__IMPORT_OPTIONS, 
                                      setting.GetPrettyName())
         
         command = (command + setting.GetCommand() + " " + 
                    value + " ")
     
     baseName = FUtils.GetProperFilename(filename) + outputFormat
     outputFilename = os.path.join(outputDir, baseName)
     
     command = (command + "\"" + filename + 
                "\" \"" + outputFilename + "\"")
     
     self.WriteCrashDetect(self.__script, command, logname)
     
     self.__testCount = self.__testCount + 1
     
     if (frameCount == 1):
         return [os.path.normpath(baseName),]
     
     outputList = []
     numDigit = len(str(frameCount))
     for i in range(0,frameCount):
         outputTemp = FUtils.GetProperFilename(filename)
         paddingCount = numDigit - len(str(i))
         for j in range(0, paddingCount):
             outputTemp = outputTemp + "0"
         outputTemp = outputTemp + str(i) + outputFormat
         outputList.append(os.path.normpath(outputTemp))
     
     return outputList
示例#11
0
    def __AddTest(self, file, checksumFile, testProcedure, test, 
                  showBlessed, showPrevious, width, height):
                      
        # Retrieve the COLLADA asset information and write it out.
        colladaId = test.GetCOLLADAId()
        if len(colladaId) == 0: colladaId = " "
        colladaKeyword = test.GetCOLLADAKeyword()
        if len(colladaKeyword) == 0: colladaKeyword = " "
        colladaSubject = test.GetCOLLADASubject()
        if len(colladaSubject) == 0: colladaSubject = " "
        
        file.write(
                "        <tr>\n" +
                "            <td>\n" +
                "                " + colladaId + "\n" +
                "            </td>\n" +
                "            <td>\n" +
                "                " + colladaKeyword + "\n" +
                "            </td>\n" +
                "            <td>\n" +
                "                " + colladaSubject + "\n" +
                "            </td>\n")
        
        exportedDir = os.path.join(self.__filesDir, "Test" + str(test.GetTestId()),
            FUtils.GetProperFilename(test.GetBaseFilename()))
        exportedDir = self.__GetAvailableDir(exportedDir)
        os.makedirs(exportedDir)
        
        origTag = "            <td>\n"
        origFile = test.GetAbsFilename()
        exportedOrig = self.__ExportImageList(exportedDir, [origFile], "orig_")
        if ((exportedOrig == None) or (exportedOrig[0] == None)):
            origTag = (origTag + 
                    "                " + test.GetSeparatedFilename() + "\n")
        else:
            origTag = (origTag + 
                    "                <a href=\"" + 
                    FUtils.GetHtmlRelativePath(exportedOrig[0], self.__mainDir)
                     + "\">" + test.GetBaseFilename() + "</a>\n")
        origTag = origTag + "            </td>\n"
        file.write(origTag)
        
        blessedTag = "            <td>\n"
        exportedBlessed = self.__ExportImageList(exportedDir, 
                test.GetBlessed(), "blessed_")
        
        if (exportedBlessed == None):
            blessedTag = blessedTag + "                &nbsp;\n"
        else:
            blessedTag = ((blessedTag + self.__GetImageTag(None, None, 
                           exportedBlessed, "                ", width, 
                           height)) + "\n")
        
        blessedTag = blessedTag + "            </td>\n"
        file.write(blessedTag)
        
        for step, app, op, settings in testProcedure.GetStepGenerator():
            if (not showBlessed):
                exportedBlessed = None
            
            file.write(self.__GetOutputTag(exportedDir, test, step,
                    exportedBlessed, showBlessed, showPrevious, width, height))
        
        # Write out the local results.
        result = test.GetCurrentResult()
        if (result == None):
            resultTag = "            <td>\n"
            resultTag = resultTag + "                &nbsp;\n"
        else:
            if (result.GetResult()):
                self.__passedTestsCount = self.__passedTestsCount + 1
                resultTag = "            <td bgcolor=\"#00FF00\">\n"
            else:
                self.__failedTestsCount = self.__failedTestsCount + 1
                resultTag = "            <td bgcolor=\"#FF0000\">\n"
            
            for entry in result.GetTextArray():
                resultTag = (resultTag + "                &nbsp;" + entry + 
                             "<br>\n")
        file.write(resultTag + "            </td>\n")

        # Write out the judging results
        execution = test.GetCurrentExecution()
        for i in range(len(FGlobals.badgeLevels)):
            if (execution == None):
                file.write("            <td>NO EXECUTION</td>")
            else:
                badgeLevel = FGlobals.badgeLevels[i]
                badgeResult = execution.GetJudgementResult(badgeLevel)
                self.__judgementCompiler.ProcessJudgement(i, badgeResult)
                if (badgeResult == FJudgement.PASSED):
                    file.write("            <td>PASSED</td>")
                elif (badgeResult == FJudgement.FAILED):
                    file.write("            <td>FAILED</td>")
                elif (badgeResult == FJudgement.MISSING_DATA):
                    file.write("            <td>MISSING DATA</td>")
                elif (badgeResult == FJudgement.NO_SCRIPT):
                    file.write("            <td>NO SCRIPT</td>")
        
        # Write out the environment information
        if (test.GetCurrentTimeRan() == None):
            timeString = "&nbsp;"
        else:
            timeString = time.asctime(test.GetCurrentTimeRan())
        
        if (test.GetCurrentDiffFromPrevious() == ""):
            diff = "&nbsp;"
        else:
            diff = str(test.GetCurrentDiffFromPrevious())
        
        environmentDict = test.GetCurrentEnvironment()
        environment = ""
        for key in environmentDict.keys():
            environment = environment + key + environmentDict[key] + "<br><br>"
        if (environment == ""):
            environment = "&nbsp;"
        
        comments = test.GetCurrentComments()
        if (comments == ""):
            comments = "&nbsp;"
        
        file.write(
                "            <td>\n" +
                "                " + diff + "\n" +
                "            </td>\n" +
                "            <td>\n" +
                "                " + timeString + "\n" +
                "            </td>\n" +
                "            <td>\n" +
                "                " + environment + "\n" +
                "            </td>\n" +
                "            <td>\n" +
                "                " + comments + "\n" +
                "            </td>\n" +
                "        </tr>\n")
                
        # Append checksum.
        if (execution != None):
            checksum = execution.GetChecksum()
            checksumFile.write(checksum + "\n")
示例#12
0
    def ToHtml(self, path, testProcedure, showBlessed, showPrevious, width,
               height, keys = None):
        file = open(path, "w")
        checksumFilename = FUtils.ChangeExtension(path, "sha")
        checksumFile = open(checksumFilename, "w")
        checksumFile.write(FUtils.CalculateSuiteChecksum())
        
        file.write(
                "<html>\n" +
                "<head>\n" + 
                "    <title>" + testProcedure.GetName() + "</title>\n" +
                "</head>\n" +
                "<body>\n" +
                "    <h1><center>" + testProcedure.GetName() + 
                        "</center></h1>\n" +
                "    <b><u>Statistics:</b></u>" +
                "    <table>\n" +
                "        <tr>\n" +
                "            <td># of tests in test procedure:</td>\n" +
                "            <td>" + 
                        FHtmlExporter.__REPLACE_TEST_PROCEDURE_COUNT + 
                        "</td>\n" +
                "        </tr>\n" +
                "        <tr>\n" +
                "            <td># of tests in HTML:</td>\n" +
                "            <td>" + FHtmlExporter.__REPLACE_HTML_COUNT + 
                        "</td>\n" +
                "        </tr>\n" +
                "        <tr>\n" +
                "            <td># of tests passed in HTML:</td>\n" +
                "            <td>" + FHtmlExporter.__REPLACE_PASSED_COUNT + 
                        "</td>\n" +
                "        </tr>\n" +
                "        <tr>\n" +
                "            <td># of tests failed in HTML:</td>\n" +
                "            <td>" + FHtmlExporter.__REPLACE_FAILED_COUNT + 
                        "</td>\n" +
                "        </tr>\n" +
                "            <td># of tests warning in HTML:</td>\n" +
                "            <td>" + FHtmlExporter.__REPLACE_WARNINGS_COUNT + 
                        "</td>\n" +
                "        </tr>\n" +
                "            <td># of tests errors in HTML:</td>\n" +
                "            <td>" + FHtmlExporter.__REPLACE_ERRORS_COUNT + 
                        "</td>\n" +
                "        </tr>\n" +
                "        </tr>\n" +
                "            <td>Badges earned:</td>\n" +
                "            <td>" + FHtmlExporter.__REPLACE_BADGES_EARNED + 
                        "</td>\n" +
                "        </tr>\n" +                "    </table>\n" +
                "    <br><br>\n" +
                # TODO:take with respect to how user positions the columns
                "    <center><table border=\"1\" cellspacing=\"0\" " +
                        "cellpadding=\"5\" bordercolor=\"gray\">\n" +
                "        <tr>\n" +
                "            <th>\n" +
                "                Test Id\n" +
                "            </th>\n" +
                "            <th>\n" +
                "                Categories\n" +
                "            </th>\n" +
                "            <th>\n" +
                "                Description\n" +
                "            </th>\n" +
                "            <th>\n" +
                "                Test Filename\n" +
                "            </th>\n" +
                "            <th>\n" +
                "                Blessed\n" +
                "            </th>\n")
        
        
        for step, app, op, settings in testProcedure.GetStepGenerator():
            if (op == VALIDATE and op not in OPS_NEEDING_APP):
                file.write(
                    "            <th>\n" +
                    "                <" + str(step) + "> " + op + "\n" +
                    "            </th>\n")
            else:
                file.write(
                    "            <th>\n" +
                    "                <" + str(step) + "> " + op + "(" + app + 
                            ")\n" +
                    "            </th>\n")
                    
        file.write(
                "            <th><div style=\"width: 300\">\n" +
                "                Result\n" +
                "            </div></th>\n");
                
        for i in range(len(FGlobals.badgeLevels)):
            file.write(
                "            <th>" + FGlobals.badgeLevels[i] + "</td>")
        
        file.write(
                "            <th>\n" +
                "                Different From Previous\n" +
                "            </th>\n" +
                "            <th><div style=\"width: 100\">\n" +
                "                Time\n" +
                "            </div></th>\n" +
                "            <th>\n" +
                "                Environment\n" +
                "            </th>\n" +
                "            <th>\n" +
                "                Comments\n" +
                "            </th>\n" +
                "        </tr>\n")
        
        self.__filesDir = FUtils.GetProperFilename(path) + HTML_POSTFIX
        self.__filesDir = os.path.join(os.path.dirname(path), self.__filesDir)
        self.__filesDir = self.__GetAvailableDir(self.__filesDir)
        
        os.mkdir(self.__filesDir)
        
        self.__mainDir = os.path.dirname(path)
        self.__passedTestsCount = 0
        self.__failedTestsCount = 0
        self.__warningCount = 0
        self.__errorCount = 0

        # Prepare the badges earned results.
        testCount = 0
        if (keys == None):
            for test in testProcedure.GetTestGenerator():
                self.__AddTest(file, checksumFile, testProcedure, test, showBlessed, 
                              showPrevious, width, height)
                testCount = testCount + 1
        else:
            for key in keys:
                self.__AddTest(file, checksumFile, testProcedure, testProcedure.GetTest(key), 
                               showBlessed, showPrevious, width, height)
                testCount = testCount + 1
        
        file.write(
                "    </table></center>\n" +
                "</body>\n" +
                "</html>\n")
        file.close()
        checksumFile.close()
        
        # Replace the statement tokens by their real values.
        badgesEarnedStatement = self.__judgementCompiler.GenerateStatement()
        if (len(badgesEarnedStatement) == 0): badgesEarnedStatement = "None"
        replaceDict = {
                FHtmlExporter.__REPLACE_TEST_PROCEDURE_COUNT : str(testProcedure.GetTestCount()),
                FHtmlExporter.__REPLACE_HTML_COUNT : str(testCount),
                FHtmlExporter.__REPLACE_PASSED_COUNT : str(self.__passedTestsCount),
                FHtmlExporter.__REPLACE_FAILED_COUNT : str(self.__failedTestsCount),
                FHtmlExporter.__REPLACE_WARNINGS_COUNT : str(self.__warningCount),
                FHtmlExporter.__REPLACE_ERRORS_COUNT : str(self.__errorCount),
                FHtmlExporter.__REPLACE_BADGES_EARNED : badgesEarnedStatement }
        
        tempFilename = FUtils.GetAvailableFilename(path + ".temp")
        f = open(tempFilename, "w")
        htmlFile = open(path)
        line = htmlFile.readline()
        while (line):
            for key in replaceDict.keys():
                if (line.count(key) != 0):
                    line = line.replace(key, replaceDict[key], 1)
                    replaceDict.pop(key)
                    break
            f.write(line)
            line = htmlFile.readline()
        htmlFile.close()
        f.close()
        
        shutil.copy2(tempFilename, path)
        os.remove(tempFilename)
示例#13
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()
        
        """
        step = os.path.basename(outputDir)
        execution = os.path.basename(os.path.dirname(outputDir))
        test = os.path.basename(os.path.dirname(os.path.dirname(outputDir)))
        path = os.path.join(self.__scenesDir, test, execution, step)
        if (not os.path.isdir(path)):
            os.makedirs(path)
        self.__pathMap.append((path, outputDir))

        self.__logFiles.append(os.path.join(path, os.path.basename(logname)))
        self.__importLogFiles.append(self.__logFiles[-1])

        command = ("SetValue \"preferences.scripting.cmdlogfilename\", \"" +
                   self.__logFiles[-1].replace("\\", "\\\\") + "\"\n"
                   "NewScene, false\n")
        if (FUtils.GetExtension(filename) == "dae"):
            command = (command + "set myIProp = CreateImportFTKOptions()\n" +
                       "myIProp.Parameters(\"Filename\").Value = \"" +
                       filename.replace("\\", "\\\\") + "\"\n" +
                       "myIProp.Parameters(\"Verbose\").Value = True\n")
            for setting in settings:
                value = setting.GetValue().strip()
                if (value == ""):
                    value = self.FindDefault(FXsi.__IMPORT_OPTIONS,
                                             setting.GetPrettyName())
                command = (command + "myIProp.Parameters(\"" +
                           setting.GetCommand() + "\").Value = " + value +
                           "\n")
            command = command + "ImportFTK myIProp.Name \n"
        elif (FUtils.GetExtension(filename) == "scn"):
            command = (command + "OpenScene \"" +
                       filename.replace("\\", "\\\\") + "\"\n")
        else:
            return

        self.__currentImportProperName = FUtils.GetProperFilename(filename)
        basename = self.__currentImportProperName + ".scn"

        #        self.__script.write(
        #                command +
        #                "SearchAndReplacePath \"All\", \"" + FXsi.__REPLACE_PATH +
        #                        "\", \"" +
        #                        os.path.dirname(filename).replace("\\", "\\\\") +
        #                        "\", True\n" +
        #                "SaveSceneAs \"" +
        #                        os.path.join(path, basename).replace("\\", "\\\\") +
        #                        "\"\n"
        #                )

        self.__script.write(
            command + "SaveSceneAs \"" +
            os.path.join(path, basename).replace("\\", "\\\\") + "\"\n")

        self.__testCount = self.__testCount + 1

        return [
            basename,
        ]
示例#14
0
    def ToCsv(self,
              path,
              testProcedure,
              showBlessed,
              showPrevious,
              width,
              height,
              keys=None):
        file = open(path, "w")
        checksumFile = open(FUtils.ChangeExtension(path, "sha"), "w")
        checksumFile.write(FUtils.CalculateSuiteChecksum())

        file.write("\nTest Procedure:,%s\n\n" % (testProcedure.GetName()))
        file.write("Statistics: \n" + "# of tests in test procedure:," +
                   FCsvExporter.__REPLACE_TEST_PROCEDURE_COUNT + "\n" +
                   "# of tests:," + FCsvExporter.__REPLACE_HTML_COUNT + "\n" +
                   "# of tests passed:," +
                   FCsvExporter.__REPLACE_PASSED_COUNT + "\n" +
                   "# of tests failed:," +
                   FCsvExporter.__REPLACE_FAILED_COUNT + "\n" +
                   "# of tests warning:," +
                   FCsvExporter.__REPLACE_WARNINGS_COUNT + "\n" +
                   "# of tests errors:," +
                   FCsvExporter.__REPLACE_ERRORS_COUNT + "\n" +
                   "Badges earned:," + FCsvExporter.__REPLACE_BADGES_EARNED +
                   "\n\n")
        file.write("Test Id,Categories,Description,Test Filename,Blessed,")
        for step, app, op, settings in testProcedure.GetStepGenerator():
            if (op == VALIDATE and op not in OPS_NEEDING_APP):
                file.write("<" + str(step) + ">" + " " + op + ",")
            else:
                file.write("<" + str(step) + ">" + " " + op + " (" + app +
                           "),")
        file.write("Results,")
        for i in range(len(FGlobals.badgeLevels)):
            file.write(FGlobals.badgeLevels[i] + ",")
        file.write("Different From Previous,Time,Environment,Comments\n")

        self.__filesDir = FUtils.GetProperFilename(path) + CSV_POSTFIX
        self.__filesDir = os.path.join(os.path.dirname(path), self.__filesDir)
        self.__filesDir = self.__GetAvailableDir(self.__filesDir)

        #   os.mkdir(self.__filesDir)

        self.__mainDir = os.path.dirname(path)
        self.__passedTestsCount = 0
        self.__failedTestsCount = 0
        self.__warningCount = 0
        self.__errorCount = 0

        testCount = 0
        if (keys == None):
            for test in testProcedure.GetTestGenerator():
                self.__AddTest(file, checksumFile, testProcedure, test,
                               showBlessed, showPrevious, width, height)
                testCount = testCount + 1
        else:
            for key in keys:
                self.__AddTest(file, checksumFile, testProcedure,
                               testProcedure.GetTest(key), showBlessed,
                               showPrevious, width, height)
                testCount = testCount + 1

        file.close()

        # Replace the statement tokens by their real values.
        badgesEarnedStatement = self.__judgementCompiler.GenerateStatement()
        if (len(badgesEarnedStatement) == 0): badgesEarnedStatement = "None"
        replaceDict = {
            FCsvExporter.__REPLACE_TEST_PROCEDURE_COUNT:
            str(testProcedure.GetTestCount()),
            FCsvExporter.__REPLACE_HTML_COUNT:
            str(testCount),
            FCsvExporter.__REPLACE_PASSED_COUNT:
            str(self.__passedTestsCount),
            FCsvExporter.__REPLACE_FAILED_COUNT:
            str(self.__failedTestsCount),
            FCsvExporter.__REPLACE_WARNINGS_COUNT:
            str(self.__warningCount),
            FCsvExporter.__REPLACE_ERRORS_COUNT:
            str(self.__errorCount),
            FCsvExporter.__REPLACE_BADGES_EARNED:
            badgesEarnedStatement
        }

        tempFilename = FUtils.GetAvailableFilename(path + ".temp")
        f = open(tempFilename, "w")
        csvFile = open(path)
        line = csvFile.readline()
        while (line):
            for key in replaceDict.keys():
                if (line.count(key) != 0):
                    line = line.replace(key, replaceDict[key], 1)
                    replaceDict.pop(key)
                    break
            f.write(line)
            line = csvFile.readline()
        csvFile.close()
        f.close()

        shutil.copy2(tempFilename, path)
        os.remove(tempFilename)
示例#15
0
    def __AddTest(self, file, checksumFile, testProcedure, test, showBlessed,
                  showPrevious, width, height):

        print "ID: %s" % (test.GetCOLLADAId())
        file.write(test.GetCOLLADAId() + ",")
        file.write(test.GetCOLLADAKeyword() + ",")
        file.write(test.GetCOLLADASubject() + ",")
        file.write(test.GetSeparatedFilename() + ",")

        execution = test.GetCurrentExecution()
        exportedDir = os.path.join(
            self.__filesDir, "Test" + str(test.GetTestId()),
            FUtils.GetProperFilename(test.GetBaseFilename()))
        exportedDir = self.__GetAvailableDir(exportedDir)

        exportedBlessed = self.__ExportImageList(exportedDir,
                                                 test.GetBlessed(), "blessed_")

        file.write(",")

        for step, app, op, settings in testProcedure.GetStepGenerator():
            if (not showBlessed):
                exportedBlessed = None

            file.write(
                self.__GetOutputTag(exportedDir, test, step, exportedBlessed,
                                    showBlessed, showPrevious, width, height) +
                ",")

    # Write out the local results
        result = test.GetCurrentResult()
        if (result == None):
            resultTag = ""
        else:
            if (result.GetResult()):
                self.__passedTestsCount = self.__passedTestsCount + 1
                resultTag = ""
            else:
                self.__failedTestsCount = self.__failedTestsCount + 1
                resultTag = ""

            for entry in result.GetTextArray():
                resultTag = resultTag + " " + entry + " "
        file.write(resultTag + ",")

        # Write out the judging results
        for i in range(len(FGlobals.badgeLevels)):
            if (execution == None):
                file.write("NO EXECUTION,")
            else:
                badgeLevel = FGlobals.badgeLevels[i]
                badgeResult = execution.GetJudgementResult(badgeLevel)
                self.__judgementCompiler.ProcessJudgement(i, badgeResult)
                if (badgeResult == FJudgement.PASSED):
                    file.write("PASSED,")
                elif (badgeResult == FJudgement.FAILED):
                    file.write("FAILED,")
                elif (badgeResult == FJudgement.MISSING_DATA):
                    file.write("MISSING DATA,")
                elif (badgeResult == FJudgement.NO_SCRIPT):
                    file.write("NO SCRIPT,")

        if (test.GetCurrentTimeRan() == None):
            timeString = ""
        else:
            timeString = time.asctime(test.GetCurrentTimeRan())

        if (test.GetCurrentDiffFromPrevious() == ""):
            diff = ""
        else:
            diff = str(test.GetCurrentDiffFromPrevious())

        environmentDict = test.GetCurrentEnvironment()
        environment = ""
        for key in environmentDict.keys():
            environment = environment + key + environmentDict[key] + " "
        if (environment == ""):
            environment = ""

        comments = test.GetCurrentComments()
        if (comments == ""):
            comments = ""

        file.write(diff + "," + timeString + "," + environment + "," +
                   comments)
        file.write("\n")

        # Append checksum.
        if (execution != None):
            checksum = execution.GetChecksum()
            checksumFile.write(checksum + "\n")