當前位置: 首頁>>代碼示例>>Python>>正文


Python policies.ProtocolWrapper方法代碼示例

本文整理匯總了Python中twisted.protocols.policies.ProtocolWrapper方法的典型用法代碼示例。如果您正苦於以下問題:Python policies.ProtocolWrapper方法的具體用法?Python policies.ProtocolWrapper怎麽用?Python policies.ProtocolWrapper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.protocols.policies的用法示例。


在下文中一共展示了policies.ProtocolWrapper方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_wrappingBehavior

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_wrappingBehavior(self):
        """
        Any modifications performed by the underlying L{ProtocolWrapper}
        propagate through to the wrapped L{Protocol}.
        """
        connecting = self.wrapper.connect(self.factory)
        pump = self.completer.succeedOnce()
        proto = self.successResultOf(connecting)
        pump.server.transport.write(b'5:hello,')
        pump.flush()
        self.assertEqual(proto.strings, [b'HELLO']) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_endpoints.py

示例2: __init__

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def __init__(self, protocol, factory):
        policies.ProtocolWrapper.__init__(self, protocol, factory)
        self.deferred = defer.Deferred() 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:5,代碼來源:loopback.py

示例3: connectionLost

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def connectionLost(self, reason):
        policies.ProtocolWrapper.connectionLost(self, reason)
        self.deferred.callback(None) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:5,代碼來源:loopback.py

示例4: __init__

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def __init__(self, factory, wrappedProtocol):
        policies.ProtocolWrapper.__init__(self, factory, wrappedProtocol)
        self._proxyInfo = None
        self._parser = None 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:6,代碼來源:_wrapper.py

示例5: __init__

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def __init__(self, factory, wrappedProtocol):
        policies.ProtocolWrapper.__init__(self, factory, wrappedProtocol) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:4,代碼來源:test_tcp.py

示例6: connectionLost

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def connectionLost(self, reason):
        policies.ProtocolWrapper.connectionLost(self, reason)
        self.factory.onDisconnect.callback(None) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:5,代碼來源:test_tcp.py

示例7: test_transportInterfaces

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_transportInterfaces(self):
        """
        The transport wrapper passed to the wrapped protocol's
        C{makeConnection} provides the same interfaces as are provided by the
        original transport.
        """
        class IStubTransport(Interface):
            pass

        @implementer(IStubTransport)
        class StubTransport:
            pass

        # Looking up what ProtocolWrapper implements also mutates the class.
        # It adds __implemented__ and __providedBy__ attributes to it.  These
        # prevent __getattr__ from causing the IStubTransport.providedBy call
        # below from returning True.  If, by accident, nothing else causes
        # these attributes to be added to ProtocolWrapper, the test will pass,
        # but the interface will only be provided until something does trigger
        # their addition.  So we just trigger it right now to be sure.
        implementedBy(policies.ProtocolWrapper)

        proto = protocol.Protocol()
        wrapper = policies.ProtocolWrapper(policies.WrappingFactory(None), proto)

        wrapper.makeConnection(StubTransport())
        self.assertTrue(IStubTransport.providedBy(proto.transport)) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:29,代碼來源:test_policies.py

示例8: test_protocolLogPrefix

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_protocolLogPrefix(self):
        """
        L{ProtocolWrapper.logPrefix} is customized to mention both the original
        protocol and the wrapper.
        """
        server = Server()
        factory = policies.WrappingFactory(server)
        protocol = factory.buildProtocol(
            address.IPv4Address('TCP', '127.0.0.1', 35))
        self.assertEqual("EchoProtocol (ProtocolWrapper)",
                         protocol.logPrefix()) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_policies.py

示例9: test_protocolLogPrefixFallback

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_protocolLogPrefixFallback(self):
        """
        If the wrapped protocol doesn't have a L{logPrefix} method,
        L{ProtocolWrapper.logPrefix} falls back to the protocol class name.
        """
        class NoProtocol(object):
            pass

        server = Server()
        server.protocol = NoProtocol
        factory = policies.WrappingFactory(server)
        protocol = factory.buildProtocol(
            address.IPv4Address('TCP', '127.0.0.1', 35))
        self.assertEqual("NoProtocol (ProtocolWrapper)",
                         protocol.logPrefix()) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:17,代碼來源:test_policies.py

示例10: test_getHost

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_getHost(self):
        """
        L{policies.ProtocolWrapper.getHost} calls C{getHost} on the underlying
        transport.
        """
        wrapper = self._getWrapper()
        self.assertEqual(wrapper.getHost(), wrapper.transport.getHost()) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:9,代碼來源:test_policies.py

示例11: test_getPeer

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_getPeer(self):
        """
        L{policies.ProtocolWrapper.getPeer} calls C{getPeer} on the underlying
        transport.
        """
        wrapper = self._getWrapper()
        self.assertEqual(wrapper.getPeer(), wrapper.transport.getPeer()) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:9,代碼來源:test_policies.py

示例12: test_registerProducer

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_registerProducer(self):
        """
        L{policies.ProtocolWrapper.registerProducer} calls C{registerProducer}
        on the underlying transport.
        """
        wrapper = self._getWrapper()
        producer = object()
        wrapper.registerProducer(producer, True)
        self.assertIs(wrapper.transport.producer, producer)
        self.assertTrue(wrapper.transport.streaming) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:test_policies.py

示例13: test_unregisterProducer

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_unregisterProducer(self):
        """
        L{policies.ProtocolWrapper.unregisterProducer} calls
        C{unregisterProducer} on the underlying transport.
        """
        wrapper = self._getWrapper()
        producer = object()
        wrapper.registerProducer(producer, True)
        wrapper.unregisterProducer()
        self.assertIsNone(wrapper.transport.producer)
        self.assertIsNone(wrapper.transport.streaming) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_policies.py

示例14: test_stopConsuming

# 需要導入模塊: from twisted.protocols import policies [as 別名]
# 或者: from twisted.protocols.policies import ProtocolWrapper [as 別名]
def test_stopConsuming(self):
        """
        L{policies.ProtocolWrapper.stopConsuming} calls C{stopConsuming} on
        the underlying transport.
        """
        wrapper = self._getWrapper()
        result = []
        wrapper.transport.stopConsuming = lambda: result.append(True)
        wrapper.stopConsuming()
        self.assertEqual(result, [True]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:test_policies.py


注:本文中的twisted.protocols.policies.ProtocolWrapper方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。