Skip to content
Permalink
Browse files

[processing] fixed handling of folders and files in settings

fixes #12511
  • Loading branch information
volaya committed Jun 26, 2015
1 parent 38d5980 commit b80a1bcac5659417c6fb05f47249fa0992410469
@@ -51,10 +51,10 @@ def initializeSettings(self):
if isWindows() or isMac():
ProcessingConfig.addSetting(Setting(self.getDescription(),
GrassUtils.GRASS_FOLDER, self.tr('GRASS folder'),
GrassUtils.grassPath()))
GrassUtils.grassPath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
GrassUtils.GRASS_WIN_SHELL, self.tr('Msys folder'),
GrassUtils.grassWinShell()))
GrassUtils.grassWinShell(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
GrassUtils.GRASS_LOG_COMMANDS,
self.tr('Log execution commands'), False))
@@ -52,11 +52,11 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(
self.getDescription(),
Grass7Utils.GRASS_FOLDER, self.tr('GRASS7 folder'),
Grass7Utils.grassPath()))
Grass7Utils.grassPath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
Grass7Utils.GRASS_WIN_SHELL, self.tr('Msys folder'),
Grass7Utils.grassWinShell()))
Grass7Utils.grassWinShell(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
Grass7Utils.GRASS_LOG_COMMANDS,
@@ -209,15 +209,17 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(
self.getDescription(),
LAStoolsUtils.LASTOOLS_FOLDER,
self.tr('LAStools folder'), LAStoolsUtils.LAStoolsPath()))
self.tr('LAStools folder'), LAStoolsUtils.LAStoolsPath(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
FusionUtils.FUSION_FOLDER,
self.tr('Fusion folder'), FusionUtils.FusionPath()))
self.tr('Fusion folder'), FusionUtils.FusionPath(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
LAStoolsUtils.WINE_FOLDER,
self.tr('Wine folder'), ''))
self.tr('Wine folder'), '', valuetype=Setting.FOLDER))

def getName(self):
return 'lidartools'
@@ -83,17 +83,21 @@ def initializeSettings(self):
if OTBUtils.findOtbPath() is None:
ProcessingConfig.addSetting(Setting(self.getDescription(),
OTBUtils.OTB_FOLDER,
self.tr("OTB command line tools folder"), OTBUtils.otbPath()))
self.tr("OTB command line tools folder"), OTBUtils.otbPath(),
valuetype=Setting.FOLDER))
if OTBUtils.findOtbLibPath() is None:
ProcessingConfig.addSetting(Setting(self.getDescription(),
OTBUtils.OTB_LIB_FOLDER,
self.tr("OTB applications folder"), OTBUtils.otbLibPath()))
self.tr("OTB applications folder"), OTBUtils.otbLibPath(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
OTBUtils.OTB_SRTM_FOLDER,
self.tr("SRTM tiles folder"), OTBUtils.otbSRTMPath()))
self.tr("SRTM tiles folder"), OTBUtils.otbSRTMPath(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
OTBUtils.OTB_GEOID_FILE,
self.tr("Geoid file"), OTBUtils.otbGeoidPath()))
self.tr("Geoid file"), OTBUtils.otbGeoidPath(),
valuetype=Setting.FOLDER))

def unload(self):
AlgorithmProvider.unload(self)
@@ -61,15 +61,18 @@ def __init__(self):
def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.RSCRIPTS_FOLDER, self.tr('R Scripts folder'), RUtils.RScriptsFolder()))
self.getDescription(), RUtils.RSCRIPTS_FOLDER,
self.tr('R Scripts folder'), RUtils.RScriptsFolder(),
valuetype=Setting.FOLDER))
if isWindows():
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_FOLDER, self.tr('R folder'), RUtils.RFolder()))
RUtils.R_FOLDER, self.tr('R folder'), RUtils.RFolder(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_LIBS_USER, self.tr('R user library folder'), RUtils.RLibs()))
RUtils.R_LIBS_USER, self.tr('R user library folder'),
RUtils.RLibs(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_USE64, self.tr('Use 64 bit version'), False))
@@ -56,7 +56,8 @@ def __init__(self):
def initializeSettings(self):
if isWindows() or isMac():
ProcessingConfig.addSetting(Setting("SAGA",
SagaUtils.SAGA_FOLDER, self.tr('SAGA folder'), ''))
SagaUtils.SAGA_FOLDER, self.tr('SAGA folder'), '',
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting("SAGA",
SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION,
self.tr('Enable SAGA Import/Export optimizations'), False))
@@ -108,7 +108,7 @@ def getSagaInstalledVersion(runSaga=False):

