Skip to content

Commit 1ce66b7

Browse files
committedJan 28, 2016
Detect R installation
1 parent 70d3907 commit 1ce66b7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed
 

‎python/plugins/processing/algs/r/RUtils.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,26 @@ class RUtils:
4747
def RFolder():
4848
folder = ProcessingConfig.getSetting(RUtils.R_FOLDER)
4949
if folder is None:
50-
folder = ''
50+
if isWindows():
51+
if "ProgramW6432" in os.environ.keys() and os.path.isdir(os.path.join(os.environ["ProgramW6432"],'R')):
52+
testfolder = os.path.join(os.environ["ProgramW6432"],'R')
53+
elif "PROGRAMFILES(x86)" in os.environ.keys() and os.path.isdir(os.path.join(os.environ["PROGRAMFILES(x86)"],'R')):
54+
testfolder = os.path.join(os.environ["PROGRAMFILES(x86)"],'R')
55+
elif "PROGRAMFILES" in os.environ.keys() and os.path.isdir(os.path.join(os.environ["PROGRAMFILES"],'R')):
56+
testfolder = os.path.join(os.environ["PROGRAMFILES"],'R')
57+
else:
58+
testfolder = 'C:\\R'
59+
if os.path.isdir(testfolder):
60+
subfolders = os.listdir(testfolder)
61+
subfolders.sort(reverse=True)
62+
for subfolder in subfolders:
63+
if subfolder.startswith('R-'):
64+
folder = os.path.join(testfolder, subfolder)
65+
break
66+
else:
67+
folder = ''
68+
else:
69+
folder = ''
5170

5271
return os.path.abspath(unicode(folder))
5372

0 commit comments

Comments
 (0)
Please sign in to comment.