add geo location finder

This commit is contained in:
2017-07-16 11:57:05 +00:00
parent 461734a2ff
commit e995e76abb

24
w.py
View File

@@ -1,19 +1,35 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# TODO: aliast in bashrc
# TODO pass argv to set time interval and maybe even the location ;D
# TODO, fetch the ipgeolocation, and basically compare against databse from xml on vedur - fetch the data and make an array
# FIXME, there is a bug with NULL/None values
import requests, os, sys
import requests, os, sys, re, json
from xml.etree import ElementTree
import urllib
from datetime import date, datetime, time, timedelta
from pprint import pprint
import platform
from urllib2 import urlopen
url = 'http://ipinfo.io/json'
response = urlopen(url)
data = json.load(response)
IP=data['ip']
org=data['org']
city = data['city']
country=data['country']
region=data['region']
print 'Your IP detail\n '
print 'IP : {4} \nRegion : {1} \nCountry : {2} \nCity : {3} \nOrg : {0}'.format(org,region,country,city,IP)
os.system('clear')
location = 1 # Reykjavik
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
justnow = datetime.strptime(now, "%Y-%m-%d %H:%M:%S")
@@ -99,4 +115,4 @@ if os.name is "posix" and platform.system() == "Linux":
Hello = Notify.Notification.new("Vedur.is", notification_text)
Hello.show()
sys.exit()
sys.exit()