Peter Westlake
2015-08-25 16:27:34 UTC
I'm making a manhole service in the usual way:
class PF(ServerProtocol):Â Â Â Â Â Â Â def protocolFactory(*a, **kw):
return manhole.Manhole(namespace)
realm = manhole_ssh.TerminalRealm()Â Â Â realm.chainedProtocolFactory = PF
mh_portal = portal.Portal(realm)Â Â Â mh_portal.registerChecker(checker)
manhole_service = TCPServer(0, manhole_ssh.ConchFactory(mh_portal))
manhole_service.startService()
and I'd like to print a message when the terminal is opened. This
change does it:
class PF(ServerProtocol):Â Â Â Â Â Â Â def protocolFactory(*a, **kw):
class Manhole(manhole.Manhole):Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â def connectionMade(self):
super(Manhole, self).connectionMade()
self.terminal.write('Hello')Â Â Â Â Â Â Â Â Â Â Â return
manhole.Manhole(namespace)
and so does this version, which is better because
t.c.i.i.ServerProtocol.connectionMade says it is the place to
write messages:
class PF(ServerProtocol):Â Â Â Â Â Â Â def protocolFactory(*a, **kw):
return manhole.Manhole(namespace)
def connectionMade(self):Â Â Â Â Â Â Â Â Â Â Â ServerProtocol.connectionMade(self)
self.write('Hello')
But in both cases, after the message the screen is cleared by what looks
like a form feed, and another prompt is printed. So far I can't find
where in the code this happens. Is there a way to print a message and
not have it scrolled off the screen?
Thanks,
Peter.
class PF(ServerProtocol):Â Â Â Â Â Â Â def protocolFactory(*a, **kw):
return manhole.Manhole(namespace)
realm = manhole_ssh.TerminalRealm()Â Â Â realm.chainedProtocolFactory = PF
mh_portal = portal.Portal(realm)Â Â Â mh_portal.registerChecker(checker)
manhole_service = TCPServer(0, manhole_ssh.ConchFactory(mh_portal))
manhole_service.startService()
and I'd like to print a message when the terminal is opened. This
change does it:
class PF(ServerProtocol):Â Â Â Â Â Â Â def protocolFactory(*a, **kw):
class Manhole(manhole.Manhole):Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â def connectionMade(self):
super(Manhole, self).connectionMade()
self.terminal.write('Hello')Â Â Â Â Â Â Â Â Â Â Â return
manhole.Manhole(namespace)
and so does this version, which is better because
t.c.i.i.ServerProtocol.connectionMade says it is the place to
write messages:
class PF(ServerProtocol):Â Â Â Â Â Â Â def protocolFactory(*a, **kw):
return manhole.Manhole(namespace)
def connectionMade(self):Â Â Â Â Â Â Â Â Â Â Â ServerProtocol.connectionMade(self)
self.write('Hello')
But in both cases, after the message the screen is cleared by what looks
like a form feed, and another prompt is printed. So far I can't find
where in the code this happens. Is there a way to print a message and
not have it scrolled off the screen?
Thanks,
Peter.