Commit 9e7683b0 authored by Guillaume Binet's avatar Guillaume Binet Committed by GitHub

Yapsictomy - part 2: backends and storage (#1220)

* Intermediate state.

* Added a separate plugin info dataclass

* add dataclasses as dep from python < 3.7

* version2array -> version2tuple

* version2tuple -> version2array

* Pass on PluginInfo

* temp

* another pass, running not working

* State where it starts to load plugins

* Cleanup for flows.

* A little bit more tests pass.

* Every tests passes except flows.

* Working on flows

* All tests passes.

* make the linter happy.

* Dataclasses backport doesn't support 3.4+3.5.

* remove 3.4 and 3.5

* error in the travis.yml.

* removed yapsy from backends and storages.

* removed all yapsy references.
parent 9a03b72a
......@@ -76,11 +76,8 @@ Extensive plugin framework
.. _VK: https://vk.com/
.. _Zulip: https://zulipchat.com/
.. _`logged to Sentry`: https://github.com/errbotio/errbot/wiki/Logging-with-Sentry
.. _bottle: http://bottlepy.org/
.. _irc: https://pypi.python.org/pypi/irc/
.. _jabberbot: http://thp.io/2007/python-jabberbot/
.. _jinja2: http://jinja.pocoo.org/
.. _rocket: https://pypi.python.org/pypi/rocket
.. _six: https://pypi.python.org/pypi/six/
.. _sleekxmpp: http://sleekxmpp.com/
.. _yapsy: http://yapsy.sourceforge.net/
......@@ -25,7 +25,7 @@ For example, with the Telegram backend this would be an instance of :class:`~err
.. code-block:: python
>>> type(self._bot)
<class 'yapsy_loaded_plugin_Telegram_0.TelegramBackend'>
<class 'errbot.backends.TelegramBackend'>
To find out what methods each bot backend has, you can take a look at the documentation of the various backends in the :mod:`errbot.backends` package.
......
......@@ -252,5 +252,4 @@ Both Travis-CI and Coveralls easily integrate with Github hosted code.
.. _conftest.py: http://doc.pytest.org/en/latest/writing_plugins.html#conftest-py-local-per-directory-plugins
.. _Coveralls.io: https://coveralls.io
.. _Travis-CI: https://travis-ci.org
.. _Yapsy: http://yapsy.sourceforge.net
.. _wheels: http://www.python.org/dev/peps/pep-0427/
import logging
import sys
from pathlib import Path
from typing import Any, Type
from errbot.plugin_info import PluginInfo
from .utils import collect_roots
log = logging.getLogger(__name__)
class PluginNotFoundException(Exception):
pass
class BackendPluginManager:
"""
This is a one shot plugin manager for Backends and Storage plugins.
"""
def __init__(self, bot_config, base_module: str, plugin_name: str, base_class: Type,
base_search_dir, extra_search_dirs=()):
self._config = bot_config
self._base_module = base_module
self._base_class = base_class
self.plugin_info = None
all_plugins_paths = collect_roots((base_search_dir, extra_search_dirs))
plugin_places = [Path(root) for root in all_plugins_paths]
for path in plugin_places:
plugfiles = path.glob('**/*.plug')
for plugfile in plugfiles:
plugin_info = PluginInfo.load(plugfile)
if plugin_info.name == plugin_name:
self.plugin_info = plugin_info
return
raise PluginNotFoundException('Could not find the plugin named %s in %s.' % (plugin_name, all_plugins_paths))
def load_plugin(self) -> Any:
plugin_path = self.plugin_info.location.parent
if plugin_path not in sys.path:
sys.path.append(plugin_path)
plugin_classes = self.plugin_info.load_plugin_classes(self._base_module, self._base_class)
if len(plugin_classes) != 1:
raise PluginNotFoundException('Found more that one plugin for %s.' % self._base_class)
_, clazz = plugin_classes[0]
return clazz(self._config)
......@@ -6,8 +6,7 @@ from typing import Any, Mapping, BinaryIO, List, Sequence, Tuple
from abc import ABC, abstractmethod
from collections import deque, defaultdict
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.base')
log = logging.getLogger(__name__)
class Identifier(ABC):
......
......@@ -3,4 +3,4 @@ Name = Graphic
Module = graphic
[Documentation]
Description = This is the graphic backend for Err.
Description = This is the graphic backend for Errbot.
......@@ -12,8 +12,7 @@ from errbot.rendering import xhtml
CARD_TMPL = Environment(loader=FileSystemLoader(os.path.dirname(__file__)),
autoescape=True).get_template('graphic_card.html')
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.graphic')
log = logging.getLogger(__name__)
try:
from PySide import QtCore, QtGui, QtWebKit
......
......@@ -3,4 +3,4 @@ Name = Hipchat
Module = hipchat
[Documentation]
Description = This is the hipchat backend for Err.
Description = This is the hipchat backend for Errbot.
......@@ -19,9 +19,7 @@ import email.mime.application
import requests
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.hipchat')
log = logging.getLogger(__name__)
try:
import hypchat
......
......@@ -3,4 +3,4 @@ Name = IRC
Module = irc
[Documentation]
Description = This is the IRC backend for Err.
Description = This is the IRC backend for Errbot.
......@@ -17,9 +17,7 @@ from errbot.utils import rate_limited
from errbot.rendering.ansiext import AnsiExtension, enable_format, \
CharacterTable, NSC
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.irc')
log = logging.getLogger(__name__)
IRC_CHRS = CharacterTable(fg_black=NSC('\x0301'),
fg_red=NSC('\x0304'),
......
......@@ -3,4 +3,4 @@ Name = Null
Module = null
[Documentation]
Description = This is the Null backend for Err.
Description = This is the Null backend for Errbot.
......@@ -5,9 +5,7 @@ from errbot.backends.base import ONLINE
from errbot.backends.test import TestPerson
from errbot.core import ErrBot
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.null')
log = logging.getLogger(__name__)
class ConnectionMock(object):
......
......@@ -3,4 +3,4 @@ Name = Slack
Module = slack
[Documentation]
Description = This is the slack backend for Err.
Description = This is the slack backend for Errbot.
......@@ -3,7 +3,6 @@ import copyreg
import json
import logging
import re
import time
import sys
import pprint
from functools import lru_cache
......@@ -18,9 +17,7 @@ from errbot.core import ErrBot
from errbot.utils import split_string_after
from errbot.rendering.ansiext import AnsiExtension, enable_format, IMTEXT_CHRS
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.slack')
log = logging.getLogger(__name__)
try:
......
......@@ -3,4 +3,4 @@ Name = Telegram
Module = telegram_messenger
[Documentation]
Description = This is the Telegram backend for Err.
Description = This is the Telegram backend for Errbot.
......@@ -6,8 +6,7 @@ from errbot.core import ErrBot
from errbot.rendering import text
from errbot.rendering.ansiext import enable_format, TEXT_CHRS
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.telegram')
log = logging.getLogger(__name__)
TELEGRAM_MESSAGE_SIZE_LIMIT = 1024
UPDATES_OFFSET_KEY = '_telegram_updates_offset'
......
......@@ -3,4 +3,4 @@ Name = Test
Module = test
[Documentation]
Description = This is the test backend for Err.
Description = This is the test backend for Errbot.
......@@ -15,8 +15,7 @@ from errbot.core_plugins.wsview import reset_app
from errbot.core import ErrBot
from errbot.bootstrap import setup_bot
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.test')
log = logging.getLogger(__name__)
QUIT_MESSAGE = '$STOP$'
......@@ -547,9 +546,7 @@ def testbot(request) -> TestBot:
# setup the logging to something digestable.
logger = logging.getLogger('')
logging.getLogger('yapsy').setLevel(logging.ERROR) # this one is way too verbose in debug
logging.getLogger('MARKDOWN').setLevel(logging.ERROR) # this one is way too verbose in debug
logging.getLogger('Rocket.Errors').setLevel(logging.ERROR) # this one is way too verbose in debug
logger.setLevel(logging.DEBUG)
console_hdlr = logging.StreamHandler(sys.stdout)
console_hdlr.setFormatter(logging.Formatter("%(levelname)-8s %(name)-25s %(message)s"))
......
......@@ -3,4 +3,4 @@ Name = Text
Module = text
[Documentation]
Description = This is the text backend for Err.
Description = This is the text backend for Errbot.
......@@ -21,8 +21,7 @@ from errbot.logs import console_hdlr
from markdown import Markdown
from markdown.extensions.extra import ExtraExtension
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.text')
log = logging.getLogger(__name__)
ENCODING_INPUT = sys.stdin.encoding
ANSI = hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()
......
......@@ -3,4 +3,4 @@ Name = XMPP
Module = xmpp
[Documentation]
Description = This is the XMPP backend for Err.
Description = This is the XMPP backend for Errbot.
......@@ -2,8 +2,6 @@ import logging
import sys
from functools import lru_cache
from sleekxmpp import JID
from sleekxmpp.exceptions import IqError
from threading import Thread
from time import sleep
......@@ -12,12 +10,13 @@ from errbot.backends.base import ONLINE, OFFLINE, AWAY, DND
from errbot.core import ErrBot
from errbot.rendering import text, xhtml, xhtmlim
# Can't use __name__ because of Yapsy
log = logging.getLogger('errbot.backends.xmpp')
log = logging.getLogger(__name__)
try:
from sleekxmpp import ClientXMPP
from sleekxmpp.xmlstream import resolver, cert
from sleekxmpp import JID
from sleekxmpp.exceptions import IqError
except ImportError:
log.exception("Could not start the XMPP backend")
log.fatal("""
......
......@@ -2,12 +2,11 @@ from os import path, makedirs
import importlib
import logging
import sys
import ast
from errbot.core import ErrBot
from errbot.plugin_manager import BotPluginManager
from errbot.repo_manager import BotRepoManager
from errbot.specific_plugin_manager import SpecificPluginManager
from errbot.backend_plugin_manager import BackendPluginManager
from errbot.storage.base import StoragePluginBase
from errbot.utils import PLUGINS_SUBDIR
from errbot.logs import format_logs
......@@ -74,7 +73,7 @@ def bot_config_defaults(config):
config.BOT_ADMINS_NOTIFICATIONS = config.BOT_ADMINS
def setup_bot(backend_name, logger, config, restore=None):
def setup_bot(backend_name: str, logger, config, restore=None) -> ErrBot:
# from here the environment is supposed to be set (daemon / non daemon,
# config.py in the python path )
......@@ -102,22 +101,22 @@ def setup_bot(backend_name, logger, config, restore=None):
)
exit(-1)
if hasattr(config, 'SENTRY_TRANSPORT') and isinstance(config.SENTRY_TRANSPORT, tuple):
try:
mod = importlib.import_module(config.SENTRY_TRANSPORT[1])
transport = getattr(mod, config.SENTRY_TRANSPORT[0])
except ImportError:
log.exception(
"Unable to import selected SENTRY_TRANSPORT - {transport}".format(transport=config.SENTRY_TRANSPORT)
)
exit(-1)
sentryhandler = SentryHandler(config.SENTRY_DSN,
level=config.SENTRY_LOGLEVEL,
transport=transport)
else:
sentryhandler = SentryHandler(config.SENTRY_DSN, level=config.SENTRY_LOGLEVEL)
logger.addHandler(sentryhandler)
try:
if hasattr(config, 'SENTRY_TRANSPORT') and isinstance(config.SENTRY_TRANSPORT, tuple):
mod = importlib.import_module(config.SENTRY_TRANSPORT[1])
transport = getattr(mod, config.SENTRY_TRANSPORT[0])
sentryhandler = SentryHandler(config.SENTRY_DSN,
level=config.SENTRY_LOGLEVEL,
transport=transport)
else:
sentryhandler = SentryHandler(config.SENTRY_DSN, level=config.SENTRY_LOGLEVEL)
logger.addHandler(sentryhandler)
except ImportError:
log.exception(
"Unable to import selected SENTRY_TRANSPORT - {transport}".format(transport=config.SENTRY_TRANSPORT)
)
exit(-1)
logger.setLevel(config.BOT_LOG_LEVEL)
......@@ -143,39 +142,39 @@ def setup_bot(backend_name, logger, config, restore=None):
getattr(config, 'PLUGINS_CALLBACK_ORDER', (None, )))
# init the backend manager & the bot
backendpm = bpm_from_config(config)
backend_plug = backendpm.get_candidate(backend_name)
backendpm = BackendPluginManager(config, 'errbot.backends', backend_name,
ErrBot, CORE_BACKENDS, getattr(config, 'BOT_EXTRA_BACKEND_DIR', []))
log.info("Found Backend plugin: '%s'\n\t\t\t\t\t\tDescription: %s" % (backend_plug.name, backend_plug.description))
log.info('Found Backend plugin: %s' % backendpm.plugin_info.name)
try:
bot = backendpm.get_plugin_by_name(backend_name)
bot = backendpm.load_plugin()
bot.attach_storage_plugin(storage_plugin)
bot.attach_repo_manager(repo_manager)
bot.attach_plugin_manager(botpm)
bot.initialize_backend_storage()
# restore the bot from the restore script
if restore:
# Prepare the context for the restore script
if 'repos' in bot:
log.fatal('You cannot restore onto a non empty bot.')
sys.exit(-1)
log.info('**** RESTORING the bot from %s' % restore)
restore_bot_from_backup(restore, bot=bot, log=log)
print('Restore complete. You can restart the bot normally')
sys.exit(0)
errors = bot.plugin_manager.update_dynamic_plugins()
if errors:
log.error('Some plugins failed to load:\n' + '\n'.join(errors.values()))
bot._plugin_errors_during_startup = "\n".join(errors.values())
return bot
except Exception:
log.exception("Unable to load or configure the backend.")
exit(-1)
# restore the bot from the restore script
if restore:
# Prepare the context for the restore script
if 'repos' in bot:
log.fatal('You cannot restore onto a non empty bot.')
sys.exit(-1)
log.info('**** RESTORING the bot from %s' % restore)
restore_bot_from_backup(restore, bot=bot, log=log)
print('Restore complete. You can restart the bot normally')
sys.exit(0)
errors = bot.plugin_manager.update_dynamic_plugins()
if errors:
log.error('Some plugins failed to load:\n' + '\n'.join(errors.values()))
bot._plugin_errors_during_startup = "\n".join(errors.values())
return bot
def restore_bot_from_backup(backup_filename, *, bot, log):
"""Restores the given bot by executing the 'backup' script.
......@@ -200,30 +199,10 @@ def get_storage_plugin(config):
"""
storage_name = getattr(config, 'STORAGE', 'Shelf')
extra_storage_plugins_dir = getattr(config, 'BOT_EXTRA_STORAGE_PLUGINS_DIR', None)
spm = SpecificPluginManager(config, 'storage', StoragePluginBase, CORE_STORAGE, extra_storage_plugins_dir)
storage_pluginfo = spm.get_candidate(storage_name)
log.info("Found Storage plugin: '%s'\nDescription: %s" % (storage_pluginfo.name, storage_pluginfo.description))
storage_plugin = spm.get_plugin_by_name(storage_name)
return storage_plugin
def bpm_from_config(config):
"""Creates a backend plugin manager from a given config."""
extra = getattr(config, 'BOT_EXTRA_BACKEND_DIR', [])
return SpecificPluginManager(
config,
'backends',
ErrBot,
CORE_BACKENDS,
extra_search_dirs=extra
)
def enumerate_backends(config):
""" Returns all the backends found for the given config.
"""
bpm = bpm_from_config(config)
return [plug.name for (_, _, plug) in bpm.getPluginCandidates()]
spm = BackendPluginManager(config, 'errbot.storage', storage_name, StoragePluginBase,
CORE_STORAGE, extra_storage_plugins_dir)
log.info('Found Storage plugin: %s.' % spm.plugin_info.name)
return spm.load_plugin()
def bootstrap(bot_class, logger, config, restore=None):
......
......@@ -3,7 +3,6 @@ from threading import RLock
from typing import Mapping, List, Tuple, Union, Callable, Any
from multiprocessing.pool import ThreadPool
from yapsy.IPlugin import IPlugin
from errbot import Message
from errbot.backends.base import Identifier, Room, RoomOccupant
......@@ -204,7 +203,7 @@ class Flow(object):
return "%s (%s) with params %s" % (self._root, self.requestor, dict(self.ctx))
class BotFlow(IPlugin):
class BotFlow:
"""
Defines a Flow plugin ie. a plugin that will define new flows from its methods with the @botflow decorator.
"""
......
......@@ -11,8 +11,6 @@ def ispydevd():
root_logger = logging.getLogger()
logging.getLogger('yapsy').setLevel(logging.INFO) # this one is way too verbose in debug
logging.getLogger('Rocket.Errors.ThreadPool').setLevel(logging.INFO) # this one is way too verbose in debug
root_logger.setLevel(logging.INFO)
pydev = ispydevd()
......
import sys
import inspect
from configparser import ConfigParser
from dataclasses import dataclass
from importlib._bootstrap import module_from_spec
from importlib._bootstrap_external import spec_from_file_location
from errbot.utils import version2tuple
from pathlib import Path
from typing import Tuple, List
from typing import Tuple, List, Type
from configparser import Error as ConfigParserError
VersionType = Tuple[int, int, int]
......@@ -74,3 +80,18 @@ class PluginInfo:
deps = [name.strip() for name in depends_on.split(',')] if depends_on else []
return PluginInfo(name, module, doc, core, python_version, min_version, max_version, deps)
def load_plugin_classes(self, base_module_name: str, baseclass: Type):
# load the module
module_name = base_module_name + '.' + self.module
spec = spec_from_file_location(module_name, self.location.parent / (self.module + '.py'))
modu1e = module_from_spec(spec)
spec.loader.exec_module(modu1e)
sys.modules[module_name] = modu1e
# introspect the modules to find plugin classes
def is_plugin(member):
return inspect.isclass(member) and issubclass(member, baseclass) and member != baseclass
plugin_classes = inspect.getmembers(modu1e, is_plugin)
return plugin_classes
......@@ -263,8 +263,6 @@ class BotPluginManager(StoreMixin):
log.warning('Plugin %s already loaded.', name)
continue
module_name = base_module_name + '.' + plugin_info.module
# save the plugin_info for ref.
dest_info_dict[name] = plugin_info
......@@ -273,16 +271,7 @@ class BotPluginManager(StoreMixin):
log.debug("%s plugin will not be loaded because it's not listed in CORE_PLUGINS", name)
continue
# load the module
spec = spec_from_file_location(module_name, plugin_info.location.parent / (plugin_info.module + '.py'))
modu1e = module_from_spec(spec)
spec.loader.exec_module(modu1e)
sys.modules[module_name] = modu1e
# introspect the modules to find plugin classes
def is_plugin(member):
return inspect.isclass(member) and issubclass(member, baseclass) and member != baseclass
plugin_classes = inspect.getmembers(modu1e, is_plugin)
plugin_classes = plugin_info.load_plugin_classes(base_module_name, baseclass)
if not plugin_classes:
feedback[path] = 'Did not find any plugin in %s.' % path
continue
......
import logging
import sys
import traceback
from yapsy.PluginManager import PluginManager
from yapsy.PluginFileLocator import PluginFileLocator, PluginFileAnalyzerWithInfoFile
from .utils import collect_roots
log = logging.getLogger(__name__)
class SpecificPluginLocator(PluginFileAnalyzerWithInfoFile):
"""
This is a plugin locator (kind of filter in yapsy jargon) to match a backend.
We have to go through hoops because yapsy is really aggressive at instanciating plugin.
(this would instantiate several bots, we don't want to do that).
"""
def __init__(self, name_to_find):
super().__init__('SpecificBackendLocator', 'plug')
self._name_to_find = name_to_find
def getInfosDictFromPlugin(self, dirpath, filename):
plugin_info_dict, config_parser = super().getInfosDictFromPlugin(dirpath, filename)
if plugin_info_dict['name'] != self._name_to_find:
# reject
return None, config_parser
return plugin_info_dict, config_parser
class SpecificPluginManager(PluginManager):
""" SpecificPluginManager is a customized plugin manager to enumerate plugins
and load only a specific one.
"""
def __init__(self, bot_config, category, base_class, base_search_dir, extra_search_dirs=()):
self._config = bot_config
# set a locator that gets every possible backends as a first discovery pass.
self._locator = PluginFileLocator(analyzers=[PluginFileAnalyzerWithInfoFile('SpecificLocator', 'plug')])
self._locator.disableRecursiveScan() # This is done below correctly with find_roots_with_extra
super().__init__(plugin_locator=self._locator)
self.setCategoriesFilter({category: base_class})
all_plugins_paths = collect_roots((base_search_dir, extra_search_dirs))
log.info('%s search paths %s', category, all_plugins_paths)
self.setPluginPlaces(all_plugins_paths)
for entry in all_plugins_paths:
if entry not in sys.path:
sys.path.append(entry) # so backends can relatively import their submodules
self.locatePlugins()
log.info('Found those plugings available:')
for (_, _, plug) in self.getPluginCandidates():
log.info('\t%10s (%s)' % (plug.name, plug.path + '.py'))
def instanciateElement(self, element):
""" Override the loading method to inject config
:param element: plugin class to load.
"""
log.debug("Class to load %s" % element.__name__)
return element(self._config)
def get_candidate(self, name):
""" Find the plugin by name.
:param name: The name of the plugin you are looking for.
:return: :raise Exception:
"""
for (_, _, plug) in self.getPluginCandidates():
if plug.name == name:
return plug
raise Exception("Plugin '%s' not found." % name)
def get_plugin_by_name(self, name):
# set a locator to narrow it to only one.
self._locator.setAnalyzers([SpecificPluginLocator(name)])
log.debug("Refilter the plugins...")
self.locatePlugins()
log.debug("Load the one remaining...")
plugins = self.loadPlugins()
if len(plugins) == 0:
raise Exception("Could not find the plugin '%s'." % name)
if len(plugins) != 1:
raise Exception("There are 2 plugins with the name '%s'." % name)
if plugins[0].error is not None:
reason = plugins[0].error
formatted_error = "%s:\n%s" % (reason[0], ''.join(traceback.format_tb(plugins[0].error[2])))
raise Exception('Error loading plugin %s:\nError:\n%s\n' % (name, formatted_error))
return plugins[0].plugin_object
......@@ -38,7 +38,6 @@ deps = ['webtest',
'jinja2',
'pyOpenSSL',
'colorlog',
'yapsy>=1.11', # new contract for plugin instantiation
'markdown', # rendering stuff
'ansi',
'Pygments>=2.0.2',
......
import logging
logger = logging.getLogger('')
logging.getLogger('yapsy').setLevel(logging.INFO) # this one is way too verbose in debug
logging.getLogger('Rocket.Errors').setLevel(logging.INFO) # this one is way too verbose in debug
logger.setLevel(logging.INFO)
logging.getLogger('').setLevel(logging.INFO)
import unittest
import logging
import pytest
from errbot.core import ErrBot
from errbot.bootstrap import CORE_BACKENDS
from errbot.specific_plugin_manager import SpecificPluginManager
from errbot.backend_plugin_manager import BackendPluginManager
logging.basicConfig(level=logging.DEBUG)
backends_to_check = ['Text', 'Test', 'Null']
def test_builtins():
bpm = SpecificPluginManager(
{},
'backends',
ErrBot,
CORE_BACKENDS,
extra_search_dirs=())
backend_plug = bpm.getPluginCandidates()
names = [plug.name for (_, _, plug) in backend_plug]
assert 'Text' in names
assert 'Test' in names
assert 'Null' in names
@pytest.mark.parametrize('backend_name', backends_to_check)
def test_builtins(backend_name):
bpm = BackendPluginManager({}, 'errbot.backends', backend_name, ErrBot, CORE_BACKENDS)
assert bpm.plugin_info.name == backend_name
......@@ -19,7 +19,7 @@ from errbot.plugin_manager import BotPluginManager
from errbot.rendering import text
from errbot.core_plugins.acls import ACLS
from errbot.repo_manager import BotRepoManager
from errbot.specific_plugin_manager import SpecificPluginManager
from errbot.backend_plugin_manager import BackendPluginManager
from errbot.storage.base import StoragePluginBase
from errbot.utils import PLUGINS_SUBDIR
......@@ -90,8 +90,8 @@ class DummyBackend(ErrBot):
self.md = text() # We just want simple text for testing purposes
# setup a memory based storage
spm = SpecificPluginManager(config, 'storage', StoragePluginBase, CORE_STORAGE, None)
storage_plugin = spm.get_plugin_by_name('Memory')
spm = BackendPluginManager(config, 'errbot.storage', 'Memory', StoragePluginBase, CORE_STORAGE)
storage_plugin = spm.load_plugin()
# setup the plugin_manager just internally
botplugins_dir = os.path.join(config.BOT_DATA_DIR, PLUGINS_SUBDIR)
......
......@@ -4,7 +4,7 @@ import pytest
from errbot.backends.test import ShallowConfig
from errbot.bootstrap import CORE_STORAGE, bot_config_defaults
from errbot.specific_plugin_manager import SpecificPluginManager
from errbot.backend_plugin_manager import BackendPluginManager
from errbot.storage.base import StoragePluginBase
from errbot.utils import *
from errbot.storage import StoreMixin
......@@ -56,8 +56,8 @@ def test_storage():
config.__dict__.update(sys.modules['errbot.config-template'].__dict__)
bot_config_defaults(config)
spm = SpecificPluginManager(config, 'storage', StoragePluginBase, CORE_STORAGE, None)
storage_plugin = spm.get_plugin_by_name('Memory')
spm = BackendPluginManager(config, 'errbot.storage', 'Memory', StoragePluginBase, CORE_STORAGE)
storage_plugin = spm.load_plugin()
persistent_object = StoreMixin()
persistent_object.open_storage(storage_plugin, 'test')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment