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
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,17 @@ def defineCharacteristicsFromFile(self):
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)
Expand Down
10 changes: 10 additions & 0 deletions python/plugins/processing/algs/otb/OTBUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ def executeOtb(commands, progress):

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 == '':
Expand Down

0 comments on commit ea712c6

Please sign in to comment.