当前位置: 首页>>代码示例>>Python>>正文


Python log.msg函数代码示例

本文整理汇总了Python中vumi.log.msg函数的典型用法代码示例。如果您正苦于以下问题:Python msg函数的具体用法?Python msg怎么用?Python msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: render_

 def render_(self, request):
     log.msg("Send request: %s" % (request,))
     request.setHeader("content-type", "application/json; charset=utf-8")
     d = self.application.handle_raw_outbound_message(request)
     d.addCallback(lambda msgs: self.finish_request(request, msgs))
     d.addErrback(lambda f: self.fail_request(request, f))
     return NOT_DONE_YET
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:7,代码来源:rapidsms_relay.py

示例2: handle_event

    def handle_event(self, event, handler_config):
        sms_copy = handler_config['sms_copy']
        conversation_key = handler_config['conversation_key']

        account_key = event['account_key']
        from_addr = event['content']['from_addr']

        user_api = self.get_user_api(account_key)
        contact = yield self.find_contact(account_key, from_addr)

        if not contact:
            log.msg('Unable to find contact for %s' % (from_addr,))
            return

        content = (sms_copy['swahili'] if contact.extra['language'] == '2'
                    else sms_copy['english'])

        conversation = yield user_api.get_wrapped_conversation(
                                                conversation_key)

        yield conversation.dispatch_command(
            'send_message', account_key, conversation.key,
            command_data={
                'batch_id': conversation.batch.key,
                'to_addr': from_addr,
                'content': content,
                'msg_options': {},
            }
        )
开发者ID:ChrisNolan1992,项目名称:vumi-go,代码行数:29,代码来源:handlers.py

示例3: handle_inbound_text_message

    def handle_inbound_text_message(self, request, wc_msg):
        double_delivery = yield self.check_for_double_delivery(
            request, wc_msg.msg_id)
        if double_delivery:
            log.msg('WeChat double delivery of message: %s' % (wc_msg.msg_id,))
            return

        lock = yield self.mark_as_seen_recently(wc_msg.msg_id)
        if not lock:
            log.msg('Unable to get lock for message id: %s' % (wc_msg.msg_id,))
            return

        config = self.get_static_config()
        if config.embed_user_profile:
            user_profile = yield self.get_user_profile(wc_msg.from_user_name)
        else:
            user_profile = {}

        mask = yield self.get_addr_mask(wc_msg.from_user_name)
        msg = yield self.publish_message(
            content=wc_msg.content,
            from_addr=wc_msg.from_user_name,
            to_addr=self.mask_addr(wc_msg.to_user_name, mask),
            timestamp=datetime.fromtimestamp(int(wc_msg.create_time)),
            transport_type=self.transport_type,
            transport_metadata={
                'wechat': {
                    'FromUserName': wc_msg.from_user_name,
                    'ToUserName': wc_msg.to_user_name,
                    'MsgType': 'text',
                    'MsgId': wc_msg.msg_id,
                    'UserProfile': user_profile,
                }
            })
        returnValue(msg)
开发者ID:caiobertacco,项目名称:vumi,代码行数:35,代码来源:wechat.py

示例4: handle_raw_inbound_message

    def handle_raw_inbound_message(self, message_id, request):
        values, errors = self.get_field_values(request, self.EXPECTED_FIELDS)

        channel = values.get('channel')
        if channel is not None and channel not in self.CHANNEL_LOOKUP.values():
            errors['unsupported_channel'] = channel

        if errors:
            log.msg('Unhappy incoming message: %s' % (errors,))
            yield self.finish_request(message_id, json.dumps(errors),
                                      code=http.BAD_REQUEST)
            return

        self.emit("AppositTransport receiving inbound message from "
                  "%(from)s to %(to)s" % values)

        yield self.publish_message(
            transport_name=self.transport_name,
            message_id=message_id,
            content=values['content'],
            from_addr=values['from'],
            to_addr=values['to'],
            provider='apposit',
            transport_type=self.TRANSPORT_TYPE_LOOKUP[channel],
            transport_metadata={'apposit': {'isTest': values['isTest']}})

        yield self.finish_request(
            message_id, json.dumps({'message_id': message_id}))
开发者ID:Nagato23,项目名称:vumi,代码行数:28,代码来源:apposit.py

