def checkreachable(self, host, port, timeout): """Check if host:port reachable over TCP in timeout seconds""" from tcppinger import tcppinger import sys assert timeout pinger = tcppinger(timeout) if not pinger.pingable(host, port): print "Error on %s: could not connect to port %d within %d secs" % \ (host, port, timeout) sys.exit(1)
def run(self): from tcppinger import tcppinger try: if self.flags["timeout"]: pinger = tcppinger(self.flags["timeout"]) if not pinger.pingable(self.ip, nodemgr.HTTPPORT): raise "Could not connect to %s" % self.ip outarg = apply(self.method, self.inargs[self.ip]) self.outargs[self.ip] = outarg except: print "Error on %s: %s" % (self.ip, sys.exc_info()) else: print "Success on %s" % self.ip self.sem.release()