Commit a5087c62 authored by Rashad Kanavath's avatar Rashad Kanavath

fixes #20 make otb-app-folder setting optional

default app path is added to app dir list which is
parent b9d13f5a
......@@ -67,18 +67,11 @@ class OTBAlgorithmProvider(QgsProcessingProvider):
def check_app_folder(self, v):
if not self.isActive():
if not v or not os.path.exists(v):
raise ValueError('Cannot activate OTB provider'))
folder = OTBUtils.otbFolder()
otb_app_dirs = self.otb_app_dir_list(v)
if len(otb_app_dirs) < 1:
raise ValueError("Invalid path given for 'OTB application folder'. OTB provider will be disabled"))
folder = OTBUtils.otbFolder()
otb_app_dirs = self.otb_app_dir_list(v, folder)
if len(otb_app_dirs) == 1:
utils.iface.messageBar().pushInfo("OTB", "OTB applications folder set to default: '{}'".format(otb_app_dirs[0]))
#isValid is True if there is atleast one valid otb application is given path
isValid = False
......@@ -189,7 +182,7 @@ class OTBAlgorithmProvider(QgsProcessingProvider):
ProcessingConfig.addSetting(Setting(group, OTBUtils.APP_FOLDER,"OTB application folder"),"OTB application folder (optional)"),
......@@ -294,12 +287,15 @@ class OTBAlgorithmProvider(QgsProcessingProvider):
def descrFile(self, d, f):
return os.path.join(self.descrFolder(d), f)
def otb_app_dir_list(self, v):
def otb_app_dir_list(self, v, otb_folder):
default_app_dir = os.path.join(otb_folder, 'lib', 'otb', 'applications')
folders = v.split(';')
app_dirs = []
for f in folders:
if f is not None and os.path.exists(f):
if not default_app_dir in app_dirs:
return app_dirs
def name(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment