python gtk-3 examples

Example 1: python pygeoip example

def main(argv):
    parseargs(argv)
    print(BANNER.format(APP_NAME, VERSION))

    print("[+] Resolving host...")
    host = gethostaddr()
    if (host is None or not host):
       print("[!] Unable to resolve host {}".format(target))
       print("[!] Make sure the host is up: ping -c1 {}\n".format(target))
       sys.exit(0)

    print("[+] Host {} has address: {}".format(target, host))
    print("[+] Tracking host...")

    query = pygeoip.GeoIP(DB_FILE)
    result = query.record_by_addr(host)

    if (result is None or not result):
        print("[!] Host location not found")
        sys.exit(0)

    print("[+] Host location found:")
    print json.dumps(result, indent=4, sort_keys=True, ensure_ascii=False, encoding="utf-8")

Example 2: python pygeoip example

def geo_ip(host):

    try:

       rawdata = pygeoip.GeoIP('GeoLiteCity.dat')
       data = rawdata.record_by_name(host)	
       country = data['country_name']
       city = data['city']
       longi = data['longitude']
       lat = data['latitude']
       time_zone = data['time_zone']
       area_code = data['area_code']
       country_code = data['country_code']
       region_code = data['region_code']
       dma_code = data['dma_code']
       metro_code = data['metro_code']
       country_code3 = data['country_code3']
       zip_code = data['postal_code']
       continent = data['continent']

       print '[*] IP Address: ',host
       print '[*] City: ',city
       print '[*] Region Code: ',region_code
       print '[*] Area Code: ',area_code
       print '[*] Time Zone: ',time_zone
       print '[*] Dma Code: ',dma_code
       print '[*] Metro Code: ',metro_code
       print '[*] Latitude: ',lat
       print '[*] Longitude: ',longi
       print '[*] Zip Code: ',zip_code
       print '[*] Country Name: ',country
       print '[*] Country Code: ',country_code
       print '[*] Country Code3: ',country_code3
       print '[*] Continent: ',continent

    except :
           print "[*] Please verify your ip !"