示例#1
0
文件: getentries.py 项目: stef/pywik
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 ''
示例#2
0
文件: bots.py 项目: stef/pywik
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 ''
示例#3
0
 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
示例#4
0
 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