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


Python pdu_utils.seq_no函数代码示例

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


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

示例1: test_mt_sms_queue_full

    def test_mt_sms_queue_full(self):
        smpp_helper = yield self.get_smpp_helper()
        transport_config = smpp_helper.transport.get_static_config()
        msg = self.tx_helper.make_outbound('hello world')

        yield self.tx_helper.dispatch_outbound(msg)
        [submit_sm_pdu] = yield smpp_helper.wait_for_pdus(1)
        yield smpp_helper.handle_pdu(
            SubmitSMResp(sequence_number=seq_no(submit_sm_pdu),
                         message_id='foo',
                         command_status='ESME_RMSGQFUL'))

        self.clock.advance(transport_config.throttle_delay)

        [submit_sm_pdu_retry] = yield smpp_helper.wait_for_pdus(1)
        yield smpp_helper.handle_pdu(
            SubmitSMResp(sequence_number=seq_no(submit_sm_pdu_retry),
                         message_id='bar',
                         command_status='ESME_ROK'))

        self.assertTrue(seq_no(submit_sm_pdu_retry) > seq_no(submit_sm_pdu))
        self.assertEqual(short_message(submit_sm_pdu), 'hello world')
        self.assertEqual(short_message(submit_sm_pdu_retry), 'hello world')
        [event] = yield self.tx_helper.wait_for_dispatched_events(1)
        self.assertEqual(event['event_type'], 'ack')
        self.assertEqual(event['user_message_id'], msg['message_id'])
开发者ID:komuW,项目名称:vumi,代码行数:26,代码来源:test_smpp_transport.py

示例2: test_unbind

 def test_unbind(self):
     protocol = yield self.get_protocol()
     calls = []
     protocol.handle_unbind_resp = calls.append
     yield self.fake_smsc.bind()
     yield protocol.unbind()
     unbind_pdu = yield self.fake_smsc.await_pdu()
     protocol.dataReceived(UnbindResp(seq_no(unbind_pdu)).get_bin())
     [unbind_resp_pdu] = calls
     self.assertEqual(seq_no(unbind_resp_pdu), seq_no(unbind_pdu))
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:10,代码来源:test_protocol.py

示例3: test_unbind

 def test_unbind(self):
     calls = []
     self.patch(EsmeTransceiver, 'handle_unbind_resp',
                lambda p, pdu: calls.append(pdu))
     transport, protocol = yield self.setup_bind()
     yield protocol.unbind()
     [unbind_pdu] = yield wait_for_pdus(transport, 1)
     protocol.dataReceived(UnbindResp(seq_no(unbind_pdu)).get_bin())
     [unbind_resp_pdu] = calls
     self.assertEqual(seq_no(unbind_resp_pdu), seq_no(unbind_pdu))
开发者ID:areski,项目名称:vumi,代码行数:10,代码来源:test_protocol.py

示例4: test_mt_sms_throttle_while_throttled

    def test_mt_sms_throttle_while_throttled(self):
        smpp_helper = yield self.get_smpp_helper()
        transport_config = smpp_helper.transport.get_static_config()
        msg1 = self.tx_helper.make_outbound('hello world 1')
        msg2 = self.tx_helper.make_outbound('hello world 2')

        yield self.tx_helper.dispatch_outbound(msg1)
        yield self.tx_helper.dispatch_outbound(msg2)
        [ssm_pdu1, ssm_pdu2] = yield smpp_helper.wait_for_pdus(2)
        yield smpp_helper.handle_pdu(
            SubmitSMResp(sequence_number=seq_no(ssm_pdu1),
                         message_id='foo1',
                         command_status='ESME_RTHROTTLED'))
        yield smpp_helper.handle_pdu(
            SubmitSMResp(sequence_number=seq_no(ssm_pdu2),
                         message_id='foo2',
                         command_status='ESME_RTHROTTLED'))

        # Advance clock, still throttled.
        self.clock.advance(transport_config.throttle_delay)
        [ssm_pdu1_retry1] = yield smpp_helper.wait_for_pdus(1)
        yield smpp_helper.handle_pdu(
            SubmitSMResp(sequence_number=seq_no(ssm_pdu1_retry1),
                         message_id='bar1',
                         command_status='ESME_RTHROTTLED'))

        # Advance clock, message no longer throttled.
        self.clock.advance(transport_config.throttle_delay)
        [ssm_pdu2_retry1] = yield smpp_helper.wait_for_pdus(1)
        yield smpp_helper.handle_pdu(
            SubmitSMResp(sequence_number=seq_no(ssm_pdu2_retry1),
                         message_id='bar2',
                         command_status='ESME_ROK'))

        # Prod clock, message no longer throttled.
        self.clock.advance(0)
        [ssm_pdu1_retry2] = yield smpp_helper.wait_for_pdus(1)
        yield smpp_helper.handle_pdu(
            SubmitSMResp(sequence_number=seq_no(ssm_pdu1_retry2),
                         message_id='baz1',
                         command_status='ESME_ROK'))

        self.assertEqual(short_message(ssm_pdu1), 'hello world 1')
        self.assertEqual(short_message(ssm_pdu2), 'hello world 2')
        self.assertEqual(short_message(ssm_pdu1_retry1), 'hello world 1')
        self.assertEqual(short_message(ssm_pdu2_retry1), 'hello world 2')
        self.assertEqual(short_message(ssm_pdu1_retry2), 'hello world 1')
        [event2, event1] = yield self.tx_helper.wait_for_dispatched_events(2)
        self.assertEqual(event1['event_type'], 'ack')
        self.assertEqual(event1['user_message_id'], msg1['message_id'])
        self.assertEqual(event2['event_type'], 'ack')
        self.assertEqual(event2['user_message_id'], msg2['message_id'])
开发者ID:komuW,项目名称:vumi,代码行数:52,代码来源:test_smpp_transport.py

示例5: handle_deliver_sm

    def handle_deliver_sm(self, pdu):
        # These operate before the PDUs ``short_message`` or
        # ``message_payload`` fields have been string decoded.
        # NOTE: order is important!
        pdu_handler_chain = [
            self.dr_processor.handle_delivery_report_pdu,
            self.deliver_sm_processor.handle_multipart_pdu,
            self.deliver_sm_processor.handle_ussd_pdu,
        ]
        for handler in pdu_handler_chain:
            handled = yield handler(pdu)
            if handled:
                self.send_pdu(DeliverSMResp(seq_no(pdu),
                              command_status='ESME_ROK'))
                return

        # At this point we either have a DR in the message payload
        # or have a normal SMS that needs to be decoded and handled.
        content_parts = self.deliver_sm_processor.decode_pdus([pdu])
        if not all([isinstance(part, unicode) for part in content_parts]):
            command_status = self.config.deliver_sm_decoding_error
            self.log.msg(
                'Not all parts of the PDU were able to be decoded. '
                'Responding with %s.' % (command_status,),
                parts=content_parts)
            self.send_pdu(DeliverSMResp(seq_no(pdu),
                          command_status=command_status))
            return

        content = u''.join(content_parts)
        was_cdr = yield self.dr_processor.handle_delivery_report_content(
            content)
        if was_cdr:
            self.send_pdu(DeliverSMResp(seq_no(pdu),
                          command_status='ESME_ROK'))
            return

        handled = yield self.deliver_sm_processor.handle_short_message_pdu(pdu)
        if handled:
            self.send_pdu(DeliverSMResp(seq_no(pdu),
                          command_status="ESME_ROK"))
            return

        command_status = self.config.deliver_sm_decoding_error
        self.log.warning(
            'Unable to process message. '
            'Responding with %s.' % (command_status,),
            content=content, pdu=pdu.get_obj())

        self.send_pdu(DeliverSMResp(seq_no(pdu),
                      command_status=command_status))
