rendered paste bodyclass tests(object): def __init__(self): print "Starting client" hostname = socket.gethostname().split('.')[0] config = ConfigParser.ConfigParser() config.read("config") for section in config.sections(): if section == "defaults": for option in config.options(section): print " ", option, "=", config.get(section, option) setattr(self, option, config.get(section, option)) if section == hostname: for option in config.options(section): print " ", option, "=", config.get(section, option) setattr(self, option, config.get(section, option)) def runTests(self): self.connect().addCallback( lambda _: self.sayHello()).addCallback( lambda _: self.report_load()).addErrback(self._catchFailure).addCallback( lambda _: reactor.stop() ) def connect(self): factory = pb.PBClientFactory() reactor.connectTCP("localhost",8789, factory) return factory.getRootObject().addCallback(self._connected) def _connected(self, rootObj): self.remote_hello = rootObj self.remote_report_load = rootObj def sayHello(self): print "Calling hello" return self.remote_hello.callRemote('hello') def report_load(self): loadavg_file = open("/proc/loadavg","r") loadavg_line = loadavg_file.readline() loadavg = loadavg_line.split()[0:3] print "Calling report_load..." hostname = socket.gethostname().split('.')[0] return self.remote_report_load.callRemote('report_load',hostname,loadavg) def report_swap(self): output = commands.getoutput("free") print "Output:\n" print output# def report_disk(self):## def report_processes(self):def main(): t = tests() t.runTests() pdb.set_trace() reactor.run()if __name__ == "__main__": main()