diff --git a/otb/OTBAlgorithmProvider.py b/otb/OTBAlgorithmProvider.py index 686e6af2b52e65da0a09e7dec48624a31235e60d..adb0528515de9863bbf25bf8c7baaacf8728d27b 100644 --- a/otb/OTBAlgorithmProvider.py +++ b/otb/OTBAlgorithmProvider.py @@ -204,12 +204,7 @@ class OTBAlgorithmProvider(QgsProcessingProvider): OTBUtils.geoidFile(), valuetype=Setting.FOLDER )) - ProcessingConfig.addSetting(Setting(group, OTBUtils.VERSION, - self.tr("version"), - OTBUtils.version(), - valuetype=str, - hidden=True - )) + ProcessingConfig.readSettings() self.refreshAlgorithms() return True @@ -253,8 +248,21 @@ class OTBAlgorithmProvider(QgsProcessingProvider): if not self.canBeActivated(): return - if self.version is None: - self.version = OTBUtils.version() + self.version = None + # install_dir #otb issue 1557 + version_file = os.path.join(OTBUtils.otbFolder(), 'share', 'doc', 'otb', 'VERSION') + if not os.path.isfile(version_file): + version_file = os.path.join(OTBUtils.otbFolder(), 'share', 'doc', 'OTB-6.6', 'VERSION') + if not os.path.isfile(version_file): + version_file = os.path.join(OTBUtils.otbFolder(), 'VERSION') + + if os.path.isfile(version_file): + with open(version_file) as vf: + vlines = vf.readlines() + vlines = [l.strip() for l in vlines] + vline = vlines[0] + if 'OTB Version:' in vline: + self.version = vline.split(':')[1].strip() QgsMessageLog.logMessage(self.tr("Loading OTB '{}'.".format(self.version)), self.tr('Processing'), Qgis.Info) self.algs = self.createAlgsList()