开发者ID:praekelt,项目名称:vumi,代码行数:51,代码来源:protocol.py

示例6: bind_protocol

def bind_protocol(transport, protocol, clear=True):
    [bind_pdu] = yield wait_for_pdus(transport, 1)
    resp_pdu_class = {
        BindTransceiver: BindTransceiverResp,
        BindReceiver: BindReceiverResp,
        BindTransmitter: BindTransmitterResp,
    }.get(protocol.bind_pdu)
    protocol.dataReceived(
        resp_pdu_class(seq_no(bind_pdu)).get_bin())
    [enquire_link] = yield wait_for_pdus(transport, 1)
    protocol.dataReceived(
        EnquireLinkResp(seq_no(enquire_link)).get_bin())
    if clear:
        transport.clear()
    returnValue(bind_pdu)
开发者ID:areski,项目名称:vumi,代码行数:15,代码来源:test_protocol.py

示例7: test_submit_and_deliver_ussd_close

    def test_submit_and_deliver_ussd_close(self):
        smpp_helper = yield self.get_smpp_helper()

        yield self.tx_helper.make_dispatch_outbound(
            "hello world", transport_type="ussd",
            session_event=TransportUserMessage.SESSION_CLOSE)

        [submit_sm_pdu] = yield smpp_helper.wait_for_pdus(1)
        self.assertEqual(command_id(submit_sm_pdu), 'submit_sm')
        self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '02')
        self.assertEqual(pdu_tlv(submit_sm_pdu, 'its_session_info'), '0001')

        # Server delivers a USSD message to the Client
        pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!")
        pdu.add_optional_parameter('ussd_service_op', '02')
        pdu.add_optional_parameter('its_session_info', '0001')

        yield smpp_helper.handle_pdu(pdu)

        [mess] = yield self.tx_helper.wait_for_dispatched_inbound(1)

        self.assertEqual(mess['content'], "reply!")
        self.assertEqual(mess['transport_type'], "ussd")
        self.assertEqual(mess['session_event'],
                         TransportUserMessage.SESSION_CLOSE)
开发者ID:komuW,项目名称:vumi,代码行数:25,代码来源:test_smpp_transport.py

示例8: _submit_sm_resp

 def _submit_sm_resp(self, submit_sm_pdu, message_id, **kw):
     self.assert_command_id(submit_sm_pdu, 'submit_sm')
     sequence_number = seq_no(submit_sm_pdu)
     if message_id is None:
         message_id = "id%s" % (sequence_number,)
     # We use handle_pdu here to avoid complications with all the async.
     return self.handle_pdu(SubmitSMResp(sequence_number, message_id, **kw))
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:7,代码来源:fake_smsc.py

示例9: handle_bind_receiver_resp

    def handle_bind_receiver_resp(self, pdu):
        if not pdu_ok(pdu):
            self.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:praekelt,项目名称:vumi,代码行数:8,代码来源:protocol.py

示例10: test_mt_sms_multipart_fail_second_part

 def test_mt_sms_multipart_fail_second_part(self):
     smpp_helper = yield self.get_smpp_helper(config={
         'submit_short_message_processor_config': {
             'send_multipart_udh': True,
         }
     })
     content = '1' * 161
     msg = self.tx_helper.make_outbound(content)
     yield self.tx_helper.dispatch_outbound(msg)
     [submit_sm1, submit_sm2] = yield smpp_helper.wait_for_pdus(2)
     smpp_helper.send_pdu(
         SubmitSMResp(sequence_number=seq_no(submit_sm1), message_id='foo'))
     smpp_helper.send_pdu(
         SubmitSMResp(sequence_number=seq_no(submit_sm2),
                      message_id='bar', command_status='ESME_RSUBMITFAIL'))
     [event] = yield self.tx_helper.wait_for_dispatched_events(1)
     self.assertEqual(event['event_type'], 'nack')
     self.assertEqual(event['user_message_id'], msg['message_id'])
