def __init__(self, callback_function=None, role='client', **kwargs): self._configured = False self.role = role if kwargs.has_key("config"): self._configure(kwargs["config"]) self._configured = True if kwargs.has_key("loglevel"): log_level = kwargs["loglevel"] elif self._configured is True and self._config.has_option('global', 'log_level'): log_level = self._config.get('global', 'log_level') else: log_level = 'WARN' self.log = logger.LogWrapper(name='vogeler-%s' % self.role).logger() if kwargs.has_key("dsn"): _dsn = kwargs["dsn"] elif self._configured is True and self._config.has_option('amqp', 'dsn'): _dsn = self._config.get('amqp', 'dsn') else: error = "No dsn provided. Cannot continue" self.log.fatal(error) raise exceptions.VogelerMessagingException(error) try: self.ch, self.queue = amqp.setup_server(_dsn) self.callback_function = callback_function except Exception, e: error = "Error connecting to %s" % _dsn self.log.fatal(error) raise e
def __init__(self, callback_function=None, role='client', **kwargs): self._configured = False self.role = role if kwargs.has_key("config"): self._configure(kwargs["config"]) self._configured = True if kwargs.has_key("loglevel"): log_level = kwargs["loglevel"] elif self._configured is True and self._config.has_option( 'global', 'log_level'): log_level = self._config.get('global', 'log_level') else: log_level = 'WARN' self.log = logger.LogWrapper(name='vogeler-%s' % self.role).logger() if kwargs.has_key("dsn"): _dsn = kwargs["dsn"] elif self._configured is True and self._config.has_option( 'amqp', 'dsn'): _dsn = self._config.get('amqp', 'dsn') else: error = "No dsn provided. Cannot continue" self.log.fatal(error) raise exceptions.VogelerMessagingException(error) try: self.ch, self.queue = amqp.setup_server(_dsn) self.callback_function = callback_function except Exception, e: error = "Error connecting to %s" % _dsn self.log.fatal(error) raise e
def __init__(self, callback_function=None, **kwargs): try: self.ch, self.queue = amqp.setup_server(kwargs['host'], kwargs['username'], kwargs['password']) self.callback_function = callback_function except: raise VogelerServerException("Unable to connect to messaging system on %s as %s" % (kwargs['host'], kwargs['username']))