From fc1b69e1d12d60dd8ca8acec66dafe0fb35e72de Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 11 Jul 2012 17:09:17 -0400 Subject: [PATCH] CC-4092: Not checking for return type "None" on some function calls in media-monitor -more fixes --- python_apps/api_clients/api_client.py | 4 ++-- .../airtimefilemonitor/airtimemediamonitorbootstrap.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 97d054ed5..ea9ea993f 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -456,8 +456,8 @@ class AirTimeApiClient(ApiClientInterface): logger.error("Exception: %s", e) try: - return getattr(response, "files") - except AttributeError: + return response["files"] + except KeyError: self.logger.error("Could not find index 'files' in dictionary: %s", str(response)) return [] diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py b/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py index 5f0b9c5b8..3dd7fc9bb 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py @@ -69,12 +69,11 @@ class AirtimeMediaMonitorBootstrap(): json = self.api_client.list_all_watched_dirs() try: - dirs = getattr(json, "dirs") - except AttributeError: - self.logger.error("Could not find index 'dirs' in dictionary: %s", str(dirs)) + return json["dirs"] + except KeyError as e: + self.logger.error("Could not find index 'dirs' in dictionary: %s", str(json)) + self.logger.error(e) return {} - - return dirs """ This function takes in a path name provided by the database (and its corresponding row id)