mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-19 00:02:48 -04:00
Merge pull request #2028 from ninsbl/master
Provide option for R_LIBS_USER in Processing
This commit is contained in:
commit
e58e8ac6bd
@ -285,6 +285,8 @@ class RAlgorithm(GeoAlgorithm):
|
||||
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 @@ class RAlgorithmProvider(AlgorithmProvider):
|
||||
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 @@ class RAlgorithmProvider(AlgorithmProvider):
|
||||
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 @@ class RUtils:
|
||||
|
||||
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 @@ class RUtils:
|
||||
'BATCH',
|
||||
'--vanilla',
|
||||
RUtils.getRScriptFilename(),
|
||||
RUtils.getConsoleOutputFilename(),
|
||||
RUtils.getConsoleOutputFilename()
|
||||
]
|
||||
|
||||
else:
|
||||
os.chmod(RUtils.getRScriptFilename(), stat.S_IEXEC | stat.S_IREAD
|
||||
| stat.S_IWRITE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user