def instantiate_plugins(self, app): """ Iterates over the plugins present in the plugin directory and instantiate each of them. :param app: The ICTV Core web.py app """ # two alternatives : select activated plugins and then query on PluginChannel to get the channel number # or select all channels and add mapping if its plugin is activated. Plugin.update_plugins(self.list_plugins()) # Updates plugins database plugins = [p for p in Plugin.select() if p.channels] # PluginChannel.select().throughTo.plugin.distinct() is not working a.t.m., see https://github.com/sqlobject/sqlobject/issues/137 for p in plugins: if p.activated == 'yes': self.instantiate_plugin(app, p) elif p.activated == 'no': self.missing_dependencies[p.name] = self.get_plugin_missing_dependencies(p.name)
def render_page(self): current_user = User.get(self.session['user']['id']) plugin_dirs = self.plugin_manager.list_plugins() plugins = Plugin.update_plugins(plugin_dirs) return self.renderer.plugins(plugins=plugins, missing_dependencies=self.plugin_manager.missing_dependencies, current_user=current_user)
def setUp( self ): # This test duplicates a lot of setUp code, it should be refactored or dropped from ictv.app import get_app from ictv.database import setup_database, create_database, load_plugins from ictv.plugin_manager.plugin_manager import PluginManager from paste.fixture import TestApp create_fake_plugin(self.fake_plugin_root) setup_database() create_database() load_plugins() Plugin.selectBy(name='fake_plugin').getOne().activated = 'notfound' Plugin.update_plugins(PluginManager.list_plugins()) self.ictv_app = get_app("/tmp/config.yaml") self.testApp = TestApp(self.ictv_app.wsgifunc())
def load_plugins(): from ictv.plugin_manager.plugin_manager import PluginManager Plugin.update_plugins(PluginManager.list_plugins()) for module in PluginManager.get_plugins_modules(): if hasattr(module, 'install'): getattr(module, 'install')()