|
| 1 | +import os |
| 2 | +from PyQt4.QtCore import * |
| 3 | +from PyQt4.QtGui import * |
| 4 | +from PyQt4 import QtGui, QtCore |
1 | 5 | from sextante.core.GeoAlgorithm import GeoAlgorithm |
2 | 6 | from sextante.parameters.ParameterRaster import ParameterRaster |
3 | 7 | from sextante.parameters.ParameterTable import ParameterTable |
|
10 | 14 | from sextante.parameters.ParameterString import ParameterString |
11 | 15 | from sextante.parameters.ParameterNumber import ParameterNumber |
12 | 16 | from sextante.parameters.ParameterBoolean import ParameterBoolean |
13 | | -import os |
14 | 17 | from sextante.parameters.ParameterSelection import ParameterSelection |
15 | | -from PyQt4 import QtGui |
16 | 18 | from sextante.parameters.ParameterTableField import ParameterTableField |
17 | 19 | from sextante.outputs.OutputHTML import OutputHTML |
18 | 20 | from sextante.r.RUtils import RUtils |
19 | 21 | from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException |
20 | 22 | from sextante.core.SextanteLog import SextanteLog |
21 | 23 | from sextante.core.SextanteUtils import SextanteUtils |
| 24 | +import subprocess |
22 | 25 |
|
23 | 26 | class RAlgorithm(GeoAlgorithm): |
24 | 27 |
|
@@ -148,7 +151,7 @@ def processAlgorithm(self, progress): |
148 | 151 | if SextanteUtils.isWindows(): |
149 | 152 | path = RUtils.RFolder() |
150 | 153 | if path == "": |
151 | | - raise GeoAlgorithmExecutionException("R folder is not configured.\nPlease configure it before running R script.") |
| 154 | + raise GeoAlgorithmExecutionException("R folder is not configured.\nPlease configure it before running R scripts.") |
152 | 155 | loglines = [] |
153 | 156 | loglines.append("R execution commands") |
154 | 157 | loglines += self.getFullSetOfRCommands() |
@@ -272,3 +275,21 @@ def getRCommands(self): |
272 | 275 | return self.commands |
273 | 276 |
|
274 | 277 |
|
| 278 | + def checkBeforeOpeningParametersDialog(self): |
| 279 | + if SextanteUtils.isWindows(): |
| 280 | + path = RUtils.RFolder() |
| 281 | + if path == "": |
| 282 | + return "R folder is not configured.\nPlease configure it before running R scripts." |
| 283 | + else: |
| 284 | + R_INSTALLED = "R_INSTALLED" |
| 285 | + settings = QSettings() |
| 286 | + if settings.contains(R_INSTALLED): |
| 287 | + return |
| 288 | + command = ["R CMD BATCH"] |
| 289 | + proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout |
| 290 | + for line in iter(proc.readline, ""): |
| 291 | + if "no input file" in line: |
| 292 | + settings.setValue(R_INSTALLED, True) |
| 293 | + return |
| 294 | + return "It seems that SAGA is not correctly installed in your system.\nPlease install it before running SAGA algorithms." |
| 295 | + |
0 commit comments