Skip to content

Commit facc198

Browse files
committed
[sextante]added checking for R installation
1 parent bfc92f7 commit facc198

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

python/plugins/sextante/r/RAlgorithm.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from PyQt4.QtCore import *
2828
from PyQt4.QtGui import *
2929
from PyQt4 import QtGui, QtCore
30+
from sextante.core.SextanteConfig import SextanteConfig
3031
from sextante.core.GeoAlgorithm import GeoAlgorithm
3132
from sextante.parameters.ParameterRaster import ParameterRaster
3233
from sextante.parameters.ParameterTable import ParameterTable
@@ -389,16 +390,24 @@ def checkBeforeOpeningParametersDialog(self):
389390
path = RUtils.RFolder()
390391
if path == "":
391392
return "R folder is not configured.\nPlease configure it before running R scripts."
393+
394+
R_INSTALLED = "R_INSTALLED"
395+
settings = QSettings()
396+
if settings.contains(R_INSTALLED):
397+
return
398+
if SextanteUtils.isWindows():
399+
if SextanteConfig.getSetting(RUtils.R_USE64):
400+
execDir = "x64"
401+
else:
402+
execDir = "i386"
403+
command = [RUtils.RFolder() + os.sep + "bin" + os.sep + execDir + os.sep + "R.exe --version"]
392404
else:
393-
R_INSTALLED = "R_INSTALLED"
394-
settings = QSettings()
395-
if settings.contains(R_INSTALLED):
396-
return
397405
command = ["R --version"]
398-
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout
399-
for line in iter(proc.readline, ""):
400-
if "R version" in line:
401-
settings.setValue(R_INSTALLED, True)
402-
return
403-
return "It seems that R is not correctly installed in your system.\nPlease install it before running R Scripts."
406+
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout
407+
408+
for line in iter(proc.readline, ""):
409+
if "R version" in line:
410+
settings.setValue(R_INSTALLED, True)
411+
return
412+
return "It seems that R is not correctly installed in your system.\nPlease install it before running R Scripts."
404413

0 commit comments

Comments
 (0)