class LocalUrwidService(service.Service): """Simple Service wrapper for a Twisted-Urwid bridge.""" def __init__(self, bridge_factory): self.bridge_factory = bridge_factory self.log_buffer = [] def startService(self): self.protocol = UrwidTerminalProtocol(self.bridge_factory) self.stdio = StandardIO(self.protocol) for args in self.log_buffer: self.protocol.bridge.add_log_line(*args) def stopService(self): self.stdio.loseConnection() del self.protocol del self.stdio def add_log_line(self, line, color): """I exist to allow the urwid app to take over logging.""" try: add_log_line = self.protocol.bridge.add_log_line except AttributeError: self.log_buffer.append((line, color)) else: add_log_line(line, color)
class ConsoleServer(ServerScript): connection_class = None def on_load(self): self.console = ConsoleInput(self.server) self.io = StandardIO(self.console) def on_unload(self): self.io.loseConnection()
class ConsoleServer(ServerScript): connection_class = None def on_load(self): self.console = ConsoleInput(self.server) self.io = StandardIO(self.console) def on_unload(self): self.io.loseConnection()
class ConsoleServer(ServerScript): connection_class = None io = None def on_load(self): if not stdout.isatty(): return self.console = ConsoleInput(self.server) self.io = StandardIO(self.console) def on_unload(self): if self.io is None: return self.io.loseConnection()
class ConsoleServer(ServerScript): connection_class = None io = None def on_load(self): if not stdout.isatty(): return self.console = ConsoleInput(self.server) self.io = StandardIO(self.console) def on_unload(self): if self.io is None: return self.io.loseConnection()