示例5: deliver_sm

    def deliver_sm(self, *args, **kwargs):
        message_type = kwargs.get('message_type', 'sms')
        message = {
            'message_id': kwargs['message_id'],
            'to_addr': kwargs['destination_addr'],
            'from_addr': kwargs['source_addr'],
            'content': kwargs['short_message'],
            'transport_type': message_type,
            'transport_metadata': {},
            }

        if message_type == 'ussd':
            session_event = {
                'new': TransportUserMessage.SESSION_NEW,
                'continue': TransportUserMessage.SESSION_RESUME,
                'close': TransportUserMessage.SESSION_CLOSE,
                }[kwargs['session_event']]
            message['session_event'] = session_event
            session_info = kwargs.get('session_info')
            message['transport_metadata']['session_info'] = session_info

        log.msg("PUBLISHING INBOUND: %s" % (message,))
        # TODO: This logs messages that fail to serialize to JSON
        #       Usually this happens when an SMPP message has content
        #       we can't decode (e.g. data_coding == 4). We should
        #       remove the try-except once we handle such messages
        #       better.
        return self.publish_message(**message).addErrback(log.err)
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:28,代码来源:transport.py

示例6: switch_to_counters

    def switch_to_counters(self, batch_id):
        """
        Actively switch a batch from the old ``zcard()`` based approach
        to the new ``redis.incr()`` counter based approach.
        """
        uses_counters = yield self.uses_counters(batch_id)
        if uses_counters:
            log.msg('Batch %r has already switched to counters.' % (
                batch_id,))
            return

        # NOTE:     Under high load this may result in the counter being off
        #           by a few. Considering this is a cache that is to be
        #           reconciled we're happy for that to be the case.
        inbound_count = yield self.count_inbound_message_keys(batch_id)
        outbound_count = yield self.count_outbound_message_keys(batch_id)

        # We do `*_count or None` because there's a chance of getting back
        # a None if this is a new batch that's not received any traffic yet.
        yield self.redis.set(self.inbound_count_key(batch_id),
                             inbound_count or 0)
        yield self.redis.set(self.outbound_count_key(batch_id),
                             outbound_count or 0)

        yield self.truncate_inbound_message_keys(batch_id)
        yield self.truncate_outbound_message_keys(batch_id)
开发者ID:areski,项目名称:vumi,代码行数:26,代码来源:message_store_cache.py

示例7: handle_outbound_message

    def handle_outbound_message(self, message):
        metadata = message['transport_metadata']['mtn_nigeria_ussd']

        try:
            self.validate_outbound_message(message)
        except CodedXmlOverTcpError as e:
            log.msg(e)
            yield self.publish_nack(message['message_id'], "%s" % e)
            yield self.factory.client.send_error_response(
                metadata.get('session_id'),
                message.payload.get('in_reply_to'),
                e.code)
            return

        log.msg(
            'MtnNigeriaUssdTransport sending outbound message: %s' % message)

        end_session = (
            message['session_event'] == TransportUserMessage.SESSION_CLOSE)
        yield self.send_response(
            message_id=message['message_id'],
            session_id=metadata['session_id'],
            request_id=metadata['requestId'],
            star_code=metadata['starCode'],
            client_id=metadata['clientId'],
            msisdn=message['to_addr'],
            user_data=message['content'].encode(self.ENCODING),
            end_session=end_session)
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:28,代码来源:mtn_nigeria_ussd.py

示例8: handle_raw_inbound_message

    def handle_raw_inbound_message(self, msgid, request):
        parts = request.path.split('/')
        session_id = parts[-2]
        session_method = parts[-1]
        session_event, session_handler_name, sends_json = (
            self.METHOD_TO_HANDLER.get(session_method,
                                       (TransportUserMessage.SESSION_NONE,
                                       "handle_infobip_error", False)))
        session_handler = getattr(self, session_handler_name)
        req_content = request.content.read()
        log.msg("Incoming message: %r" % (req_content,))
        if sends_json:
            try:
                req_data = json.loads(req_content)
            except ValueError:
                # send bad JSON to error handler
                session_handler = self.handle_infobip_error
                req_data = {"error": "Invalid JSON"}
        else:
            req_data = {}

        message_dict = yield session_handler(msgid, session_id, req_data)
        if message_dict is not None:
            transport_metadata = {'session_id': session_id}
            message_dict.setdefault("message_id", msgid)
            message_dict.setdefault("session_event", session_event)
            message_dict.setdefault("content", None)
            message_dict["transport_name"] = self.transport_name
            message_dict["transport_type"] = self.config.get('transport_type',
                                                             'ussd')
            message_dict["transport_metadata"] = transport_metadata
            self.publish_message(**message_dict)
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:32,代码来源:infobip.py

