add geo location finder
This commit is contained in:
24
w.py
24
w.py
@@ -1,19 +1,35 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# TODO: aliast in bashrc
|
# TODO, fetch the ipgeolocation, and basically compare against databse from xml on vedur - fetch the data and make an array
|
||||||
# TODO pass argv to set time interval and maybe even the location ;D
|
|
||||||
# FIXME, there is a bug with NULL/None values
|
# FIXME, there is a bug with NULL/None values
|
||||||
import requests, os, sys
|
import requests, os, sys, re, json
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
import urllib
|
import urllib
|
||||||
from datetime import date, datetime, time, timedelta
|
from datetime import date, datetime, time, timedelta
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
import platform
|
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')
|
os.system('clear')
|
||||||
|
|
||||||
location = 1 # Reykjavik
|
location = 1 # Reykjavik
|
||||||
|
|
||||||
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
justnow = datetime.strptime(now, "%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 = Notify.Notification.new("Vedur.is", notification_text)
|
||||||
Hello.show()
|
Hello.show()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
Reference in New Issue
Block a user