def gethost(ip): if ip in ipcache: return ipcache[ip] try: ipcache[ip]=host(ip).split(' ')[-1][:-2] return ipcache[ip] except ErrorReturnCode_1: ipcache[ip]='' return ''
def getip(hostname): if hostname in hostcache: return hostcache[hostname] try: res=[tmp.split()[-1] for tmp in host(hostname).split('\n') if tmp] hostcache[hostname]=res return res except ErrorReturnCode_1: return ''
def hostip(self, url): hostname = self.hostfromurl(url) hostanswer = sh.host(hostname) hostip = "" if "not found" in hostanswer: hostip = "nf" else: self.debug(hostanswer) hostanswer = hostanswer.split("\n") hostanswer = hostanswer[0].split(" ") hostip = hostanswer[3] return hostname, hostip
def hostexist(self, url): hostname = self.hostfromurl(url) self.debug("Hostname: " + hostname) checkhost = "" try: checkhost = str(sh.host(hostname)) except Exception as ex: print "no host", ex self.debug("Reply from host command: " + checkhost) if "not found" in checkhost or checkhost == "": return False else: return True