Commit 2b37cb9b authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Updated a deprecated function call, added new submodule "network".

- updated __version__
parent b8887bc1
......@@ -15,7 +15,7 @@ __all__=[#'compatibility',
'similarity',
'GeoArray']
__version__ = '20170405_01'
__version__ = '20170422_01'
__author__='Daniel Scheffler'
# Validate GDAL version
......
......@@ -19,4 +19,4 @@ def calc_ssim(image0, image1, dynamic_range=None, win_size=None, gaussian_weight
image0 = image0.astype(np.int16)
image1 = image1.astype(np.int16)
return ssim(image0, image1, dynamic_range=dynamic_range, win_size=win_size, gaussian_weights=gaussian_weights)
\ No newline at end of file
return ssim(image0, image1, data_range=dynamic_range, win_size=win_size, gaussian_weights=gaussian_weights)
\ No newline at end of file
import six
import json
import socket
if six.PY2:
from urllib import urlopen
else:
from urllib.request import urlopen
def get_geoinfo():
"""Returns a dictionary containing country, city, longitude, latitude and IP of the executing host."""
url = 'http://ipinfo.io/json'
info = json.loads(urlopen(url).read())
ip = info['ip']
urlFoLaction = "http://www.freegeoip.net/json/{0}".format(ip)
locationInfo = json.loads(urlopen(urlFoLaction).read())
return dict(
Country = locationInfo['country_name'],
City = locationInfo['city'],
Latitude = str(locationInfo['latitude']),
Longitude = str(locationInfo['longitude']),
IP = str(locationInfo['ip'])
)
def is_connected(REMOTE_SERVER = "www.google.com"):
"""Checks if an internet connection is present."""
try:
# see if we can resolve the host name -- tells us if there is
# a DNS listening
host = socket.gethostbyname(REMOTE_SERVER)
# connect to the host -- tells us if the host is actually
# reachable
socket.create_connection((host, 80), 2)
return True
except:
pass
return False
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment