Add sanity check for ip_address_public
This commit is contained in:
parent
eb3f6bffa8
commit
c16262aba6
1 changed files with 11 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from requests import Session, Request
|
from requests import Session, Request
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from geoip2.errors import AddressNotFoundError
|
from geoip2.errors import AddressNotFoundError
|
||||||
|
@ -38,7 +40,16 @@ class TautulliAPI(object):
|
||||||
self.logger.error('TypeError has occurred : %s while creating TautulliStream structure', e)
|
self.logger.error('TypeError has occurred : %s while creating TautulliStream structure', e)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for session in sessions:
|
for session in sessions:
|
||||||
|
# Check to see if ip_address_public atribute exists as it was introduced in v2
|
||||||
|
try:
|
||||||
|
getattr(session, 'ip_address_public')
|
||||||
|
except AttributeError:
|
||||||
|
self.logger.error('Public IP attribute missing!!! Do you have an old version of Tautulli (v1)?')
|
||||||
|
os._exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
geodata = geo_lookup(session.ip_address_public, self.data_folder)
|
geodata = geo_lookup(session.ip_address_public, self.data_folder)
|
||||||
except (ValueError, AddressNotFoundError):
|
except (ValueError, AddressNotFoundError):
|
||||||
|
|
Loading…
Reference in a new issue