def __init__(self, extra_config=None): self.outgoing_message_queue = Queue() if extra_config is None: extra_config = {} # make up a config. tempdir = mkdtemp() # reset the config every time sys.modules.pop('errbot.config-template', None) __import__('errbot.config-template') config = ShallowConfig() config.__dict__.update(sys.modules['errbot.config-template'].__dict__) bot_config_defaults(config) # It injects itself as a plugin. Changed the name to be sure we distinguish it. self.name = 'DummyBackendRealName' config.BOT_DATA_DIR = tempdir config.BOT_LOG_FILE = tempdir + sep + 'log.txt' config.BOT_PLUGIN_INDEXES = tempdir + sep + 'repos.json' config.BOT_EXTRA_PLUGIN_DIR = [] config.BOT_LOG_LEVEL = logging.DEBUG config.BOT_IDENTITY = {'username': '******'} config.BOT_ASYNC = False config.BOT_PREFIX = '!' config.CHATROOM_FN = 'blah' # Writeout the made up repos file with open(config.BOT_PLUGIN_INDEXES, "w") as index_file: index_file.write(SIMPLE_JSON_PLUGINS_INDEX) for key in extra_config: setattr(config, key, extra_config[key]) super().__init__(config) self.bot_identifier = self.build_identifier('err') 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') # setup the plugin_manager just internally botplugins_dir = os.path.join(config.BOT_DATA_DIR, PLUGINS_SUBDIR) if not os.path.exists(botplugins_dir): os.makedirs(botplugins_dir, mode=0o755) # get it back from where we publish it. repo_index_paths = (os.path.join(os.path.dirname(__file__), '..', 'docs', '_extra', 'repos.json'),) repo_manager = BotRepoManager(storage_plugin, botplugins_dir, repo_index_paths) self.attach_storage_plugin(storage_plugin) self.attach_repo_manager(repo_manager) self.attach_plugin_manager(BotPluginManager(storage_plugin, repo_manager, config.BOT_EXTRA_PLUGIN_DIR, config.AUTOINSTALL_DEPS, getattr(config, 'CORE_PLUGINS', None), getattr(config, 'PLUGINS_CALLBACK_ORDER', (None, )))) self.inject_commands_from(self) self.inject_command_filters_from(ACLS(self))
def __init__(self, extra_config=None): self.outgoing_message_queue = Queue() if extra_config is None: extra_config = {} # make up a config. tempdir = mkdtemp() # reset the config every time sys.modules.pop('errbot.config-template', None) __import__('errbot.config-template') config = sys.modules['errbot.config-template'] bot_config_defaults(config) config.BOT_DATA_DIR = tempdir config.BOT_LOG_FILE = tempdir + sep + 'log.txt' config.BOT_EXTRA_PLUGIN_DIR = [] config.BOT_LOG_LEVEL = logging.DEBUG config.BOT_IDENTITY = {'username': '******'} config.BOT_ASYNC = False config.BOT_PREFIX = '!' config.CHATROOM_FN = 'blah' for key in extra_config: setattr(config, key, extra_config[key]) super().__init__(config) self.bot_identifier = self.build_identifier('err') self.inject_commands_from(self) self.inject_command_filters_from(ACLS(self)) self.md = text() # We just want simple text for testing purposes
def __init__(self, extra_config=None): self.outgoing_message_queue = Queue() if extra_config is None: extra_config = {} # make up a config. tempdir = mkdtemp() # reset the config every time sys.modules.pop('errbot.config-template', None) __import__('errbot.config-template') config = sys.modules['errbot.config-template'] bot_config_defaults(config) config.BOT_DATA_DIR = tempdir config.BOT_LOG_FILE = tempdir + sep + 'log.txt' config.BOT_EXTRA_PLUGIN_DIR = [] config.BOT_LOG_LEVEL = logging.DEBUG config.BOT_IDENTITY = {'username': '******'} config.BOT_ASYNC = False config.BOT_PREFIX = '!' config.CHATROOM_FN = 'blah' for key in extra_config: setattr(config, key, extra_config[key]) super().__init__(config) self.bot_identifier = self.build_identifier('err') 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') # setup the plugin_manager just internally botplugins_dir = os.path.join(config.BOT_DATA_DIR, PLUGINS_SUBDIR) if not os.path.exists(botplugins_dir): os.makedirs(botplugins_dir, mode=0o755) self.attach_plugin_manager( BotPluginManager(storage_plugin, botplugins_dir, config.BOT_EXTRA_PLUGIN_DIR, config.AUTOINSTALL_DEPS, getattr(config, 'CORE_PLUGINS', None))) self.attach_storage_plugin(storage_plugin) self.inject_commands_from(self) self.inject_command_filters_from(ACLS(self))
def __init__(self, extra_config=None): self.outgoing_message_queue = Queue() if extra_config is None: extra_config = {} # make up a config. tempdir = mkdtemp() # reset the config every time sys.modules.pop("errbot.config-template", None) __import__("errbot.config-template") config = ShallowConfig() config.__dict__.update(sys.modules["errbot.config-template"].__dict__) bot_config_defaults(config) # It injects itself as a plugin. Changed the name to be sure we distinguish it. self.name = "DummyBackendRealName" config.BOT_DATA_DIR = tempdir config.BOT_LOG_FILE = tempdir + sep + "log.txt" config.BOT_PLUGIN_INDEXES = tempdir + sep + "repos.json" config.BOT_EXTRA_PLUGIN_DIR = [] config.BOT_LOG_LEVEL = logging.DEBUG config.BOT_IDENTITY = {"username": "******"} config.BOT_ASYNC = False config.BOT_PREFIX = "!" config.CHATROOM_FN = "blah" # Writeout the made up repos file with open(config.BOT_PLUGIN_INDEXES, "w") as index_file: index_file.write(SIMPLE_JSON_PLUGINS_INDEX) for key in extra_config: setattr(config, key, extra_config[key]) super().__init__(config) self.bot_identifier = self.build_identifier("err") self.md = text() # We just want simple text for testing purposes # setup a memory based storage 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) if not os.path.exists(botplugins_dir): os.makedirs(botplugins_dir, mode=0o755) # get it back from where we publish it. repo_index_paths = (os.path.join(os.path.dirname(__file__), "..", "docs", "_extra", "repos.json"), ) repo_manager = BotRepoManager(storage_plugin, botplugins_dir, repo_index_paths) self.attach_storage_plugin(storage_plugin) self.attach_repo_manager(repo_manager) self.attach_plugin_manager( BotPluginManager( storage_plugin, config.BOT_EXTRA_PLUGIN_DIR, config.AUTOINSTALL_DEPS, getattr(config, "CORE_PLUGINS", None), lambda name, clazz: clazz(self, name), getattr(config, "PLUGINS_CALLBACK_ORDER", (None, )), )) self.inject_commands_from(self) self.inject_command_filters_from(ACLS(self))