class ShellPlugin(ProxyPlugin): """ Default plugin to allow use of a shell """ variables = ['escape_key'] def __init__(self, c, stdout, key): super(ShellPlugin, self).__init__(c) self.chat_header = packets_by_name["chat"] self.escape_key = key self.shell = ProxyShell(self, stdout) def packet(self, header, payload): if self._enabled: if header == self.chat_header: if payload.message[0] == self.escape_key: # our shell cannot handle unicode...just convert it to plain ascii msg = str(payload.message[1:]) self.shell.onecmd(msg)
def __init__(self, c, stdout, key): super(ShellPlugin, self).__init__(c) self.chat_header = packets_by_name["chat"] self.escape_key = key self.shell = ProxyShell(self, stdout)