本文整理汇总了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()
)
示例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)
示例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")
示例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)
示例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)
示例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)
示例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")
示例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)
示例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")
示例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)
示例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")
示例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
示例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())
示例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))
示例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)