def methodslist(self, request, **kwargs): self.method_check(request, allowed=['get']) self.is_authenticated(request) self.throttle_check(request) if 'plugin_name' in kwargs: methods = PluginManagerSingleton.get().methodListPlugin(plugin_name=kwargs['plugin_name']) else: methods = PluginManagerSingleton.get().methodListPlugin() self.log_throttled_access(request) return self.create_response(request, methods, HttpAccepted)
def methodslist(self, request, **kwargs): self.method_check(request, allowed=['get']) self.is_authenticated(request) self.throttle_check(request) if 'plugin_name' in kwargs: methods = PluginManagerSingleton.get().methodListPlugin( plugin_name=kwargs['plugin_name']) else: methods = PluginManagerSingleton.get().methodListPlugin() self.log_throttled_access(request) return self.create_response(request, methods, HttpAccepted)
def enable(self, request, **kwargs): self.method_check(request, allowed=['get']) self.is_authenticated(request) self.throttle_check(request) status = PluginManagerSingleton.get().enablePlugin(plugin_pk=kwargs['pk']) self.log_throttled_access(request) LisaFactorySingleton.get().SchedReload() LisaFactorySingleton.get().LisaReload() return self.create_response(request, status, HttpAccepted)
def install(self, request, **kwargs): self.method_check(request, allowed=['post','get']) self.is_authenticated(request) self.throttle_check(request) plugin_name = kwargs['plugin_name'] status = PluginManagerSingleton.get().installPlugin(plugin_name=plugin_name) self.log_throttled_access(request) LisaFactorySingleton.get().SchedReload() LisaFactorySingleton.get().LisaReload() return self.create_response(request, status, HttpCreated)
def uninstall(self, request, **kwargs): self.method_check(request, allowed=['get']) self.is_authenticated(request) self.throttle_check(request) status = PluginManagerSingleton.get().uninstallPlugin( plugin_pk=kwargs['pk']) self.log_throttled_access(request) LisaFactorySingleton.get().SchedReload() LisaFactorySingleton.get().LisaReload() return self.create_response(request, status, HttpAccepted)
def manage(self, name, action, author_email=None, author_name=None, dev_mode=False, version=None): status = {'status': None} if action == "install": status = PluginManagerSingleton.get().installPlugin(plugin_name=name, dev_mode=dev_mode, version=version) elif action == "disable": status = PluginManagerSingleton.get().disablePlugin(plugin_name=name) elif action == "uninstall": status = PluginManagerSingleton.get().uninstallPlugin(plugin_name=name, dev_mode=dev_mode) elif action == "enable": status = PluginManagerSingleton.get().enablePlugin(plugin_name=name) elif action == "upgrade": status = PluginManagerSingleton.get().upgradePlugin(plugin_name=name, dev_mode=dev_mode) elif action == "create": status = PluginManagerSingleton.get().createPlugin(plugin_name=name, author_name=author_name, author_email=author_email) else: exit() if status['status'] == 'success': self.stdout.write("[" + self.OKGREEN + "OK" + self.ENDC + "]" + " " + status['log']) else: self.stdout.write("[" + self.FAIL + "FAIL" + self.ENDC + "]" + " " + status['log'])
import tastypie_swagger v1_api = Api(api_name='v1') v1_api.register(UserResource()) v1_api.register(PluginResource()) v1_api.register(IntentResource()) v1_api.register(WorkspaceResource()) v1_api.register(WidgetResource()) v1_api.register(WidgetByUserResource()) v1_api.register(LisaResource()) urlpatterns = [] #Register plugin's API from lisa.server.plugins.PluginManager import PluginManagerSingleton for plugin in PluginManagerSingleton.get().getEnabledPlugins(): urlpatterns += patterns('', url(r'^backend/' + str(plugin) + r'/', include('lisa.plugins.' + str(plugin) + '.web.urls'))) v1_api.register(namedAny('lisa.plugins.' + plugin + '.web.api.' + plugin + 'Resource')()) apipatterns = patterns('', url(r'api/', include(v1_api.urls)), url(r'^api/docs/', include('tastypie_swagger.urls', namespace='tastypie_swagger'), kwargs={"tastypie_api_module":'lisa.server.web.weblisa.urls.v1_api', "namespace":"tastypie_swagger"} ), ) urlpatterns += patterns('', (r'^backend/', include(apipatterns)))
def setUp(self): self.pluginManager = PluginManagerSingleton.get()
""" Actually create an instance """ if self.__instance is None: self.__instance = LisaFactory() log.msg("LisaFactory initialised") return self.__instance get = classmethod(get) # Create an instance of factory, then create a protocol instance to import it everywhere LisaFactorySingleton.get() LisaProtocolSingleton.get() # Load the plugins PluginManagerSingleton.get().loadPlugins() def Initialize(): # Create the default core_intents_list intent defaults_intent_list = {'name': "core_intents_list", 'function': "list", 'module': "lisa.server.core.intents.Intents", 'enabled': True } intent_list, created = Intent.objects.get_or_create(name='core_intents_list', defaults=defaults_intent_list) # Create the default rule of the rule engine defaults_rule = {'name': "DefaultAnwser", 'order': 999,
from api import LisaResource, UserResource from twisted.python.reflect import namedAny import tastypie_swagger v1_api = Api(api_name='v1') v1_api.register(UserResource()) v1_api.register(PluginResource()) v1_api.register(IntentResource()) v1_api.register(WorkspaceResource()) v1_api.register(WidgetResource()) v1_api.register(WidgetByUserResource()) v1_api.register(LisaResource()) urlpatterns = patterns('', url(r'^speech/', include('lisa.server.web.googlespeech.urls')), url(r'^plugins/', include('lisa.server.web.manageplugins.urls')), url(r'', include('lisa.server.web.interface.urls')), ) #Register plugin's API from lisa.server.plugins.PluginManager import PluginManagerSingleton for plugin in PluginManagerSingleton.get().getEnabledPlugins(): urlpatterns += patterns('', url(r'^' + str(plugin) + r'/', include('lisa.plugins.' + str(plugin) + '.web.urls'))) v1_api.register(namedAny('lisa.plugins.' + plugin + '.web.api.' + plugin + 'Resource')()) urlpatterns += patterns('', url(r'^api/', include(v1_api.urls)), url(r'^api/docs/', include('tastypie_swagger.urls', namespace='tastypie_swagger')), )
Actually create an instance """ if self.__instance is None: self.__instance = LisaFactory() log.msg("LisaFactory initialised") return self.__instance get = classmethod(get) # Create an instance of factory, then create a protocol instance to import it everywhere LisaFactorySingleton.get() LisaProtocolSingleton.get() # Load the plugins PluginManagerSingleton.get().loadPlugins() def Initialize(): # Create the default core_intents_list intent defaults_intent_list = { 'name': "core_intents_list", 'function': "list", 'module': "lisa.server.core.intents.Intents", 'enabled': True } intent_list, created = Intent.objects.get_or_create( name='core_intents_list', defaults=defaults_intent_list) # Create the default rule of the rule engine