Exemplo n.º 1
0
    def startWorker(self):
        log.msg("Starting the SmppTransport with %s" % self.config)

        # TODO: move this to a config file
        dbindex = get_deploy_int(self._amqp_client.vhost)
        self.smpp_offset = int(self.config['smpp_offset'])
        self.transport_name = self.config.get('TRANSPORT_NAME', 'fallback')

        # Connect to Redis
        self.r_server = redis.Redis("localhost", db=dbindex)
        self.r_prefix = "%(system_id)s@%(host)s:%(port)s" % self.config
        log.msg("Connected to Redis, prefix: %s" % self.r_prefix)
        last_sequence_number = int(self.r_get_last_sequence()
                                   or self.smpp_offset)
        log.msg("Last sequence_number: %s" % last_sequence_number)

        # start the Smpp transport
        factory = EsmeTransceiverFactory(self.config,
                                            self._amqp_client.vumi_options)
        factory.loadDefaults(self.config)
        factory.setLastSequenceNumber(last_sequence_number)
        factory.setConnectCallback(self.esme_connected)
        factory.setDisconnectCallback(self.esme_disconnected)
        factory.setSubmitSMRespCallback(self.submit_sm_resp)
        factory.setDeliveryReportCallback(self.delivery_report)
        factory.setDeliverSMCallback(self.deliver_sm)
        factory.setSendFailureCallback(self.send_failure)
        log.msg(factory.defaults)
        reactor.connectTCP(
                factory.defaults['host'],
                factory.defaults['port'],
                factory)
Exemplo n.º 2
0
    def startWorker(self):
        self.session_manager = SessionManager(
            get_deploy_int(self._amqp_client.vhost),
            "%(worker_name)s:%(transport_name)s" % self.config,
            max_session_length=self.MAX_SESSION_LENGTH)

        yield super(WikipediaWorker, self).startWorker()
Exemplo n.º 3
0
    def setup_transport(self):
        log.msg("Starting the SmppTransport with %s" % self.config)

        # TODO: move this to a config file
        dbindex = get_deploy_int(self._amqp_client.vhost)
        self.smpp_offset = int(self.config['smpp_offset'])

        # Connect to Redis
        if not hasattr(self, 'r_server'):
            # Only set up redis if we don't have a test stub already
            self.r_server = redis.Redis("localhost", db=dbindex)
        self.r_prefix = "%(system_id)s@%(host)s:%(port)s" % self.config
        log.msg("Connected to Redis, prefix: %s" % self.r_prefix)
        last_sequence_number = int(self.r_get_last_sequence()
                                   or self.smpp_offset)
        log.msg("Last sequence_number: %s" % last_sequence_number)

        if not hasattr(self, 'esme_client'):
            # start the Smpp transport (if we don't have one)
            factory = EsmeTransceiverFactory(self.config,
                                             self._amqp_client.vumi_options)
            factory.loadDefaults(self.config)
            factory.setLastSequenceNumber(last_sequence_number)
            factory.setConnectCallback(self.esme_connected)
            factory.setDisconnectCallback(self.esme_disconnected)
            factory.setSubmitSMRespCallback(self.submit_sm_resp)
            factory.setDeliveryReportCallback(self.delivery_report)
            factory.setDeliverSMCallback(self.deliver_sm)
            factory.setSendFailureCallback(self.send_failure)
            log.msg(factory.defaults)
            reactor.connectTCP(
                factory.defaults['host'],
                factory.defaults['port'],
                factory)
Exemplo n.º 4
0
    def setup_transport(self):
        log.msg('Starting the OperaInboundTransport config: %s' %
            self.transport_name)

        dbindex = get_deploy_int(self._amqp_client.vhost)
        redis_config = self.config.get('redis', {})
        self.r_server = yield redis.Redis(db=dbindex, **redis_config)
        self.r_prefix = "%(transport_name)s@%(url)s" % self.config

        self.proxy = xmlrpc.Proxy(self.opera_url)
        self.default_values = {
            'Service': self.opera_service,
            'Password': self.opera_password,
            'Channel': self.opera_channel,
        }

        # start receipt web resource
        self.web_resource = yield self.start_web_resources(
            [
                (OperaReceiptResource(self.handle_raw_incoming_receipt),
                 self.web_receipt_path),
                (OperaReceiveResource(self.publish_message),
                 self.web_receive_path),
                (OperaHealthResource(), 'health'),
            ],
            self.web_port
        )
