当前位置: 首页>>代码示例>>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;未经允许,请勿转载。