(self)
Load all plugins present in the plugins/ directory in our module
Load all plugins present in the plugins/ directory in our module
Load all plugins present in the plugins / directory in our module
def load_plugins(self):
        """Load all plugins present in the plugins/ directory in our module"""
        if self.done:
            dbg('PluginRegistry::load_plugins: Already loaded')
            return

        config = Config()

        for plugindir in self.path:
            sys.path.insert(0, plugindir)
            try:
                files = os.listdir(plugindir)
            except OSError:
                sys.path.remove(plugindir)
                continue
            for plugin in files:
                if plugin == '__init__.py':
                    continue
                pluginpath = os.path.join(plugindir, plugin)
                if os.path.isfile(pluginpath) and plugin[-3:] == '.py':
                    dbg('PluginRegistry::load_plugins: Importing plugin %s' % 
                        plugin)
                    try:
                        module = __import__(plugin[:-3], None, None, [''])
                        for item in getattr(module, 'AVAILABLE'):
                            if item not in list(self.available_plugins.keys()):
                                func = getattr(module, item)
                                self.available_plugins[item] = func

                            if item not in config['enabled_plugins']:
                                dbg('plugin %s not enabled, skipping' % item)
                                continue
                            if item not in self.instances:
                                self.instances[item] = func()
                    except Exception as ex:
                        err('PluginRegistry::load_plugins: Importing plugin %s \
failed: %s' % (plugin, ex))

        self.done = True
def load_plugins ( self ) : if self . done : dbg ( 'PluginRegistry::load_plugins: Already loaded' ) return config = Config ( ) for plugindir in self . path : sys . path . insert ( 0 , plugindir ) try : files = os . listdir ( plugindir ) except OSError : sys . path . remove ( plugindir ) continue for plugin in files : if plugin == '__init__.py' : continue pluginpath = os . path . join ( plugindir , plugin ) if os . path . isfile ( pluginpath ) and plugin [ - 3 : ] == '.py' : dbg ( 'PluginRegistry::load_plugins: Importing plugin %s' % plugin ) try : module = __import__ ( plugin [ : - 3 ] , None , None , [ '' ] ) for item in getattr ( module , 'AVAILABLE' ) : if item not in list ( self . available_plugins . keys ( ) ) : func = getattr ( module , item ) self . available_plugins [ item ] = func if item not in config [ 'enabled_plugins' ] : dbg ( 'plugin %s not enabled, skipping' % item ) continue if item not in self . instances : self . instances [ item ] = func ( ) except Exception as ex : err ( 'PluginRegistry::load_plugins: Importing plugin %s \
failed: %s' % ( plugin , ex ) ) self . done = True