Exemplo n.º 5
0
 def setup_transport(self):
     log.msg('Setting up transport')
     dbindex = get_deploy_int(self._amqp_client.vhost)
     redis_config = self.config.get('redis', {})
     self.r_server = yield redis.Redis(db=dbindex, **redis_config)
     self.r_prefix = "%(transport_name)s" % self.config
     self.start_polling()
Exemplo n.º 6
0
 def __init__(self, seq, config, vumi_options):
     self.build_maps()
     self.name = 'Proto' + str(seq)
     log.msg('__init__', self.name)
     self.defaults = {}
     self.state = 'CLOSED'
     log.msg(self.name, 'STATE :', self.state)
     self.seq = seq
     self.config = config
     self.vumi_options = vumi_options
     self.inc = int(self.config['smpp_increment'])
     self.incSeq()
     self.datastream = ''
     self.__connect_callback = None
     self.__submit_sm_resp_callback = None
     self.__delivery_report_callback = None
     self.__deliver_sm_callback = None
     self._send_failure_callback = None
     self.error_handlers = {
             "ok": self.dummy_ok,
             "mess_permfault": self.dummy_mess_permfault,
             "mess_tempfault": self.dummy_mess_tempfault,
             "conn_permfault": self.dummy_conn_permfault,
             "conn_tempfault": self.dummy_conn_tempfault,
             "conn_throttle": self.dummy_conn_throttle,
             }
     self.r_server = redis.Redis("localhost",
             db=get_deploy_int(self.vumi_options['vhost']))
     log.msg("Connected to Redis")
     self.r_prefix = "%s@%s:%s" % (
             self.config['system_id'],
             self.config['host'],
             self.config['port'])
     log.msg("r_prefix = %s" % self.r_prefix)
Exemplo n.º 7
0
 def set_up_redis(self):
     if not hasattr(self, 'r_server'):
         self.r_server = redis.Redis(
             "localhost", db=get_deploy_int(self._amqp_client.vhost))
     log.msg("Connected to Redis")
     self.r_prefix = "failures:%s" % (self.config['transport_name'],)
     log.msg("r_prefix = %s" % self.r_prefix)
     self._retry_timestamps_key = self.r_key("retry_timestamps")
Exemplo n.º 8
0
 def setup_transport(self):
     # TODO: get_deploy_int must die
     dbindex = get_deploy_int(self._amqp_client.vhost)
     self.r_server = yield redis.Redis(db=dbindex, **self.r_config)
     consumer = oauth.OAuthConsumer(self.consumer_key, self.consumer_secret)
     token = oauth.OAuthToken(self.access_token, self.access_token_secret)
     self.twitter = twitter.TwitterFeed(consumer=consumer, token=token)
     yield self.start_tracking_terms()
     self.start_checking_for_replies()
Exemplo n.º 9
0
 def setup_transport(self):
     yield super(InfobipTransport, self).setup_transport()
     self.r_server = redis.Redis("localhost",
                                 db=get_deploy_int(self._amqp_client.vhost))
     log.msg("Connected to Redis")
     self.r_prefix = "infobip:%s" % (self.transport_name,)
     log.msg("r_prefix = %s" % self.r_prefix)
     self.r_session_timeout = int(self.config.get("ussd_session_timeout",
                                                  600))
Exemplo n.º 10
0
    def startWorker(self):
        """Start the worker"""
        # Connect to Redis
        self.r_server = redis.Redis("localhost", db=get_deploy_int(self._amqp_client.vhost))
        log.msg("Connected to Redis")
        self.r_prefix = "hangman:%s:%s" % (self.config["transport_name"], self.config["worker_name"])
        log.msg("r_prefix = %s" % self.r_prefix)
        self.random_word_url = self.config["random_word_url"]
        log.msg("random_word_url = %s" % self.random_word_url)

        yield super(HangmanWorker, self).startWorker()
Exemplo n.º 11
0
    def startWorker(self):
        self.sms_transport = self.config.get("sms_transport", None)
        self.override_sms_address = self.config.get("override_sms_address", None)
        db = get_deploy_int(self._amqp_client.vhost)
        self.r_server = redis.Redis("localhost", db=db)
        self.session_manager = SessionManager(
            self.r_server,
            "%(worker_name)s:%(transport_name)s" % self.config,
            max_session_length=self.MAX_SESSION_LENGTH,
        )

        yield super(WikipediaWorker, self).startWorker()
Exemplo n.º 12
0
 def __init__(self, publisher):
     self.publisher = publisher
     if hasattr(publisher, 'vumi_options'):
         self.vhost = publisher.vumi_options.get('vhost', self.vhost)
     self.r_server = redis.Redis("localhost", db=get_deploy_int(self.vhost))