maxRetries = 5
retries = 0
if _installedVersionFound or not runSaga:
if _installedVersionFound and not runSaga:
return _installedVersion

if isWindows():
@@ -79,11 +79,11 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.TAUDEM_FOLDER,
self.tr('TauDEM command line tools folder'),
TauDEMUtils.taudemPath()))
TauDEMUtils.taudemPath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.TAUDEM_MULTIFILE_FOLDER,
self.tr('TauDEM multifile command line tools folder'),
TauDEMUtils.taudemMultifilePath()))
TauDEMUtils.taudemMultifilePath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.TAUDEM_USE_SINGLEFILE,
self.tr('Enable singlefile TauDEM tools'), True))
@@ -93,7 +93,7 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.MPIEXEC_FOLDER,
self.tr('MPICH2/OpenMPI bin directory'),
TauDEMUtils.mpiexecPath()))
TauDEMUtils.mpiexecPath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.MPI_PROCESSES,
self.tr('Number of MPI parallel processes to use'), 2))
@@ -80,7 +80,8 @@ def initialize():
ProcessingConfig.addSetting(Setting(
ProcessingConfig.tr('General'),
ProcessingConfig.OUTPUT_FOLDER,
ProcessingConfig.tr('Output folder'), tempFolder()))
ProcessingConfig.tr('Output folder'), tempFolder(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
ProcessingConfig.tr('General'),
ProcessingConfig.SHOW_CRS_DEF,
@@ -17,6 +17,7 @@
***************************************************************************
"""


__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
@@ -33,7 +34,7 @@
QStandardItemModel, QStandardItem, QMessageBox, QStyledItemDelegate,
QLineEdit, QSpinBox, QDoubleSpinBox, QWidget, QToolButton, QHBoxLayout)

from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.core.Processing import Processing

pluginPath = os.path.split(os.path.dirname(__file__))[0]
@@ -165,7 +166,7 @@ class SettingItem(QStandardItem):
def __init__(self, setting):
QStandardItem.__init__(self)
self.setting = setting

self.setData(setting.valuetype, Qt.UserRole)
if isinstance(setting.value, bool):
self.setCheckable(True)
self.setEditable(False)
@@ -199,10 +200,9 @@ def createEditor(
spnBox.setDecimals(6)
return spnBox
elif isinstance(value, (str, unicode)):
if os.path.isdir(value):
valuetype = self.convertValue(index.model().data(index, Qt.UserRole))
if valuetype == Setting.FOLDER:
return FileDirectorySelector(parent)
elif os.path.isfile(value):
return FileDirectorySelector(parent, True)
else:
return FileDirectorySelector(parent, True)

@@ -55,7 +55,7 @@ def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
ProcessingConfig.addSetting(Setting(self.getDescription(),
ModelerUtils.MODELS_FOLDER, self.tr('Models folder', 'ModelerAlgorithmProvider'),
ModelerUtils.modelsFolder()))
ModelerUtils.modelsFolder(), valuetype=Setting.FOLDER))

def setAlgsList(self, algs):
ModelerUtils.allAlgs = algs
@@ -58,7 +58,7 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(self.getDescription(),
ScriptUtils.SCRIPTS_FOLDER,
self.tr('Scripts folder', 'ScriptAlgorithmProvider'),
ScriptUtils.scriptsFolder()))
ScriptUtils.scriptsFolder(), valuetype=Setting.FOLDER))

def unload(self):
AlgorithmProvider.unload(self)

0 comments on commit b80a1bc

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