开发者ID:komuW,项目名称:vumi,代码行数:18,代码来源:test_smpp_transport.py

示例11: test_on_enquire_link_resp

 def test_on_enquire_link_resp(self):
     protocol = yield self.get_protocol()
     calls = []
     protocol.handle_enquire_link_resp = calls.append
     yield self.fake_smsc.bind()
     [pdu] = calls
     # bind_transceiver is sequence_number 1
     self.assertEqual(seq_no(pdu), 2)
     self.assertEqual(command_id(pdu), 'enquire_link_resp')
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:9,代码来源:test_protocol.py

示例12: test_on_enquire_link_resp

 def test_on_enquire_link_resp(self):
     calls = []
     self.patch(EsmeTransceiver, 'handle_enquire_link_resp',
                lambda p, pdu: calls.append(pdu))
     transport, protocol = yield self.setup_bind()
     [pdu] = calls
     # bind_transceiver is sequence_number 1
     self.assertEqual(seq_no(pdu), 2)
     self.assertEqual(command_id(pdu), 'enquire_link_resp')
开发者ID:areski,项目名称:vumi,代码行数:9,代码来源:test_protocol.py

示例13: test_out_of_order_responses

    def test_out_of_order_responses(self):
        smpp_helper = yield self.get_smpp_helper()
        yield self.tx_helper.make_dispatch_outbound("msg 1", message_id='444')
        [submit_sm1] = yield smpp_helper.wait_for_pdus(1)
        response1 = SubmitSMResp(seq_no(submit_sm1), "3rd_party_id_1")

        yield self.tx_helper.make_dispatch_outbound("msg 2", message_id='445')
        [submit_sm2] = yield smpp_helper.wait_for_pdus(1)
        response2 = SubmitSMResp(seq_no(submit_sm2), "3rd_party_id_2")

        # respond out of order - just to keep things interesting
        yield smpp_helper.handle_pdu(response2)
        yield smpp_helper.handle_pdu(response1)

        [ack1, ack2] = yield self.tx_helper.wait_for_dispatched_events(2)
        self.assertEqual(ack1['user_message_id'], '445')
        self.assertEqual(ack1['sent_message_id'], '3rd_party_id_2')
        self.assertEqual(ack2['user_message_id'], '444')
        self.assertEqual(ack2['sent_message_id'], '3rd_party_id_1')
开发者ID:komuW,项目名称:vumi,代码行数:19,代码来源:test_smpp_transport.py

示例14: _bind_resp

 def _bind_resp(self, bind_pdu):
     resp_pdu_classes = {
         'bind_transceiver': BindTransceiverResp,
         'bind_receiver': BindReceiverResp,
         'bind_transmitter': BindTransmitterResp,
     }
     self.assert_command_id(bind_pdu, *resp_pdu_classes)
     resp_pdu_class = resp_pdu_classes.get(command_id(bind_pdu))
     self.send_pdu(resp_pdu_class(seq_no(bind_pdu)))
     eq_d = self.respond_to_enquire_link()
     return eq_d.addCallback(self._bound_d.callback)
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:11,代码来源:fake_smsc.py

示例15: test_drop_link

 def test_drop_link(self):
     protocol = yield self.get_protocol()
     bind_pdu = yield self.fake_smsc.await_pdu()
     self.assertCommand(bind_pdu, 'bind_transceiver')
     self.assertFalse(protocol.is_bound())
     self.assertEqual(protocol.state, EsmeProtocol.OPEN_STATE)
     self.clock.advance(protocol.config.smpp_bind_timeout + 1)
     unbind_pdu = yield self.fake_smsc.await_pdu()
     self.assertCommand(unbind_pdu, 'unbind')
     yield self.fake_smsc.send_pdu(UnbindResp(seq_no(unbind_pdu)))
     yield self.fake_smsc.await_disconnect()
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:11,代码来源:test_protocol.py


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