示例9: stopWorker

 def stopWorker(self):
     log.msg("HeartBeat: stopping worker")
     if self._task:
         self._task.stop()
         self._task = None
         yield self._task_done
     self._redis.close_manager()
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:7,代码来源:monitor.py

示例10: setup_transport

    def setup_transport(self):
        config = self.get_static_config()
        log.msg('Starting SMPP Transport for: %s' % (config.twisted_endpoint,))

        default_prefix = '%[email protected]%s' % (config.system_id,
                                    config.transport_name)
        redis_prefix = config.split_bind_prefix or default_prefix
        self.redis = (yield TxRedisManager.from_config(
            config.redis_manager)).sub_manager(redis_prefix)

        self.dr_processor = config.delivery_report_processor(
            self, config.delivery_report_processor_config)
        self.deliver_sm_processor = config.deliver_short_message_processor(
            self, config.deliver_short_message_processor_config)
        self.submit_sm_processor = config.submit_short_message_processor(
            self, config.submit_short_message_processor_config)

        self.sequence_generator = self.sequence_class(self.redis)
        self.message_stash = SmppMessageDataStash(self.redis, config)
        self.throttled = None
        self._throttled_message_ids = []
        self._unthrottle_delayedCall = None
        self.factory = self.factory_class(self)

        self.service = self.start_service(self.factory)

        self.tps_counter = 0
        self.tps_limit = config.mt_tps
        if config.mt_tps > 0:
            self.mt_tps_lc = LoopingCall(self.reset_mt_tps)
            self.mt_tps_lc.clock = self.clock
            self.mt_tps_lc.start(1, now=True)
        else:
            self.mt_tps_lc = None
开发者ID:Nagato23,项目名称:vumi,代码行数:34,代码来源:smpp_transport.py

示例11: handle_raw_inbound_message

    def handle_raw_inbound_message(self, request_id, request):
        values, errors = self.get_field_values(request, self.EXPECTED_FIELDS)
        if errors:
            log.msg('Unhappy incoming message: %r' % (errors,))
            self.finish_request(
                request_id, json.dumps(errors), code=http.BAD_REQUEST)
            return

        to_addr = values["ussdServiceCode"]
        from_addr = values["msisdn"]
        session_event = yield self.session_event_for_transaction(
            values["transactionId"])

        yield self.publish_message(
            message_id=request_id,
            content=values["ussdRequestString"],
            to_addr=to_addr,
            from_addr=from_addr,
            provider='dmark',
            session_event=session_event,
            transport_type=self.transport_type,
            transport_metadata={
                'dmark_ussd': {
                    'transaction_id': values['transactionId'],
                    'transaction_time': values['transactionTime'],
                    'creation_time': values['creationTime'],
                }
            })
开发者ID:Nagato23,项目名称:vumi,代码行数:28,代码来源:dmark_ussd.py

示例12: finish_expired_request

 def finish_expired_request(self, request_id, request):
     """
     Called on requests that timed out.
     """
     del self._requests[request_id]
     log.msg('Timing out on response for %s' % request.session['from_addr'])
     request.deferred.callback(self.response_for_error())
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:7,代码来源:transport.py

示例13: reset_mt_tps

 def reset_mt_tps(self):
     if self.throttled and self.need_mt_throttling():
         if not self.service.is_bound():
             # We don't have a bound SMPP connection, so try again later.
             log.msg("Can't stop throttling while unbound, trying later.")
             return
         self.reset_mt_throttle_counter()
         self.stop_throttling(quiet=True)
开发者ID:Nagato23,项目名称:vumi,代码行数:8,代码来源:smpp_transport.py

示例14: connectionMade

 def connectionMade(self):
     self.state = 'OPEN'
     log.msg('STATE: %s' % (self.state))
     seq = yield self.get_next_seq()
     pdu = self.BIND_PDU(seq, **self.bind_params)
     log.msg(pdu.get_obj())
     self.send_pdu(pdu)
     self.schedule_lose_connection(self.CONNECTED_STATE)
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:8,代码来源:client.py

示例15: handle_enquire_link

 def handle_enquire_link(self, pdu):
     if pdu['header']['command_status'] == 'ESME_ROK':
         log.msg("enquire_link OK")
         sequence_number = pdu['header']['sequence_number']
         pdu_resp = EnquireLinkResp(sequence_number)
         self.send_pdu(pdu_resp)
     else:
         log.msg("enquire_link NOT OK: %r" % (pdu,))
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:8,代码来源:client.py


注:本文中的vumi.log.msg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。