From 62c284fdd7eb7dbc9f40eb425615222c78c213ca Mon Sep 17 00:00:00 2001 From: shaun Date: Sat, 19 Nov 2016 10:08:36 +1100 Subject: [PATCH] add come verification to values passed into functions and returned from download calls dont log profile change exception bump ver --- addon.xml | 2 +- resources/lib/connect/connectionmanager.py | 3 +++ resources/lib/embydb_functions.py | 5 ++++- resources/lib/service_entry.py | 3 ++- resources/lib/views.py | 5 ++++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/addon.xml b/addon.xml index 1ca62726..45b04230 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/lib/connect/connectionmanager.py b/resources/lib/connect/connectionmanager.py index 74daca2d..968c146d 100644 --- a/resources/lib/connect/connectionmanager.py +++ b/resources/lib/connect/connectionmanager.py @@ -144,6 +144,9 @@ class ConnectionManager(object): def _updateServerInfo(self, server, systemInfo): + if server is None or systemInfo is None: + return + server['Name'] = systemInfo['ServerName'] server['Id'] = systemInfo['Id'] diff --git a/resources/lib/embydb_functions.py b/resources/lib/embydb_functions.py index 2c71e5d0..dd4ca55f 100644 --- a/resources/lib/embydb_functions.py +++ b/resources/lib/embydb_functions.py @@ -58,7 +58,10 @@ class Embydb_Functions(): def getView_embyId(self, item_id): # Returns ancestors using embyId url = "{server}/emby/Items/%s/Ancestors?UserId={UserId}&format=json" % item_id - for view in self.download(url): + view_list = self.download(url) + if view_list is None: + view_list = [] + for view in view_list: if view['Type'] == "CollectionFolder": # Found view diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index c58d8e3a..98ee700b 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -22,6 +22,7 @@ from views import VideoNodes from utils import window, settings, dialog, language as lang from ga_client import GoogleAnalytics import hashlib +import internal_exceptions ################################################################################################# @@ -106,7 +107,7 @@ class Service(object): # Profile change happened, terminate this thread and others log.info("Kodi profile was: %s and changed to: %s. Terminating old Emby thread.", kodi_profile, window('emby_kodiProfile')) - raise RuntimeError("Kodi profile changed detected") + raise internal_exceptions.ExceptionWrapper("Kodi profile changed detected") # Before proceeding, need to make sure: # 1. Server is online diff --git a/resources/lib/views.py b/resources/lib/views.py index fc738c21..79649e9e 100644 --- a/resources/lib/views.py +++ b/resources/lib/views.py @@ -54,7 +54,10 @@ class Views(object): def _populate_views(self): # Will get emby views and views in Kodi grouped_views = self.emby.get_views() - self.grouped_views = grouped_views['Items'] if "Items" in grouped_views else [] + if grouped_views is not None and "Items" in grouped_views: + self.grouped_views = grouped_views['Items'] + else: + self.grouped_views = [] for view in self.emby.getViews(sortedlist=True): self.views.append(view['name'])