[processing] Search for description files also in the sub-directories of the script/model directory

This commit is contained in:
Rado Guzinski 2014-05-26 17:39:35 +02:00
parent 8499b4d07c
commit 3799f115b4
3 changed files with 42 additions and 39 deletions

View File

@ -88,16 +88,17 @@ class RAlgorithmProvider(AlgorithmProvider):
def loadFromFolder(self, folder):
if not os.path.exists(folder):
return
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('rsx'):
try:
fullpath = os.path.join(folder, descriptionFile)
alg = RAlgorithm(fullpath)
if alg.name.strip() != '':
self.algs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load R script:' + descriptionFile + '\n'
+ unicode(e))
for path, subdirs, files in os.walk(folder):
for descriptionFile in files:
if descriptionFile.endswith('rsx'):
try:
fullpath = os.path.join(path, descriptionFile)
alg = RAlgorithm(fullpath)
if alg.name.strip() != '':
self.algs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load R script:' + descriptionFile + '\n'
+ unicode(e))

View File

@ -80,16 +80,17 @@ class ModelerAlgorithmProvider(AlgorithmProvider):
def loadFromFolder(self, folder):
if not os.path.exists(folder):
return
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('model'):
try:
alg = ModelerAlgorithm()
fullpath = os.path.join(folder, descriptionFile)
alg.openModel(fullpath)
if alg.name.strip() != '':
alg.provider = self
self.algs.append(alg)
except WrongModelException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load model ' + descriptionFile + '\n'
+ e.msg)
for path, subdirs, files in os.walk(folder):
for descriptionFile in files:
if descriptionFile.endswith('model'):
try:
alg = ModelerAlgorithm()
fullpath = os.path.join(path, descriptionFile)
alg.openModel(fullpath)
if alg.name.strip() != '':
alg.provider = self
self.algs.append(alg)
except WrongModelException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load model ' + descriptionFile + '\n'
+ e.msg)

View File

@ -82,16 +82,17 @@ class ScriptAlgorithmProvider(AlgorithmProvider):
def loadFromFolder(self, folder):
if not os.path.exists(folder):
return
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('py'):
try:
fullpath = os.path.join(folder, descriptionFile)
alg = ScriptAlgorithm(fullpath)
if alg.name.strip() != '':
self.algs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load script:' + descriptionFile + '\n'
+ unicode(e))
for path, subdirs, files in os.walk(folder):
for descriptionFile in files:
if descriptionFile.endswith('py'):
try:
fullpath = os.path.join(path, descriptionFile)
alg = ScriptAlgorithm(fullpath)
if alg.name.strip() != '':
self.algs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load script:' + descriptionFile + '\n'
+ unicode(e))