Esempio n. 1
0
 def loadFromFolder(folder):
     if not os.path.exists(folder):
         return []
     algs = []
     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() != '':
                         algs.append(alg)
                 except WrongScriptException as e:
                     QgsMessageLog.logMessage(
                         e.msg,
                         QCoreApplication.translate('Processing',
                                                    'Processing'),
                         QgsMessageLog.CRITICAL)
                 except Exception as e:
                     QgsMessageLog.logMessage(
                         QCoreApplication.translate(
                             'Processing',
                             'Could not load script: {0}\n{1}').format(
                                 descriptionFile, str(e)),
                         QCoreApplication.translate('Processing',
                                                    'Processing'),
                         QgsMessageLog.CRITICAL)
     return algs
Esempio n. 2
0
 def loadFromFolder(folder):
     if not os.path.exists(folder):
         return []
     algs = []
     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() != '':
                         algs.append(alg)
                 except WrongScriptException as e:
                     ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
                 except Exception as e:
                     ProcessingLog.addToLog(
                         ProcessingLog.LOG_ERROR,
                         QCoreApplication.translate('Processing', 'Could not load script: {0}\n{1}').format(descriptionFile, str(e))
                     )
     return algs