def __init__(self, config): self.channels = [c.split(' ', 1) for c in config['channels']] self.nickname = config['nickname'] self.password = config.get('password', None) self.history = {} self.sent_messages = {} acl_fname = config.get('acl', None) if acl_fname: # Bubble up an IOError if they passed a bad file with open(acl_fname, 'r') as acl_fd: self.acl = ACL(acl_fd.read()) log.info('Loaded ACLs from %s', acl_fname) else: self.acl = AllowAllACL() log.info('Using no-op ACLs.') self.loader = PluginLoader(config) if 'db' in config: log.info('Loading db from config: %s', config['db']) db_engine = sqlalchemy.create_engine(config['db']) else: log.info('Using in-memory db') db_engine = sqlalchemy.create_engine('sqlite:///:memory:') DBSession = orm.sessionmaker(db_engine) session = DBSession() self.loader.db = DB(db_engine, session) self.loader.loadAll()
def __init__(self, config): self.channels = [c.split(' ', 1) for c in config['channels']] self.nickname = config['nickname'] self.password = config.get('password', None) self.history = {} acl_fname = config.get('acl', None) if acl_fname: # Bubble up an IOError if they passed a bad file with open(acl_fname, 'r') as acl_fd: self.acl = ACL(acl_fd.read()) log.info('Loaded ACLs from %s', acl_fname) else: self.acl = AllowAllACL() log.info('Using no-op ACLs.') self.loader = PluginLoader(config) if 'db' in config: log.info('Loading db from config: %s', config['db']) db_engine = sqlalchemy.create_engine(config['db']) else: log.info('Using in-memory db') db_engine = sqlalchemy.create_engine('sqlite:///:memory:') DBSession = orm.sessionmaker(db_engine) session = DBSession() self.loader.db = DB(db_engine, session) self.loader.loadAll()
def main(): config = hamper.config.load() hamper.log.setup_logging() if config.get('ssl', False): reactor.connectSSL( config['server'], config['port'], CommanderFactory(config), ssl.ClientContextFactory()) else: reactor.connectTCP( config['server'], config['port'], CommanderFactory(config)) reactor.run()
def main(): config = hamper.config.load() hamper.log.setup_logging() if config.get('ssl', False): reactor.connectSSL(config['server'], config['port'], CommanderFactory(config), ssl.ClientContextFactory()) else: reactor.connectTCP(config['server'], config['port'], CommanderFactory(config)) reactor.run()
def __init__(self, config): self.channels = [c.split(' ', 1) for c in config['channels']] self.nickname = config['nickname'] self.password = config.get('password', None) self.history = {} acl_fname = config.get('acl', None) if acl_fname: # Bubble up an IOError if they passed a bad file with open(acl_fname, 'r') as acl_fd: self.acl = ACL(acl_fd.read()) else: self.acl = AllowAllACL() self.loader = PluginLoader() self.loader.config = config if 'db' in config: print('Loading db from config: ' + config['db']) db_engine = sqlalchemy.create_engine(config['db']) else: print('Using in-memory db') db_engine = sqlalchemy.create_engine('sqlite:///:memory:') DBSession = orm.sessionmaker(db_engine) session = DBSession() self.loader.db = DB(db_engine, session) # Load all plugins mentioned in the configuration. Allow globbing. config_matches = set() for plugin in getPlugins(BaseInterface, package=plugins): for pattern in config['plugins']: if fnmatch(plugin.name, pattern): self.loader.registerPlugin(plugin) config_matches.add(pattern) break for pattern in config['plugins']: if pattern not in config_matches: log.warning('No plugin matched pattern "%s"', pattern)