Skip to content
Permalink
Browse files

Merge pull request #2028 from ninsbl/master

Provide option for R_LIBS_USER in Processing
  • Loading branch information
volaya committed May 6, 2015
2 parents c4eb1fb + 70d3907 commit e58e8ac6bd434b9f6b2d33e43c4427ba94227159
@@ -285,6 +285,8 @@ def getImportCommands(self):
commands.append('options("repos"="http://cran.at.r-project.org/")')

# Try to install packages if needed
if isWindows():
commands.append('.libPaths(\"' + str(RUtils.RLibs()).replace('\\','/') + '\")')
packages = RUtils.getRequiredPackages(self.script)
packages.extend(['rgdal', 'raster'])
for p in packages:
@@ -61,6 +61,9 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_FOLDER, self.tr('R folder'), RUtils.RFolder()))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_LIBS_USER, self.tr('R user library folder'), RUtils.RLibs()))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_USE64, self.tr('Use 64 bit version'), False))
@@ -70,6 +73,7 @@ def unload(self):
ProcessingConfig.removeSetting(RUtils.RSCRIPTS_FOLDER)
if isWindows():
ProcessingConfig.removeSetting(RUtils.R_FOLDER)
ProcessingConfig.removeSetting(RUtils.R_LIBS_USER)
ProcessingConfig.removeSetting(RUtils.R_USE64)

def getIcon(self):
@@ -41,6 +41,7 @@ class RUtils:
RSCRIPTS_FOLDER = 'R_SCRIPTS_FOLDER'
R_FOLDER = 'R_FOLDER'
R_USE64 = 'R_USE64'
R_LIBS_USER = 'R_LIBS_USER'

@staticmethod
def RFolder():
@@ -50,6 +51,15 @@ def RFolder():

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

@staticmethod
def RLibs():
folder = ProcessingConfig.getSetting(RUtils.R_LIBS_USER)
if folder is None:
folder = unicode(os.path.join(userFolder(), 'rlibs'))
mkdir(folder)

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

@staticmethod
def RScriptsFolder():
folder = ProcessingConfig.getSetting(RUtils.RSCRIPTS_FOLDER)
@@ -90,8 +100,9 @@ def executeRAlgorithm(alg, progress):
'BATCH',
'--vanilla',
RUtils.getRScriptFilename(),
RUtils.getConsoleOutputFilename(),
RUtils.getConsoleOutputFilename()
]

else:
os.chmod(RUtils.getRScriptFilename(), stat.S_IEXEC | stat.S_IREAD
| stat.S_IWRITE)

0 comments on commit e58e8ac

Please sign in to comment.
You can’t perform that action at this time.