Commit b9d13f5a authored by Rashad Kanavath's avatar Rashad Kanavath

always read version on startup

DONOT store this variable in qgsettings. A new/updated install of otb in
same location will mislead users
parent e88ccb86
......@@ -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()
......
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