Beispiel #1
0
 def generateGraph(self, fileName, graphTitle, results, colourFinder):
     plugins.log.info("Generating graph at " + fileName + " ...")
     graph = Graph(graphTitle, width=24, height=20)
     self.addAllPlots(graph, results, colourFinder)
     self.addDateLabels(graph, results)
     plugins.ensureDirExistsForFile(fileName)
     graph.save(fileName)
Beispiel #2
0
 def archiveFile(self, fullPath, app):
     targetPath = self.getTargetPath(fullPath, app.name)
     plugins.ensureDirExistsForFile(targetPath)
     try:
         os.rename(fullPath, targetPath)
     except:
         plugins.log.info("Rename failed: " + fullPath + " " + targetPath)
Beispiel #3
0
 def archiveFile(self, fullPath, app):
     targetPath = self.getTargetPath(fullPath, app.name)
     plugins.ensureDirExistsForFile(targetPath)
     try:
         os.rename(fullPath, targetPath)
     except EnvironmentError, e:
         plugins.log.info("Rename failed: " + fullPath + " " + targetPath)
         plugins.log.info("Error was " + str(e))
Beispiel #4
0
 def saveToRepository(self, test):
     testRepository = self.repositories[test.app]
     targetFile = os.path.join(testRepository, test.app.name, getVersionName(test.app, self.allApps), \
                               test.getRelPath(), self.fileName)
     if os.path.isfile(targetFile):
         plugins.printWarning("File already exists at " + targetFile + " - not overwriting!")
     else:
         try:
             plugins.ensureDirExistsForFile(targetFile)
             shutil.copyfile(test.getStateFile(), targetFile)
         except IOError:
             plugins.printWarning("Could not write file at " + targetFile)
 def saveFileEdits(self, test, versionString):
     tmpFileEditDir = test.makeTmpFileName("file_edits", forComparison=0)
     fileEditDir = test.dircache.pathName("file_edits")
     if versionString:
         fileEditDir += "." + versionString
     if os.path.isdir(tmpFileEditDir):
         for root, _, files in os.walk(tmpFileEditDir):
             for file in sorted(files):
                 fullPath = os.path.join(root, file)
                 savePath = fullPath.replace(tmpFileEditDir, fileEditDir)
                 self.updateStatus(test, "edited file " + file, versionString)
                 plugins.ensureDirExistsForFile(savePath)
                 shutil.copyfile(fullPath, savePath)
Beispiel #6
0
 def intercept(self, interceptDir, cmd, trafficFiles, executable):
     interceptName = os.path.join(interceptDir, cmd)
     plugins.ensureDirExistsForFile(interceptName)
     for trafficFile in trafficFiles:
         if os.name == "posix":
             os.symlink(trafficFile, interceptName)
         elif executable:
             # Windows PATH interception isn't straightforward. Only .exe files get found.
             # Put them directly into the sandbox directory rather than the purpose-built directory:
             # that way they can also intercept stuff that is otherwise picked up directly from the registry (like Java)
             interceptName = os.path.join(os.path.dirname(interceptDir), cmd)
             extension = os.path.splitext(trafficFile)[-1]
             shutil.copy(trafficFile, interceptName + extension)
         else:
             shutil.copy(trafficFile, interceptName)
 def saveTmpFile(self, test, exact=True):
     self.diag.info("Saving tmp file to " + self.stdFile)
     plugins.ensureDirExistsForFile(self.stdFile)
     # Allow for subclasses to differentiate between a literal overwrite and a
     # more intelligent save, e.g. for performance. Default is the same for exact
     # and inexact save
     tmpFile = self.getTmpFileForSave(test)
     if os.path.isfile(tmpFile):
         if exact:
             copyfile(tmpFile, self.stdFile)
         else:
             self.saveResults(tmpFile, self.stdFile)
     else:
         raise plugins.TextTestError, "The following file seems to have been removed since it was created:\n" + repr(tmpFile) 
     self.differenceCache = self.SAVED
Beispiel #8
0
    def copyTestContents(self, test, newDir):
        stdFiles, defFiles = test.listStandardFiles(allVersions=True)
        for sourceFile in stdFiles + defFiles:
            dirname, local = os.path.split(sourceFile)
            if dirname == test.getDirectory():
                targetFile = os.path.join(newDir, local)
                shutil.copy2(sourceFile, targetFile)

        extFiles = test.listExternallyEditedFiles()[1]
        dataFiles = test.listDataFiles() + extFiles
        for sourcePath in dataFiles:
            if os.path.isdir(sourcePath):
                continue
            targetPath = sourcePath.replace(test.getDirectory(), newDir)
            plugins.ensureDirExistsForFile(targetPath)
            shutil.copy2(sourcePath, targetPath)
Beispiel #9
0
    def collatePath(self, test, configName, collateMethod, remoteCopy, mergeDirectories=False):
        targetPath = self.getTargetPath(test, configName)
        sourceFileName = self.getSourceFileName(configName, test)
        if not targetPath or not sourceFileName: # Can happen with e.g. empty environment
            return
        plugins.ensureDirExistsForFile(targetPath)
        for sourcePath in self.getSourcePaths(test, configName, sourceFileName):
            self.diag.info("Collating " + configName + " from " + repr(sourcePath) +
                           "\nto " + repr(targetPath))
            collateMethod(test, sourcePath, targetPath)
            if not mergeDirectories or not os.path.isdir(sourcePath):
                break

        if remoteCopy and targetPath:
            remoteCopy(targetPath)
            
        envVarToSet, propFileName = self.findDataEnvironment(test, configName)
        if envVarToSet and targetPath:
            self.diag.info("Setting env. variable " + envVarToSet + " to " + targetPath)
            test.setEnvironment(envVarToSet, targetPath, propFileName)
Beispiel #10
0
 def intercept(self, moduleFile, interceptDir):
     interceptName = os.path.join(interceptDir, os.path.basename(moduleFile))
     plugins.ensureDirExistsForFile(interceptName)
     self.copyOrLink(moduleFile, interceptName)