Esempio n. 1
0
 def processAlgorithm(self, progress):
     if isWindows():
         path = RUtils.RFolder()
         if path == '':
             raise GeoAlgorithmExecutionException(
                     'R folder is not configured.\nPlease configure it \
                      before running R scripts.')
     loglines = []
     loglines.append('R execution commands')
     loglines += self.getFullSetOfRCommands()
     
     current = 0
     total = 50.00 / len(loglines)
     
     for line in loglines:
         progress.setCommand(line)
         current += 1
         progress.setPercentage(int(current * total))
         
     ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
     RUtils.executeRAlgorithm(self, progress)
     if self.outputStringExist:
         consoleOutput = RUtils.consoleResults
         for line in consoleOutput:
             line = line.strip().strip(' ')
             if line.startswith('<p>'):
                 token = line.split(' ')
                 token = token[1].split('<')
         self.setOutputValue(self.outputStringName, token[0])
     if self.report:
         knitrname = self.getOutputValue(RAlgorithm.KNITR_REPORT)
         htmlreportname = open(self.htmlreport + '/reporthtml.html','r')
         
         file = open(knitrname, 'w')
         file.write(htmlreportname.read())
         
         file.close()
         htmlreportname.close()
     if self.showPlots:
         htmlfilename = self.getOutputValue(RAlgorithm.RPLOTS)
         f = open(htmlfilename, 'w')
         f.write('<html><img src="' + self.plotsFilename + '"/></html>')
         f.close()
     if self.showConsoleOutput:
         htmlfilename = self.getOutputValue(RAlgorithm.R_CONSOLE_OUTPUT)
         f = open(htmlfilename, 'w')
         f.write(RUtils.getConsoleOutput())
         f.close()
     if self.outputNumberBool:
         consoleOutput = RUtils.consoleResults
         for line in consoleOutput:
             line = line.strip().strip(' ')
             if line.startswith('<p>'):
                 token = line.split(' ')
                 token = token[1].split('<')
                 self.setOutputValue(self.outputNumberName, token[0])
Esempio n. 2
0
 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     ProcessingConfig.addSetting(
         Setting(self.getDescription(), RUtils.RSCRIPTS_FOLDER,
                 'R Scripts folder', RUtils.RScriptsFolder()))
     if isWindows():
         ProcessingConfig.addSetting(
             Setting(self.getDescription(), RUtils.R_FOLDER, 'R folder',
                     RUtils.RFolder()))
         ProcessingConfig.addSetting(
             Setting(self.getDescription(), RUtils.R_USE64,
                     'Use 64 bit version', False))
Esempio n. 3
0
 def processAlgorithm(self, progress):
     if ProcessingUtils.isWindows():
         path = RUtils.RFolder()
         if path == "":
             raise GeoAlgorithmExecutionException(
                 "R folder is not configured.\nPlease configure it before running R scripts."
             )
     loglines = []
     loglines.append("R execution commands")
     loglines += self.getFullSetOfRCommands()
     for line in loglines:
         progress.setCommand(line)
     ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
     RUtils.executeRAlgorithm(self, progress)
     if self.showPlots:
         htmlfilename = self.getOutputValue(RAlgorithm.RPLOTS)
         f = open(htmlfilename, "w")
         f.write("<img src=\"" + self.plotsFilename + "\"/>")
         f.close()
     if self.showConsoleOutput:
         htmlfilename = self.getOutputValue(RAlgorithm.R_CONSOLE_OUTPUT)
         f = open(htmlfilename, "w")
         f.write(RUtils.getConsoleOutput())
         f.close()