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


Python insults.ServerProtocol方法代码示例

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


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

示例1: protocol

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def protocol(self):
        class Portal:
            """An implementation of IPortal"""
            @defers
            def login(self_, credentials, mind, *interfaces):
                if not (credentials.username == self.username.encode('utf8') and
                        credentials.checkPassword(self.password.encode('utf8'))):
                    raise ValueError("Invalid credentials")

                protocol = telnet.TelnetBootstrapProtocol(
                    insults.ServerProtocol,
                    manhole.Manhole,
                    self._get_telnet_vars()
                )
                return (interfaces[0], protocol, lambda: None)

        return telnet.TelnetTransport(
            telnet.AuthenticatingTelnetProtocol,
            Portal()
        ) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:22,代码来源:telnet.py

示例2: test_consoleTextServer

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def test_consoleTextServer(self):
        """
        L{ConsoleTextServer.connectionMade} sets the protocol of its player to
        itself.
        """
        leader, follower = makeTerminal(self)
        store = Store()
        world = ImaginaryWorld(store=store)
        actor = world.create(u"player")

        setTerminalSize(leader, 234, 567)
        player = Player(actor)
        textServer = ConsoleTextServer(player, follower)
        terminalProtocol = ServerProtocol(lambda: textServer)
        self.assertIdentical(player.proto, None)
        terminalProtocol.makeConnection(StringTransport())
        self.assertIdentical(player.proto, textServer)
        self.assertEqual(textServer.width, 567)
        self.assertEqual(textServer.height, 234) 
开发者ID:twisted,项目名称:imaginary,代码行数:21,代码来源:test_runner.py

示例3: runWithProtocol

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def runWithProtocol(klass):
    fd = sys.__stdin__.fileno()
    oldSettings = termios.tcgetattr(fd)
    tty.setraw(fd)
    try:
        p = ServerProtocol(klass)
        stdio.StandardIO(p)
        reactor.run()
    finally:
        termios.tcsetattr(fd, termios.TCSANOW, oldSettings)
        os.write(fd, b"\r\x1bc\r") 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:stdio.py

示例4: __call__

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def __call__(self):
        return insults.ServerProtocol(manhole.ColoredManhole, self.namespace) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:4,代码来源:manhole_tap.py

示例5: setUp

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def setUp(self):
        self.underlyingTransport = StringTransport()
        self.pt = insults.ServerProtocol()
        self.p = recvline.HistoricRecvLine()
        self.pt.protocolFactory = lambda: self.p
        self.pt.factory = self
        self.pt.makeConnection(self.underlyingTransport) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_recvline.py

示例6: test_interruptResetsInterpreterBuffer

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def test_interruptResetsInterpreterBuffer(self):
        """
        L{manhole.Manhole.handle_INT} should cause the interpreter input buffer
        to be reset.
        """
        transport = StringTransport()
        terminal = insults.ServerProtocol(manhole.Manhole)
        terminal.makeConnection(transport)
        protocol = terminal.terminalProtocol
        interpreter = protocol.interpreter
        interpreter.buffer.extend(["1", "2"])
        protocol.handle_INT()
        self.assertFalse(interpreter.buffer) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_manhole.py

示例7: runWithProtocol

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def runWithProtocol(klass):
    fd = sys.__stdin__.fileno()
    oldSettings = termios.tcgetattr(fd)
    tty.setraw(fd)
    try:
        stdio.StandardIO(ServerProtocol(klass))
        reactor.run()
    finally:
        termios.tcsetattr(fd, termios.TCSANOW, oldSettings)
        os.write(fd, b"\r\x1bc\r") 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:12,代码来源:stdio.py

示例8: doWork

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def doWork(self):
        """
        Service startup.
        """

        # Set up the terminal for interactive action
        self.terminalFD = sys.__stdin__.fileno()
        self._oldTerminalSettings = termios.tcgetattr(self.terminalFD)
        tty.setraw(self.terminalFD)

        self.protocol = ServerProtocol(lambda: ShellProtocol(self))
        StandardIO(self.protocol)
        return succeed(None) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:15,代码来源:terminal.py

示例9: runWithProtocol

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def runWithProtocol(klass):
    fd = sys.__stdin__.fileno()
    oldSettings = termios.tcgetattr(fd)
    tty.setraw(fd)
    try:
        p = ServerProtocol(klass)
        stdio.StandardIO(p)
        reactor.run()
    finally:
        termios.tcsetattr(fd, termios.TCSANOW, oldSettings)
        os.write(fd, "\r\x1bc\r") 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:13,代码来源:stdio.py

示例10: setUp

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def setUp(self):
        self.underlyingTransport = StringTransport()
        self.pt = insults.ServerProtocol()
        self.p = recvline.HistoricRecvLine()
        self.pt.protocolFactory = lambda: self.p
        self.pt.factory = self
        self.pt.makeConnection(self.underlyingTransport)
        # self.p.makeConnection(self.pt) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:10,代码来源:test_recvline.py

示例11: runWithProtocol

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def runWithProtocol(klass):
    fd = sys.__stdin__.fileno()
    oldSettings = termios.tcgetattr(fd)
    tty.setraw(fd)
    try:
        p = ServerProtocol(klass)
        stdio.StandardIO(p)
        reactor.run()
    finally:
        termios.tcsetattr(fd, termios.TCSANOW, oldSettings)
        os.write(0, "\r\x1bc\r") 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:13,代码来源:stdio.py

示例12: runTextServer

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def runTextServer(reactor, *argv):
    """
    Run a L{ConsoleTextServer}.
    """
    textServer = makeTextServer(reactor, *argv)
    StandardIO(ServerProtocol(lambda: textServer))
    return textServer.done 
开发者ID:twisted,项目名称:imaginary,代码行数:9,代码来源:__main__.py

示例13: test_connectionMadePrompt

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def test_connectionMadePrompt(self):
        """
        L{CharacterSelectionTextServer} prompts the player upon connection,
        giving them the option to create a character.
        """
        testWorld = buildWorld(self)
        transport = StringTransport()
        terminal = ServerProtocol(lambda: testWorld.proto)
        terminal.makeConnection(transport)
        self.assertIn("0) Create", transport.io.getvalue()) 
开发者ID:twisted,项目名称:imaginary,代码行数:12,代码来源:test_wiring.py

示例14: openShell

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def openShell(self, protocol):
        server_protocol = insults.ServerProtocol(SwitchSSHShell, self, switch_core=self.switch_core)
        server_protocol.makeConnection(protocol)
        protocol.makeConnection(session.wrapProtocol(server_protocol)) 
开发者ID:internap,项目名称:fake-switches,代码行数:6,代码来源:ssh_service.py

示例15: makeDebugCLIService

# 需要导入模块: from twisted.conch.insults import insults [as 别名]
# 或者: from twisted.conch.insults.insults import ServerProtocol [as 别名]
def makeDebugCLIService(self, args):
        """
        This is dangerous, and should only ever be enabled by explicit user config and only for non-production use

        :param args:
        :return:
        """

        f = protocol.ServerFactory()
        f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
                                             insults.ServerProtocol,
                                             args['protocolFactory'],
                                             *args.get('protocolArgs', ()),
                                             **args.get('protocolKwArgs', {}))
        return internet.TCPServer(args['telnet'], f) 
开发者ID:anchore,项目名称:anchore-engine,代码行数:17,代码来源:twisted.py


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