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


Python StringTransport.write方法代码示例

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


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

示例1: require

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import write [as 别名]
def require(packageName, fixName):
    if (packageName, fixName) in _alreadyInstalled:
        return

    if (packageName, fixName) == ("twisted", "filepath_copyTo"):
        from twisted.python import filepath

        if filepath.FilePath("a") != filepath.FilePath("a"):
            from vmc.contrib.epsilon.hotfixes import filepath_copyTo

            filepath_copyTo.install()
    elif (packageName, fixName) == ("twisted", "timeoutmixin_calllater"):
        from twisted.protocols import policies

        if not hasattr(policies.TimeoutMixin, "callLater"):
            from vmc.contrib.epsilon.hotfixes import timeoutmixin_calllater

            timeoutmixin_calllater.install()
    elif (packageName, fixName) == ("twisted", "delayedcall_seconds"):
        from twisted.internet import base

        args = inspect.getargs(base.DelayedCall.__init__.func_code)[0]
        if "seconds" not in args:
            from vmc.contrib.epsilon.hotfixes import delayedcall_seconds

            delayedcall_seconds.install()
    elif (packageName, fixName) == ("twisted", "deferredgenerator_tfailure"):
        from twisted.internet import defer

        result = []

        def test():
            d = defer.waitForDeferred(defer.succeed(1))
            yield d
            result.append(d.getResult())

        defer.deferredGenerator(test)()
        if result == [1]:
            from vmc.contrib.epsilon.hotfixes import deferredgenerator_tfailure

            deferredgenerator_tfailure.install()
        else:
            assert result == [None]
    elif (packageName, fixName) == ("twisted", "proto_helpers_stringtransport"):
        from twisted.test.proto_helpers import StringTransport

        st = StringTransport()
        try:
            st.write(u"foo")
        except TypeError, e:
            pass
        else:
            from vmc.contrib.epsilon.hotfixes import proto_helpers_stringtransport

            proto_helpers_stringtransport.install()
开发者ID:mrader11,项目名称:vodafone-mobile-connect,代码行数:57,代码来源:hotfix.py

示例2: write

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import write [as 别名]
    def write(self, data):
        """Write some data"""
        StringTransport.write(self, data)
        if not self.done:
            if "\r\n\r\n" in self.value():
                self.done = True
                self.reply_func(self.value())

        else:
            if self.remote_func is not None:
                self.remote_func(self.value())
开发者ID:magicicada-bot,项目名称:magicicada-protocol,代码行数:13,代码来源:test_proxy_tunnel.py

示例3: Request

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import write [as 别名]
class Request(DummyRequest):
    def __init__(self, method, *args, **kwargs):
        DummyRequest.__init__(self, *args, **kwargs)
        self.method = method
        self.content = StringIO()
        self.transport = StringTransport()
    
    def writeContent(self, data):
        self.content.seek(0,2) # Go to end of content
        self.content.write(data) # Write the data
        self.content.seek(0,0) # Go back to beginning of content
    
    def write(self, data):
        DummyRequest.write(self, data)
        self.transport.write("".join(self.written))
        self.written = []
    
    def value(self):
        return self.transport.value()
开发者ID:DesertBus,项目名称:sockjs-twisted,代码行数:21,代码来源:common.py

示例4: write

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import write [as 别名]
 def write(self, bytes, addr=None):
     StringTransport.write(self, bytes)
开发者ID:deepakhajare,项目名称:maas,代码行数:4,代码来源:test_protocol.py

示例5: require

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import write [as 别名]
def require(packageName, fixName):
    if (packageName, fixName) in _alreadyInstalled:
        return

    if (packageName, fixName) == ('twisted', 'filepath_copyTo'):
        from twisted.python import filepath
        if filepath.FilePath('a') != filepath.FilePath('a'):
            from epsilon.hotfixes import filepath_copyTo
            filepath_copyTo.install()
    elif (packageName, fixName) == ('twisted', 'timeoutmixin_calllater'):
        from twisted.protocols import policies
        if not hasattr(policies.TimeoutMixin, 'callLater'):
            from epsilon.hotfixes import timeoutmixin_calllater
            timeoutmixin_calllater.install()
    elif (packageName, fixName) == ('twisted', 'delayedcall_seconds'):
        from twisted.internet import base
        args = inspect.getargs(base.DelayedCall.__init__.__code__)[0]
        if 'seconds' not in args:
            from epsilon.hotfixes import delayedcall_seconds
            delayedcall_seconds.install()
    elif (packageName, fixName) == ('twisted', 'deferredgenerator_tfailure'):
        from twisted.internet import defer
        result = []
        def test():
            d = defer.waitForDeferred(defer.succeed(1))
            yield d
            result.append(d.getResult())
        defer.deferredGenerator(test)()
        if result == [1]:
            from epsilon.hotfixes import deferredgenerator_tfailure
            deferredgenerator_tfailure.install()
        else:
            assert result == [None]
    elif (packageName, fixName) == ("twisted", "proto_helpers_stringtransport"):
        from twisted.test.proto_helpers import StringTransport
        st = StringTransport()
        try:
            st.write('foo')
        except TypeError as e:
            pass
        else:
            from epsilon.hotfixes import proto_helpers_stringtransport
            proto_helpers_stringtransport.install()
    elif (packageName, fixName) == ("twisted", "internet_task_Clock"):
        from twisted.internet.task import Clock
        from twisted.internet import base
        from twisted import version
        from epsilon.hotfixes import internet_task_clock
        if internet_task_clock.clockIsBroken():
            internet_task_clock.install()
    elif (packageName, fixName) == ("twisted", "trial_assertwarns"):
        from twisted.trial.unittest import TestCase
        if not hasattr(TestCase, "failUnlessWarns"):
            from epsilon.hotfixes import trial_assertwarns
            trial_assertwarns.install()
    elif (packageName, fixName) == ("twisted", "plugin_package_paths"):
        try:
            from twisted.plugin import pluginPackagePaths
        except ImportError:
            from epsilon.hotfixes import plugin_package_paths
            plugin_package_paths.install()
    elif (packageName, fixName) == ("twisted", "loopbackasync_reentrancy"):
        # This one is really hard to detect reasonably.  Invoking the code
        # involves triggering the reactor, which it would be good to avoid. 
        from twisted import version
        if (version.major, version.minor) < (8, 2):
            from epsilon.hotfixes import loopbackasync_reentrancy
            loopbackasync_reentrancy.install()
    else:
        raise NoSuchHotfix(packageName, fixName)

    _alreadyInstalled.add((packageName, fixName))
开发者ID:perkinslr,项目名称:epsilon-py3,代码行数:74,代码来源:hotfix.py

示例6: write

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import write [as 别名]
 def write(self, data, host=None):
     """Wrapper around TStringTransport.write"""
     TStringTransport.write(self, data)
     self.msgs.append(data)
开发者ID:cs648,项目名称:dissertation,代码行数:6,代码来源:test_agent.py


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