Exemplo n.º 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>")
Exemplo n.º 2
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 = "&nbsp;"
        colladaKeyword = test.GetCOLLADAKeyword()
        if len(colladaKeyword) == 0: colladaKeyword = "&nbsp;"
        colladaSubject = test.GetCOLLADASubject()
        if len(colladaSubject) == 0: colladaSubject = "&nbsp;"
        
        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")
Exemplo n.º 3
0
 def __GetOutputTag(self, exportedDir, test, step, 
             exportedBlessed, showBlessed, showPrevious, width, height):
     errorCount = test.GetCurrentErrorCount(step)
     warningCount = test.GetCurrentWarningCount(step)
     
     if (errorCount != None):
         self.__errorCount = self.__errorCount + errorCount
     if (warningCount != None):
         self.__warningCount = self.__warningCount + warningCount
     
     # None (not ran) is considered < 0 in python
     if (errorCount > 0):
         tag = "            <td bgcolor=\"#FF0000\">\n"
     elif (warningCount > 0):
         tag = "            <td bgcolor=\"#FFFF00\">\n"
     else:
         tag = "            <td bgcolor=\"#FFFFFF\">\n"
     
     outputList = test.GetCurrentOutputLocation(step)
     if ((outputList == None) or (len(outputList) == 0)):
         tag = tag + "                &nbsp;\n"
     elif (not type(outputList) is types.ListType): # validation
         name = os.path.basename(outputList)
         exportedFilename = os.path.join(exportedDir, str(step) + "_" + 
                 name)
         
         if (os.path.isfile(outputList)):
             shutil.copy2(outputList, exportedFilename)
             if (errorCount > 0):
                 status = "Failed"
             else:
                 status = "Passed"
             tag = (tag + "                <a href=\"" + 
                     FUtils.GetHtmlRelativePath(exportedFilename, 
                             self.__mainDir) + 
                     "\"> " + status + "<br>" + 
                     str(warningCount) + "&nbsp;Warnings<br>" + 
                     str(errorCount) + "&nbsp;Errors</a>\n")
         else:
             tag = tag + "                Missing&nbsp;File\n"
     else:
         if (showPrevious):
             exportedPrevious = self.__ExportImageList(exportedDir,
                     test.GetPreviousOutputLocation(step), str(step) + "p_")
         else:
             exportedPrevious = None
         
         exportedFilename = self.__ExportImageList(exportedDir, outputList,
                 str(step) + "_")
         if (exportedFilename == None):
             tag = tag + "                Missing&nbsp;File<br>\n"
         else:
             tag = (tag + self.__GetImageTag(exportedBlessed, 
                     exportedPrevious, exportedFilename, "                ",
                     width, height, showBlessed, showPrevious) + "<br>\n")
     
     logName = test.GetCurrentLog(step)
     if (logName != None):  # equals None if not ran
         name = os.path.basename(logName)
         exportedLog = os.path.join(exportedDir, str(step) + "_" + name)
         if (os.path.isfile(logName)):
             shutil.copy2(logName, exportedLog)
             tag = (tag + "                <a href=\"" + 
                     FUtils.GetHtmlRelativePath(exportedLog, 
                             self.__mainDir) + 
                     "\"> " + str(warningCount) + "&nbsp;Warnings<br>" + 
                     str(errorCount) + "&nbsp;Errors</a>\n")
         else:
             tag = tag + "                Missing&nbsp;Log&nbsp;File\n"
     
     tag = tag + "            </td>\n"
     return tag