Skip to content

Commit 0b96621

Browse files
committedJan 15, 2016
Merge pull request #2669 from volaya/otb_version
[processing] improved version detection mechanism for OTB
2 parents df27c07 + b68ee3d commit 0b96621

File tree

243 files changed

+158
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+158
-127
lines changed
 

‎python/plugins/processing/algs/otb/OTBAlgorithm.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from processing.core.ProcessingLog import ProcessingLog
4444
from processing.core.parameters import getParameterFromString
4545
from processing.core.outputs import getOutputFromString
46-
from OTBUtils import OTBUtils
46+
import OTBUtils
4747
from processing.core.parameters import ParameterExtent
4848
from processing.tools.system import getTempFilename
4949
import xml.etree.ElementTree as ET
@@ -77,7 +77,11 @@ def getIcon(self):
7777
return QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
7878

7979
def help(self):
80-
folder = os.path.join(OTBUtils.otbDescriptionPath(), 'doc')
80+
version = OTBUtils.getInstalledVersion()
81+
folder = OTBUtils.compatibleDescriptionPath(version)
82+
if folder is None:
83+
return False, None
84+
folder = os.path.join(folder, 'doc')
8185
helpfile = os.path.join(unicode(folder), self.appkey + ".html")
8286
if os.path.exists(helpfile):
8387
return False, helpfile
@@ -166,16 +170,9 @@ def defineCharacteristicsFromFile(self):
166170
self.tr('Could not open OTB algorithm: %s\n%s' % (self.descriptionFile, line)))
167171
raise e
168172

169-
def checkBeforeOpeningParametersDialog(self):
170-
return OTBUtils.checkOtbConfiguration()
171-
172173
def processAlgorithm(self, progress):
173174
currentOs = os.name
174175

175-
msg = OTBUtils.checkOtbConfiguration()
176-
if msg:
177-
raise GeoAlgorithmExecutionException(msg)
178-
179176
path = OTBUtils.otbPath()
180177

181178
commands = []

‎python/plugins/processing/algs/otb/OTBAlgorithmProvider.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from PyQt4.QtGui import QIcon
3333
from processing.core.AlgorithmProvider import AlgorithmProvider
3434
from processing.core.ProcessingConfig import ProcessingConfig, Setting
35-
from OTBUtils import OTBUtils
35+
import OTBUtils
3636
from OTBAlgorithm import OTBAlgorithm
3737
from processing.core.ProcessingLog import ProcessingLog
3838

@@ -45,7 +45,6 @@ class OTBAlgorithmProvider(AlgorithmProvider):
4545
def __init__(self):
4646
AlgorithmProvider.__init__(self)
4747
self.activate = True
48-
self.createAlgsList()
4948

5049
def getDescription(self):
5150
return self.tr("Orfeo Toolbox (Image analysis)")
@@ -57,18 +56,27 @@ def getIcon(self):
5756
return QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
5857

5958
def _loadAlgorithms(self):
60-
self.algs = self.preloadedAlgs
59+
self.algs = []
60+
61+
version = OTBUtils.getInstalledVersion(True)
62+
if version is None:
63+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
64+
self.tr('Problem with OTB installation: OTB was not found or is not correctly installed'))
65+
return
66+
67+
folder = OTBUtils.compatibleDescriptionPath(version)
68+
if folder is None:
69+
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
70+
self.tr('Problem with OTB installation: installed OTB version (%s) is not supported' % version))
71+
return
6172

62-
def createAlgsList(self):
63-
self.preloadedAlgs = []
64-
folder = OTBUtils.otbDescriptionPath()
6573
for descriptionFile in os.listdir(folder):
6674
if descriptionFile.endswith("xml"):
6775
try:
6876
alg = OTBAlgorithm(os.path.join(folder, descriptionFile))
6977

7078
if alg.name.strip() != "":
71-
self.preloadedAlgs.append(alg)
79+
self.algs.append(alg)
7280
else:
7381
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
7482
self.tr("Could not open OTB algorithm: %s" % descriptionFile))
@@ -101,6 +109,3 @@ def unload(self):
101109
AlgorithmProvider.unload(self)
102110
ProcessingConfig.removeSetting(OTBUtils.OTB_FOLDER)
103111
ProcessingConfig.removeSetting(OTBUtils.OTB_LIB_FOLDER)
104-
105-
def canBeActivated(self):
106-
return not bool(OTBUtils.checkOtbConfiguration())

0 commit comments

Comments
 (0)
Failed to load comments.