本文整理汇总了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')
示例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')
示例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."
),
)
示例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)
示例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))
示例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)
示例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))