Esempio n. 1
0
 def findJenkinsChanges(self, prevTag, tag, cacheDir):
     buildNumber = self.getCiBuildNumber(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.getCiBuildNumber(
             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 []
Esempio n. 2
0
 def getCoreFileLocation(self, app):
     location = app.getConfigValue("queue_system_core_file_location")
     if not location or not os.path.isdir(location):
         location = os.path.join(os.getenv("TEXTTEST_TMP"),
                                 "grid_core_files")
         plugins.ensureDirectoryExists(location)
     return location
Esempio n. 3
0
 def notifyAdd(self, test, *args, **kw):
     if not self.done:
         RedirectLogResponder.done = True
         logDir = os.path.join(test.app.writeDirectory, "slavelogs")
         plugins.ensureDirectoryExists(logDir)
         os.chdir(logDir)
         logFile, errFile = test.app.getSubmissionRules(test).getJobFiles()
         errPath = os.path.join(logDir, errFile)
         logPath = os.path.join(logDir, logFile)
         if not os.path.isfile(errPath) and not os.path.isfile(logPath):
             sys.stderr = open(errPath, "w")
             # This is more or less hardcoded to use a timed formatter and write to the file
             handler = logging.FileHandler(logPath)
             formatter = logging.Formatter("%(asctime)s - %(message)s")
             handler.setFormatter(formatter)
             plugins.log.addHandler(handler)
Esempio n. 4
0
 def copyFiles(self, test, reconnLocation):
     test.makeWriteDirectory()
     tmpDir = test.getDirectory(temporary=1)
     plugins.ensureDirectoryExists(tmpDir)
     self.diag.info("Copying files from " + reconnLocation + " to " + tmpDir)
     for file in os.listdir(reconnLocation):
         fullPath = os.path.join(reconnLocation, file)
         if os.path.isfile(fullPath):
             targetPath = os.path.join(tmpDir, os.path.basename(fullPath))
             try:
                 shutil.copyfile(fullPath, targetPath)
             except EnvironmentError as e:
                 # File could not be copied, may not have been readable
                 # Write the exception to it instead
                 targetFile = open(targetPath, "w")
                 targetFile.write("Failed to copy file - exception info follows :\n" + str(e) + "\n")
                 targetFile.close()
Esempio n. 5
0
 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