Missing parameter in guess_country()
This commit is contained in:
parent
d4c2fd61aa
commit
9d984957fe
|
|
@ -752,7 +752,7 @@ def get_external_ip(*positionals, **kwargs):
|
||||||
result = urllib.request.urlopen("https://hvornum.se/ip/?f=json").read().decode('UTF-8')
|
result = urllib.request.urlopen("https://hvornum.se/ip/?f=json").read().decode('UTF-8')
|
||||||
return json.loads(result)['ip']
|
return json.loads(result)['ip']
|
||||||
|
|
||||||
def guess_country(*positionals, **kwargs):
|
def guess_country(ip, *positionals, **kwargs):
|
||||||
# python-pygeoip
|
# python-pygeoip
|
||||||
# geoip-database
|
# geoip-database
|
||||||
result = None
|
result = None
|
||||||
|
|
@ -761,6 +761,7 @@ def guess_country(*positionals, **kwargs):
|
||||||
try:
|
try:
|
||||||
import pygeoip
|
import pygeoip
|
||||||
except:
|
except:
|
||||||
|
## TODO: Do a best-effort-guess based off the hostname given off the IP instead, if GoeIP doesn't exist.
|
||||||
return result
|
return result
|
||||||
|
|
||||||
gi = pygeoip.GeoIP(GEOIP_DB)
|
gi = pygeoip.GeoIP(GEOIP_DB)
|
||||||
|
|
@ -818,9 +819,7 @@ def setup_args_defaults(args, interactive=True):
|
||||||
country = None
|
country = None
|
||||||
if get_default_gateway_linux():
|
if get_default_gateway_linux():
|
||||||
ip = get_external_ip()
|
ip = get_external_ip()
|
||||||
print('IP:', ip)
|
|
||||||
country = guess_country(ip)
|
country = guess_country(ip)
|
||||||
print('Country:', country)
|
|
||||||
args['country'] = 'all' if not country else country
|
args['country'] = 'all' if not country else country
|
||||||
if not 'localtime' in args: args['localtime'] = 'Europe/Stockholm' if args['country'] == 'SE' else 'GMT+0' # TODO: Arbitrary for now
|
if not 'localtime' in args: args['localtime'] = 'Europe/Stockholm' if args['country'] == 'SE' else 'GMT+0' # TODO: Arbitrary for now
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue