def makeTemporarySettingsDir(self, writeDir, app, fileType, contents):
     tmpDir = os.path.join(writeDir, "temporary_settings")
     plugins.ensureDirectoryExists(tmpDir)
     fileName = os.path.join(tmpDir, fileType + "." + app.name + app.versionSuffix())
     with open(fileName, "w") as f:
         f.write(contents)
     return tmpDir
 def makeAndGenerate(self, subDirs, getConfigValue, pageDir, *args):
     resourcePages = self.getResourcePages(getConfigValue)
     for resourcePage in resourcePages:
         plugins.ensureDirectoryExists(os.path.join(pageDir, resourcePage))
     try:
         self.generateWebPages(subDirs, getConfigValue, pageDir, resourcePages, *args)
     except Exception: # pragma: no cover - robustness only, shouldn't be reachable
         sys.stderr.write("Caught exception while generating web pages :\n")
         plugins.printException()
Exemple #3
0
 def getVirtualServerArgs(self, machine, app):
     binDir = plugins.installationDir("libexec")
     fullPath = os.path.join(binDir, "startXvfb.py")
     logDir = os.path.join(app.writeDirectory, "Xvfb") 
     plugins.ensureDirectoryExists(logDir)
     python = self.findPython(machine)
     xvfbExtraArgs = plugins.splitcmd(app.getConfigValue("virtual_display_extra_args"))
     cmdArgs = [ python, "-u", fullPath, logDir ] + xvfbExtraArgs
     return app.getCommandArgsOn(machine, cmdArgs)
