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


Python amp.IBoxSender方法代码示例

本文整理汇总了Python中twisted.protocols.amp.IBoxSender方法的典型用法代码示例。如果您正苦于以下问题:Python amp.IBoxSender方法的具体用法?Python amp.IBoxSender怎么用?Python amp.IBoxSender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.protocols.amp的用法示例。


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

示例1: test_sendBoxInStartReceivingBoxes

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import IBoxSender [as 别名]
def test_sendBoxInStartReceivingBoxes(self):
        """
        The L{IBoxReceiver} which is started when L{amp.BinaryBoxProtocol} is
        connected to a transport can call C{sendBox} on the L{IBoxSender}
        passed to it before C{startReceivingBoxes} returns and have that box
        sent.
        """
        class SynchronouslySendingReceiver:
            def startReceivingBoxes(self, sender):
                sender.sendBox(amp.Box({b'foo': b'bar'}))

        transport = StringTransport()
        protocol = amp.BinaryBoxProtocol(SynchronouslySendingReceiver())
        protocol.makeConnection(transport)
        self.assertEqual(
            transport.value(),
            b'\x00\x03foo\x00\x03bar\x00\x00') 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:test_amp.py

示例2: test_sendBoxInStartReceivingBoxes

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import IBoxSender [as 别名]
def test_sendBoxInStartReceivingBoxes(self):
        """
        The L{IBoxReceiver} which is started when L{amp.BinaryBoxProtocol} is
        connected to a transport can call C{sendBox} on the L{IBoxSender}
        passed to it before C{startReceivingBoxes} returns and have that box
        sent.
        """
        class SynchronouslySendingReceiver:
            def startReceivingBoxes(self, sender):
                sender.sendBox(amp.Box({'foo': 'bar'}))

        transport = StringTransport()
        protocol = amp.BinaryBoxProtocol(SynchronouslySendingReceiver())
        protocol.makeConnection(transport)
        self.assertEqual(
            transport.value(),
            '\x00\x03foo\x00\x03bar\x00\x00') 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:test_amp.py

示例3: unhandledError

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import IBoxSender [as 别名]
def unhandledError(self, failure):
        """Terminal errback, after application code has seen the failure.

        `amp.BoxDispatcher.unhandledError` calls the `amp.IBoxSender`'s
        `unhandledError`. In the default implementation this disconnects the
        transport.

        Here we instead log the failure but do *not* disconnect because it's
        too disruptive to the running of MAAS.
        """
        log.err(
            failure,
            (
                "Unhandled failure during AMP request. This is probably a bug. "
                "Please ensure that this error is handled within application "
                "code."
            ),
        ) 
开发者ID:maas,项目名称:maas,代码行数:20,代码来源:common.py

示例4: test_startReceivingBoxes

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import IBoxSender [as 别名]
def test_startReceivingBoxes(self):
        """
        When L{amp.BinaryBoxProtocol} is connected to a transport, it calls
        C{startReceivingBoxes} on its L{IBoxReceiver} with itself as the
        L{IBoxSender} parameter.
        """
        protocol = amp.BinaryBoxProtocol(self)
        protocol.makeConnection(None)
        self.assertIs(self._boxSender, protocol) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_amp.py

示例5: test_interfaceDeclarations

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import IBoxSender [as 别名]
def test_interfaceDeclarations(self):
        """
        The classes in the amp module ought to implement the interfaces that
        are declared for their benefit.
        """
        for interface, implementation in [(amp.IBoxSender, amp.BinaryBoxProtocol),
                                          (amp.IBoxReceiver, amp.BoxDispatcher),
                                          (amp.IResponderLocator, amp.CommandLocator),
                                          (amp.IResponderLocator, amp.SimpleStringLocator),
                                          (amp.IBoxSender, amp.AMP),
                                          (amp.IBoxReceiver, amp.AMP),
                                          (amp.IResponderLocator, amp.AMP)]:
            self.assertTrue(interface.implementedBy(implementation),
                            "%s does not implements(%s)" % (implementation, interface)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:test_amp.py

示例6: test_startReceivingBoxes

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import IBoxSender [as 别名]
def test_startReceivingBoxes(self):
        """
        When L{amp.BinaryBoxProtocol} is connected to a transport, it calls
        C{startReceivingBoxes} on its L{IBoxReceiver} with itself as the
        L{IBoxSender} parameter.
        """
        protocol = amp.BinaryBoxProtocol(self)
        protocol.makeConnection(None)
        self.assertIdentical(self._boxSender, protocol) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:test_amp.py

示例7: test_interfaceDeclarations

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import IBoxSender [as 别名]
def test_interfaceDeclarations(self):
        """
        The classes in the amp module ought to implement the interfaces that
        are declared for their benefit.
        """
        for interface, implementation in [(amp.IBoxSender, amp.BinaryBoxProtocol),
                                          (amp.IBoxReceiver, amp.BoxDispatcher),
                                          (amp.IResponderLocator, amp.CommandLocator),
                                          (amp.IResponderLocator, amp.SimpleStringLocator),
                                          (amp.IBoxSender, amp.AMP),
                                          (amp.IBoxReceiver, amp.AMP),
                                          (amp.IResponderLocator, amp.AMP)]:
            self.failUnless(interface.implementedBy(implementation),
                            "%s does not implements(%s)" % (implementation, interface)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:16,代码来源:test_amp.py


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