本文整理匯總了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))