From 5459ac607f9007e07011a8e8e6f2544c46da4423 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Sat, 11 Aug 2018 03:00:30 -0400 Subject: [PATCH] Fix Geoip2 DB to be full paths --- tautulli.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tautulli.py b/tautulli.py index 214450a..41a1bd7 100644 --- a/tautulli.py +++ b/tautulli.py @@ -19,13 +19,16 @@ sessions = {d['session_id']: d for d in activity['sessions']} def GeoLite2db(ipaddress): - dbfile = 'GeoLite2-City.mmdb' + tar_dbfile = '{}/GeoLite2-City.tar.gz'.format(os.path.dirname(os.path.realpath(__file__))) - if not os.path.isfile('GeoLite2-City.mmdb'): - urllib.request.urlretrieve('http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz', 'GeoLite2-City.tar.gz') - tar = tarfile.open('GeoLite2-City.tar.gz', "r:gz") + dbfile = '{}/GeoLite2-City.mmdb'.format(os.path.dirname(os.path.realpath(__file__))) + + if not os.path.isfile(dbfile): + urllib.request.urlretrieve('http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz', tar_dbfile) + + tar = tarfile.open(tar_dbfile, "r:gz") for files in tar.getmembers(): - if dbfile in files.name: + if 'GeoLite2-City.mmdb' in files.name: files.name = os.path.basename(files.name) tar.extract(files, '{}/'.format(os.path.dirname(os.path.realpath(__file__))))