diff --git a/w.py b/w.py index 8108214..5a957e5 100644 --- a/w.py +++ b/w.py @@ -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() \ No newline at end of file +sys.exit()