Пример #1
0
    def checkBeforeOpeningParametersDialog(self):
        if SextanteUtils.isWindows():
            path = RUtils.RFolder()
            if path == "":
                return "R folder is not configured.\nPlease configure it before running R scripts."

        R_INSTALLED = "R_INSTALLED"
        settings = QSettings()
        if settings.contains(R_INSTALLED):
            return
        if SextanteUtils.isWindows():
            if SextanteConfig.getSetting(RUtils.R_USE64):
                execDir = "x64"
            else:
                execDir = "i386"
            command = [
                RUtils.RFolder() + os.sep + "bin" + os.sep + execDir + os.sep +
                "R.exe --version"
            ]
        else:
            command = ["R --version"]
        proc = subprocess.Popen(command,
                                shell=True,
                                stdout=subprocess.PIPE,
                                stdin=subprocess.PIPE,
                                stderr=subprocess.STDOUT,
                                universal_newlines=True).stdout

        for line in iter(proc.readline, ""):
            if "R version" in line:
                settings.setValue(R_INSTALLED, True)
                return
        return "It seems that R is not correctly installed in your system.\nPlease install it before running R Scripts."
Пример #2
0
 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     SextanteConfig.addSetting(
         Setting(self.getDescription(), RUtils.RSCRIPTS_FOLDER,
                 "R Scripts folder", RUtils.RScriptsFolder()))
     if SextanteUtils.isWindows():
         SextanteConfig.addSetting(
             Setting(self.getDescription(), RUtils.R_FOLDER, "R folder",
                     RUtils.RFolder()))
Пример #3
0
 def processAlgorithm(self, progress):
     if SextanteUtils.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)
     SextanteLog.addToLog(SextanteLog.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()