[processing] prevent otb algorithms being run if otb not configured

fixes #13215
This commit is contained in:
volaya 2015-09-30 09:42:20 +02:00
parent 1d67ce7ca7
commit ea712c6c23
2 changed files with 17 additions and 5 deletions

View File

@ -166,15 +166,17 @@ class OTBAlgorithm(GeoAlgorithm):
self.tr('Could not open OTB algorithm: %s\n%s' % (self.descriptionFile, line)))
raise e
def checkBeforeOpeningParametersDialog(self):
return OTBUtils.checkOtbConfiguration()
def processAlgorithm(self, progress):
currentOs = os.name
msg = OTBUtils.checkOtbConfiguration()
if msg:
raise GeoAlgorithmExecutionException(msg)
path = OTBUtils.otbPath()
libpath = OTBUtils.otbLibPath()
if path == "" or libpath == "":
raise GeoAlgorithmExecutionException(
self.tr('OTB folder is not configured. Please configure it '
'before running OTB algorithms.'))
commands = []
commands.append(path + os.sep + self.cliName)

View File

@ -144,6 +144,16 @@ class OTBUtils:
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
@staticmethod
def checkOtbConfiguration():
path = OTBUtils.otbPath()
libpath = OTBUtils.otbLibPath()
configurationOk = bool(path) and bool(libpath)
if not configurationOk:
return OTBUtils.tr('OTB folder is not configured. Please configure it '
'before running OTB algorithms.')
@staticmethod
def tr(string, context=''):
if context == '':