Exemple #4
0
 def makeAndGenerate(self, subDirs, getConfigValue, pageDir, *args):
     resourcePages = self.getResourcePages(getConfigValue)
     for resourcePage in resourcePages:
         plugins.ensureDirectoryExists(os.path.join(pageDir, resourcePage))
     try:
         self.generateWebPages(subDirs, getConfigValue, pageDir, resourcePages, *args)
     except:
         sys.stderr.write("Caught exception while generating web pages :\n")
         plugins.printException()
 def startTextTestProcess(self, usecase, runModeOptions, testSelOverride=None, filterFileOverride=None):
     app = self.getCurrentApplication()
     writeDir = os.path.join(self.getLogRootDirectory(app), "dynamic_run" + str(self.runNumber))
     plugins.ensureDirectoryExists(writeDir)
     filterFile = self.createFilterFile(writeDir, filterFileOverride)
     ttOptions = runModeOptions + self.getTextTestOptions(filterFile, app, usecase)
     self.diag.info("Starting " + usecase + " run of TextTest with arguments " + repr(ttOptions))
     logFile = os.path.join(writeDir, "output.log")
     errFile = os.path.join(writeDir, "errors.log")
     BasicRunningAction.runNumber += 1
     description = "Dynamic GUI started at " + plugins.localtime()
     cmdArgs = self.getInterpreterArgs() + [ sys.argv[0] ] + ttOptions
     env = self.getNewUseCaseEnvironment(usecase)
     testsAffected = self.getTestsAffected(testSelOverride)
     guiplugins.processMonitor.startProcess(cmdArgs, description, env=env, killOnTermination=self.killOnTermination(),
                                            stdout=open(logFile, "w"), stderr=open(errFile, "w"),
                                            exitHandler=self.checkTestRun,
                                            exitHandlerArgs=(errFile,testsAffected,filterFile,usecase))
 def getVirtualServerArgs(self, machine, app):
     binDir = plugins.installationDir("libexec")
     fullPath = os.path.join(binDir, "startXvfb.py")
     appTmpDir = app.getRemoteTmpDirectory()[1]
     if appTmpDir:
         logDir = os.path.join(appTmpDir, "Xvfb")
         app.ensureRemoteDirExists(machine, logDir)
         remoteXvfb = os.path.join(appTmpDir, "startXvfb.py")
         app.copyFileRemotely(fullPath, "localhost", remoteXvfb, machine)
         fullPath = remoteXvfb
         pythonArgs = [ "python", "-u" ]
     else:
         logDir = os.path.join(app.writeDirectory, "Xvfb") 
         plugins.ensureDirectoryExists(logDir)
         pythonArgs = self.findPythonArgs(machine)
         
     xvfbExtraArgs = plugins.splitcmd(app.getConfigValue("virtual_display_extra_args"))
     cmdArgs = pythonArgs + [ fullPath, logDir ] + xvfbExtraArgs
     return app.getCommandArgsOn(machine, cmdArgs)
 def performOnCurrent(self):
     self.reloadConfigForSelected() # Always make sure we're up to date here
     test = self.currTestSelection[0]
     fileName = self.currFileSelection[0][0]
     text = self.getTextToShow(test, fileName)
     root = test.getEnvironment("TEXTTEST_SANDBOX_ROOT")
     plugins.ensureDirectoryExists(root)
     tmpFileNameLocal = os.path.basename(fileName) + " (FILTERED)"
     tmpFileName = os.path.join(root, tmpFileNameLocal)
     bakFileName = tmpFileName + ".bak"
     if os.path.isfile(bakFileName):
         os.remove(bakFileName)
     if os.path.isfile(tmpFileName):
         os.rename(tmpFileName, bakFileName)
     with open(tmpFileName, "w") as tmpFile:
         tmpFile.write(text)
         
     # Don't want people editing by mistake, remove write permissions
     os.chmod(tmpFileName, stat.S_IREAD)
     self.notify("ViewReadonlyFile", tmpFileName)
 def splitFile(self, test, filename, sepRegex):
     parts = []
     localPartsDir = os.path.basename(filename + "_split")
     partsDir = test.makeTmpFileName(localPartsDir, forFramework=1)
     plugins.ensureDirectoryExists(partsDir)
     initialFileName = os.path.join(partsDir, "initial")
     parts.append(initialFileName)
     currWriteFile = open(initialFileName, "w")
     splitFileNames = []
     with open(filename) as f:
         for line in f:
             match = sepRegex.search(line)
             if match:
                 currWriteFile.close()
                 newFileName = self.getSplitFileName(match, partsDir, splitFileNames)
                 parts.append(newFileName)
                 currWriteFile = open(newFileName, "w")
             currWriteFile.write(line)
     currWriteFile.close()
     return parts
 def findJenkinsChanges(self, prevTag, tag, cacheDir):
     buildNumber = self.getJenkinsBuildNumber(tag)
     cacheFileOldName = os.path.join(cacheDir, buildNumber)
     cacheFile = os.path.join(cacheDir, tag)
     if os.path.isfile(cacheFileOldName):
         os.rename(cacheFileOldName, cacheFile)
     if os.path.isfile(cacheFile):
         return eval(open(cacheFile).read().strip())
     else:
         bugSystemData = self.getConfigValue("bug_system_location", allSubKeys=True)
         markedArtefacts = self.getConfigValue("batch_jenkins_marked_artefacts")
         fileFinder = self.getConfigValue("batch_jenkins_archive_file_pattern")
         prevBuildNumber = self.getJenkinsBuildNumber(prevTag) if prevTag else None
         if buildNumber.isdigit() and prevBuildNumber is not None:
             try:
                 allChanges = jenkinschanges.getChanges(prevBuildNumber, buildNumber, bugSystemData, markedArtefacts, fileFinder, cacheDir)
                 plugins.ensureDirectoryExists(cacheDir)
                 with open(cacheFile, "w") as f:
                     f.write(pformat(allChanges) + "\n")
                 return allChanges
             except jenkinschanges.JobStillRunningException:
                 pass # don't write to cache in this case
         return []     
 def __init__(self, *args):
     plugins.ensureDirectoryExists(self.getCoreFileLocation())