Skip to content

Commit

Permalink
[processing] Search for description files also in the sub-directories…
Browse files Browse the repository at this point in the history
… of the script/model directory
  • Loading branch information
Rado Guzinski committed May 26, 2014
1 parent 8499b4d commit 3799f11
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
27 changes: 14 additions & 13 deletions python/plugins/processing/algs/r/RAlgorithmProvider.py
Expand Up @@ -88,16 +88,17 @@ def _loadAlgorithms(self):
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))
27 changes: 14 additions & 13 deletions python/plugins/processing/modeler/ModelerAlgorithmProvider.py
Expand Up @@ -80,16 +80,17 @@ def _loadAlgorithms(self):
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)
27 changes: 14 additions & 13 deletions python/plugins/processing/script/ScriptAlgorithmProvider.py
Expand Up @@ -82,16 +82,17 @@ def _loadAlgorithms(self):
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))

0 comments on commit 3799f11

Please sign in to comment.