Fix relay lookup failure using geoip
This commit is contained in:
parent
cd56692834
commit
a312edabb8
1 changed files with 6 additions and 3 deletions
|
@ -2,12 +2,15 @@ import os
|
||||||
import tarfile
|
import tarfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timezone
|
|
||||||
import geoip2.database
|
import geoip2.database
|
||||||
from influxdb import InfluxDBClient
|
|
||||||
import requests
|
import requests
|
||||||
import configuration
|
import configuration
|
||||||
|
|
||||||
|
from geoip2.errors import AddressNotFoundError
|
||||||
|
from influxdb import InfluxDBClient
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
|
||||||
CURRENT_TIME = datetime.now(timezone.utc).astimezone().isoformat()
|
CURRENT_TIME = datetime.now(timezone.utc).astimezone().isoformat()
|
||||||
|
|
||||||
PAYLOAD = {'apikey': configuration.tautulli_api_key, 'cmd': 'get_activity'}
|
PAYLOAD = {'apikey': configuration.tautulli_api_key, 'cmd': 'get_activity'}
|
||||||
|
@ -74,7 +77,7 @@ INFLUX_PAYLOAD = [
|
||||||
for session in SESSIONS.keys():
|
for session in SESSIONS.keys():
|
||||||
try:
|
try:
|
||||||
geodata = geo_lookup(SESSIONS[session]['ip_address_public'])
|
geodata = geo_lookup(SESSIONS[session]['ip_address_public'])
|
||||||
except (ValueError, geoip2.errors.AddressNotFoundError):
|
except (ValueError, AddressNotFoundError):
|
||||||
if configuration.tautulli_failback_ip:
|
if configuration.tautulli_failback_ip:
|
||||||
geodata = geo_lookup(configuration.tautulli_failback_ip)
|
geodata = geo_lookup(configuration.tautulli_failback_ip)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue