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


Python log.warning函数代码示例

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


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

示例1: handle_PUT_in_reply_to

    def handle_PUT_in_reply_to(self, request, payload, in_reply_to):
        user_account = request.getUser()
        conversation = yield self.get_conversation(user_account)

        reply_to = yield self.vumi_api.mdb.get_inbound_message(in_reply_to)
        if reply_to is None:
            self.client_error_response(request, 'Invalid in_reply_to value')
            return

        reply_to_mdh = MessageMetadataHelper(self.vumi_api, reply_to)
        try:
            msg_conversation_key = reply_to_mdh.get_conversation_key()
        except KeyError:
            log.warning('Invalid reply to message %r which has no conversation'
                        ' key' % (reply_to,))
            msg_conversation_key = None
        if msg_conversation_key != conversation.key:
            self.client_error_response(request, 'Invalid in_reply_to value')
            return

        msg_options = ReplyToOptions(payload)
        if not msg_options.is_valid:
            self.client_error_response(request, msg_options.error_msg)
            return

        continue_session = (msg_options.session_event
                            != TransportUserMessage.SESSION_CLOSE)
        helper_metadata = conversation.set_go_helper_metadata()
        helper_metadata.update(self.get_load_balancer_metadata(payload))

        msg = yield self.worker.reply_to(
            reply_to, msg_options.content, continue_session,
            helper_metadata=helper_metadata)

        self.successful_send_response(request, msg)
开发者ID:ChrisNolan1992,项目名称:vumi-go,代码行数:35,代码来源:resource.py

示例2: send_message_to_client

 def send_message_to_client(self, message, conversation, push_url):
     if push_url is None:
         log.warning(
             "push_message_url not configured for conversation: %s" % (
                 conversation.key))
         return
     return self.push(push_url, message)
开发者ID:ChrisNolan1992,项目名称:vumi-go,代码行数:7,代码来源:vumi_app.py

示例3: _handle_receive

    def _handle_receive(self, message_id, request):
        if not self._check_request_args(request, ["secret", "sent_timestamp", "sent_to", "from", "message"]):
            log.warning("Bad request: %r (args: %r)" % (request, request.args))
            yield self._send_response(message_id, success=self.SMSSYNC_FALSE)
            return
        msginfo = yield self.msginfo_for_request(request)
        supplied_secret = request.args["secret"][0]
        if msginfo is None or (msginfo.smssync_secret and not msginfo.smssync_secret == supplied_secret):
            log.warning("Bad secret or account: %r (args: %r)" % (request, request.args))
            yield self._send_response(message_id, success=self.SMSSYNC_FALSE)
            return

        timestamp = self._parse_timestamp(request)

        normalize = lambda raw: normalize_msisdn(raw, msginfo.country_code)
        message = {
            "message_id": message_id,
            "transport_type": self.transport_type,
            "to_addr": normalize(request.args["sent_to"][0]),
            "from_addr": normalize(request.args["from"][0]),
            "content": request.args["message"][0],
            "timestamp": timestamp,
        }
        self.add_msginfo_metadata(message, msginfo)
        yield self.publish_message(**message)
        self.callLater(
            self._reply_delay, self._respond_with_pending_messages, msginfo, message_id, success=self.SMSSYNC_TRUE
        )
开发者ID:caiobertacco,项目名称:vumi,代码行数:28,代码来源:smssync.py

示例4: process_command_send_message

    def process_command_send_message(self, user_account_key, conversation_key,
                                     command_data, **kwargs):
        if kwargs:
            log.info("Received unexpected command args: %s" % (kwargs,))
        conv = yield self.get_conversation(user_account_key, conversation_key)
        if conv is None:
            log.warning("Cannot find conversation '%s' for user '%s'." % (
                conversation_key, user_account_key))
            return

        log.info('Processing send_message: %s' % kwargs)
        to_addr = command_data['to_addr']
        content = command_data['content']
        msg_options = command_data['msg_options']
        in_reply_to = msg_options.pop('in_reply_to', None)
        self.add_conv_to_msg_options(conv, msg_options)
        if in_reply_to:
            msg = yield self.vumi_api.mdb.get_inbound_message(in_reply_to)
            if msg:
                yield self.reply_to(
                    msg, content,
                    helper_metadata=msg_options['helper_metadata'])
            else:
                log.warning('Unable to reply, message %s does not exist.' % (
                    in_reply_to))
        else:
            yield self.send_to(
                to_addr, content, endpoint='default', **msg_options)
开发者ID:TouK,项目名称:vumi-go,代码行数:28,代码来源:app_worker.py

示例5: push

    def push(self, url, vumi_message):
        config = self.get_static_config()
        data = vumi_message.to_json().encode('utf-8')
        try:
            auth, url = extract_auth_from_url(url.encode('utf-8'))
            headers = {
                'Content-Type': 'application/json; charset=utf-8',
            }
            if auth is not None:
                username, password = auth

                if username is None:
                    username = ''

                if password is None:
                    password = ''

                headers.update({
                    'Authorization': 'Basic %s' % (
                        base64.b64encode('%s:%s' % (username, password)),)
                })
            resp = yield http_request_full(
                url, data=data, headers=headers, timeout=config.timeout)
            if not (200 <= resp.code < 300):
                # We didn't get a 2xx response.
                log.warning('Got unexpected response code %s from %s' % (
                    resp.code, url))
        except SchemeNotSupported:
            log.warning('Unsupported scheme for URL: %s' % (url,))
        except HttpTimeoutError:
            log.warning("Timeout pushing message to %s" % (url,))
        except DNSLookupError:
            log.warning("DNS lookup error pushing message to %s" % (url,))
        except ConnectionRefusedError:
            log.warning("Connection refused pushing message to %s" % (url,))
开发者ID:ChrisNolan1992,项目名称:vumi-go,代码行数:35,代码来源:vumi_app.py

示例6: handle_outbound_message

    def handle_outbound_message(self, message):
        headers = {"Content-Type": "application/json; charset=utf-8"}
        headers.update(self.get_auth_headers())

        params = {
            "to_addr": message["to_addr"],
            "content": message["content"],
            "message_id": message["message_id"],
            "in_reply_to": message["in_reply_to"],
            "session_event": message["session_event"],
        }
        if "helper_metadata" in message:
            params["helper_metadata"] = message["helper_metadata"]

        resp = yield http_request_full(
            self.get_url("messages.json"),
            data=json.dumps(params).encode("utf-8"),
            headers=headers,
            method="PUT",
            agent_class=self.agent_factory,
        )

        if resp.code != http.OK:
            log.warning("Unexpected status code: %s, body: %s" % (resp.code, resp.delivered_body))
            yield self.publish_nack(message["message_id"], reason="Unexpected status code: %s" % (resp.code,))
            return

        remote_message = json.loads(resp.delivered_body)
        yield self.map_message_id(remote_message["message_id"], message["message_id"])
        yield self.publish_ack(user_message_id=message["message_id"], sent_message_id=remote_message["message_id"])
开发者ID:caiobertacco,项目名称:vumi,代码行数:30,代码来源:vumi_bridge.py

示例7: handle_outbound_message

    def handle_outbound_message(self, message):
        headers = {
            'Content-Type': 'application/json; charset=utf-8',
        }
        headers.update(self.get_auth_headers())

        params = {
            'to_addr': message['to_addr'],
            'content': message['content'],
            'message_id': message['message_id'],
            'in_reply_to': message['in_reply_to'],
            'session_event': message['session_event']
        }
        if 'helper_metadata' in message:
            params['helper_metadata'] = message['helper_metadata']

        resp = yield http_request_full(
            self.get_url('messages.json'),
            data=json.dumps(params).encode('utf-8'),
            headers=headers,
            method='PUT')

        if resp.code != http.OK:
            log.warning('Unexpected status code: %s, body: %s' % (
                resp.code, resp.delivered_body))
            yield self.publish_nack(message['message_id'],
                                    reason='Unexpected status code: %s' % (
                                        resp.code,))
            return

        remote_message = json.loads(resp.delivered_body)
        yield self.map_message_id(
            remote_message['message_id'], message['message_id'])
        yield self.publish_ack(user_message_id=message['message_id'],
                               sent_message_id=remote_message['message_id'])
开发者ID:Nagato23,项目名称:vumi,代码行数:35,代码来源:vumi_bridge.py

示例8: _handle_send

 def _handle_send(self, message_id, request):
     msginfo = yield self.msginfo_for_request(request)
     if msginfo is None:
         log.warning("Bad account: %r (args: %r)" % (request, request.args))
         yield self._send_response(message_id, success=self.SMSSYNC_FALSE)
         return
     yield self._respond_with_pending_messages(msginfo, message_id, task="send", secret=msginfo.smssync_secret)
开发者ID:caiobertacco,项目名称:vumi,代码行数:7,代码来源:smssync.py

示例9: handle_bind_receiver_resp

    def handle_bind_receiver_resp(self, pdu):
        if not pdu_ok(pdu):
            log.warning('Unable to bind: %r' % (command_status(pdu),))
            self.transport.loseConnection()
            return

        self.state = self.BOUND_STATE_RX
        return self.on_smpp_bind(seq_no(pdu))
开发者ID:Nagato23,项目名称:vumi,代码行数:8,代码来源:protocol.py

示例10: normalise_provider

 def normalise_provider(self, provider):
     if provider not in self.provider_mappings:
         log.warning(
             "No mapping exists for provider '%s', "
             "using '%s' as a fallback" % (provider, provider,))
         return provider
     else:
         return self.provider_mappings[provider]
开发者ID:imsickofmaps,项目名称:vumi-aat,代码行数:8,代码来源:ussd.py

示例11: _handle_submit_sm_resp_callback

 def _handle_submit_sm_resp_callback(self, message_id, smpp_message_id,
                                     command_status, cb):
     if message_id is None:
         # We have no message_id, so log a warning instead of calling the
         # callback.
         log.warning("Failed to retrieve message id for deliver_sm_resp."
                     " ack/nack from %s discarded."
                     % self.vumi_transport.transport_name)
     else:
         return cb(message_id, smpp_message_id, command_status)
开发者ID:Nagato23,项目名称:vumi,代码行数:10,代码来源:smpp_transport.py

示例12: process_message_in_sandbox

 def process_message_in_sandbox(self, msg):
     # TODO remove the delivery class inference and injection into the
     # message once we have message address types
     metadata = msg['helper_metadata']
     metadata['delivery_class'] = self.infer_delivery_class(msg)
     config = yield self.get_config(msg)
     if not config.javascript:
         log.warning("No JS for conversation: %s" % (
             config.conversation.key,))
         return
     yield super(JsBoxApplication, self).process_message_in_sandbox(msg)
开发者ID:ChrisNolan1992,项目名称:vumi-go,代码行数:11,代码来源:vumi_app.py

示例13: on_unsupported_command_id

    def on_unsupported_command_id(self, pdu):
        """
        Called when an SMPP PDU is received for which no handler function has
        been defined.

        :param dict pdu:
            The dict result one gets when calling ``smpp.pdu.unpack_pdu()``
            on the received PDU
        """
        log.warning(
            'Received unsupported SMPP command_id: %r' % (command_id(pdu),))
开发者ID:Nagato23,项目名称:vumi,代码行数:11,代码来源:protocol.py

示例14: consume_user_message

 def consume_user_message(self, message):
     msg_mdh = self.get_metadata_helper(message)
     conversation = yield msg_mdh.get_conversation()
     if conversation is None:
         log.warning("Cannot find conversation for message: %r" % (
             message,))
         return
     ignore = self.get_api_config(conversation, 'ignore_messages', False)
     if not ignore:
         push_url = self.get_api_config(conversation, 'push_message_url')
         yield self.send_message_to_client(message, conversation, push_url)
开发者ID:ChrisNolan1992,项目名称:vumi-go,代码行数:11,代码来源:vumi_app.py

示例15: get_conversations

 def get_conversations(self, conv_pointers):
     results = yield gatherResults([
         self.get_conversation_fallback(account_key, conv_key)
         for account_key, conv_key in conv_pointers])
     conversations = []
     for pointer, conv in zip(conv_pointers, results):
         if conv is None:
             log.warning("Conversation %s for account %s not found." % (
                 pointer[1], pointer[0]))
         else:
             conversations.append(conv)
     returnValue(conversations)
开发者ID:ChrisNolan1992,项目名称:vumi-go,代码行数:12,代码来源:vumi_app.py


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