class Node: def __init__(self, address, port = 5000, authKey = "terry.xu"): from RPCRunner import Shell, ShellManager ShellManager.register('Shell', Shell) self.manager = ShellManager(address = (address, port), authkey = authKey) self.manager.connect() self.sh = self.manager.Shell() self.address = address self.port = port self.authKey = authKey print self, "init ok" def close(self): return "%s closed" % (self,) def __str__(self): return self.address def run(self, cmd): return os.linesep.join(["%s Execute: %s" % (self, cmd), "-" * 20, self.sh.run(cmd), "-" * 40, '']) def kill(self, pid, all = False): return os.linesep.join(["%s Kill %s %s:" % (self, all, pid), "-" * 20, self.sh.kill(pid, all), "-" * 40, ''])