Skip to content

Commit

Permalink
[processing] prevent otb algorithms being run if otb not configured
Browse files Browse the repository at this point in the history
fixes #13215
  • Loading branch information
volaya committed Sep 30, 2015
1 parent 1d67ce7 commit ea712c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 7 additions & 5 deletions python/plugins/processing/algs/otb/OTBAlgorithm.py
Expand Up @@ -166,15 +166,17 @@ def defineCharacteristicsFromFile(self):
self.tr('Could not open OTB algorithm: %s\n%s' % (self.descriptionFile, line))) self.tr('Could not open OTB algorithm: %s\n%s' % (self.descriptionFile, line)))
raise e raise e


def checkBeforeOpeningParametersDialog(self):
return OTBUtils.checkOtbConfiguration()

def processAlgorithm(self, progress): def processAlgorithm(self, progress):
currentOs = os.name currentOs = os.name


msg = OTBUtils.checkOtbConfiguration()
if msg:
raise GeoAlgorithmExecutionException(msg)

path = OTBUtils.otbPath() 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 = []
commands.append(path + os.sep + self.cliName) commands.append(path + os.sep + self.cliName)
Expand Down
10 changes: 10 additions & 0 deletions python/plugins/processing/algs/otb/OTBUtils.py
Expand Up @@ -144,6 +144,16 @@ def executeOtb(commands, progress):


ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines) 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 @staticmethod
def tr(string, context=''): def tr(string, context=''):
if context == '': if context == '':
Expand Down

0 comments on commit ea712c6

Please sign in to comment.