mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-13 00:32:58 -07:00
Fix regression PMS down notifications failing
This commit is contained in:
parent
74a232630a
commit
4b0eab57a8
2 changed files with 10 additions and 17 deletions
|
@ -463,12 +463,8 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
||||||
plex_tv = plextv.PlexTV()
|
plex_tv = plextv.PlexTV()
|
||||||
server_times = plex_tv.get_server_times()
|
server_times = plex_tv.get_server_times()
|
||||||
|
|
||||||
# Get the server version
|
|
||||||
pms_connect = pmsconnect.PmsConnect()
|
|
||||||
server_identity = pms_connect.get_server_identity()
|
|
||||||
|
|
||||||
if server_times:
|
if server_times:
|
||||||
updated_at = server_times[0]['updated_at']
|
updated_at = server_times['updated_at']
|
||||||
server_uptime = helpers.human_duration(int(time.time() - helpers.cast_to_int(updated_at)))
|
server_uptime = helpers.human_duration(int(time.time() - helpers.cast_to_int(updated_at)))
|
||||||
else:
|
else:
|
||||||
logger.error(u"PlexPy NotificationHandler :: Unable to retrieve server uptime.")
|
logger.error(u"PlexPy NotificationHandler :: Unable to retrieve server uptime.")
|
||||||
|
@ -653,7 +649,7 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
||||||
available_params = {# Global paramaters
|
available_params = {# Global paramaters
|
||||||
'server_name': server_name,
|
'server_name': server_name,
|
||||||
'server_uptime': server_uptime,
|
'server_uptime': server_uptime,
|
||||||
'server_version': server_identity.get('version',''),
|
'server_version': server_times.get('version',''),
|
||||||
'action': notify_action.title(),
|
'action': notify_action.title(),
|
||||||
'datestamp': arrow.now().format(date_format),
|
'datestamp': arrow.now().format(date_format),
|
||||||
'timestamp': arrow.now().format(time_format),
|
'timestamp': arrow.now().format(time_format),
|
||||||
|
@ -931,16 +927,12 @@ def build_server_notify_text(notify_action=None, agent_id=None):
|
||||||
plex_tv = plextv.PlexTV()
|
plex_tv = plextv.PlexTV()
|
||||||
server_times = plex_tv.get_server_times()
|
server_times = plex_tv.get_server_times()
|
||||||
|
|
||||||
# Get the server version
|
|
||||||
pms_connect = pmsconnect.PmsConnect()
|
|
||||||
server_identity = pms_connect.get_server_identity()
|
|
||||||
|
|
||||||
update_status = {}
|
update_status = {}
|
||||||
if notify_action == 'pmsupdate':
|
if notify_action == 'pmsupdate':
|
||||||
update_status = pms_connect.get_update_staus()
|
update_status = pms_connect.get_update_staus()
|
||||||
|
|
||||||
if server_times:
|
if server_times:
|
||||||
updated_at = server_times[0]['updated_at']
|
updated_at = server_times['updated_at']
|
||||||
server_uptime = helpers.human_duration(int(time.time() - helpers.cast_to_int(updated_at)))
|
server_uptime = helpers.human_duration(int(time.time() - helpers.cast_to_int(updated_at)))
|
||||||
else:
|
else:
|
||||||
logger.error(u"PlexPy NotificationHandler :: Unable to retrieve server uptime.")
|
logger.error(u"PlexPy NotificationHandler :: Unable to retrieve server uptime.")
|
||||||
|
@ -963,7 +955,7 @@ def build_server_notify_text(notify_action=None, agent_id=None):
|
||||||
available_params = {# Global paramaters
|
available_params = {# Global paramaters
|
||||||
'server_name': server_name,
|
'server_name': server_name,
|
||||||
'server_uptime': server_uptime,
|
'server_uptime': server_uptime,
|
||||||
'server_version': server_identity.get('version',''),
|
'server_version': server_times.get('version',''),
|
||||||
'action': notify_action.title(),
|
'action': notify_action.title(),
|
||||||
'datestamp': arrow.now().format(date_format),
|
'datestamp': arrow.now().format(date_format),
|
||||||
'timestamp': arrow.now().format(time_format),
|
'timestamp': arrow.now().format(time_format),
|
||||||
|
|
|
@ -450,19 +450,20 @@ class PlexTV(object):
|
||||||
|
|
||||||
def get_server_times(self):
|
def get_server_times(self):
|
||||||
servers = self.get_plextv_server_list(output_format='xml')
|
servers = self.get_plextv_server_list(output_format='xml')
|
||||||
server_times = []
|
server_times = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
xml_head = servers.getElementsByTagName('Server')
|
xml_head = servers.getElementsByTagName('Server')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(u"PlexPy PlexTV :: Unable to parse XML for get_server_times: %s." % e)
|
logger.warn(u"PlexPy PlexTV :: Unable to parse XML for get_server_times: %s." % e)
|
||||||
return []
|
return {}
|
||||||
|
|
||||||
for a in xml_head:
|
for a in xml_head:
|
||||||
if helpers.get_xml_attr(a, 'machineIdentifier') == plexpy.CONFIG.PMS_IDENTIFIER:
|
if helpers.get_xml_attr(a, 'machineIdentifier') == plexpy.CONFIG.PMS_IDENTIFIER:
|
||||||
server_times.append({"created_at": helpers.get_xml_attr(a, 'createdAt'),
|
server_times = {"created_at": helpers.get_xml_attr(a, 'createdAt'),
|
||||||
"updated_at": helpers.get_xml_attr(a, 'updatedAt')
|
"updated_at": helpers.get_xml_attr(a, 'updatedAt'),
|
||||||
})
|
"version": helpers.get_xml_attr(a, 'version')
|
||||||
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
return server_times
|
return server_times
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue