From 819361053240c1f50e37ef7cd7b1c8d6f9941369 Mon Sep 17 00:00:00 2001 From: Yumeng Bao Date: Mon, 30 Jul 2018 19:58:39 +0800 Subject: [PATCH] fix indicator exception When the indicator is none, there could be exception. This patch could avoid this exception. Change-Id: Ia243197ccab149a26f8bdf092b190c2c29c03ee5 --- watcher_dashboard/api/watcher.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/watcher_dashboard/api/watcher.py b/watcher_dashboard/api/watcher.py index 0a2a456..0d66bda 100644 --- a/watcher_dashboard/api/watcher.py +++ b/watcher_dashboard/api/watcher.py @@ -516,7 +516,7 @@ class EfficacyIndicator(base.APIDictWrapper): def __init__(self, indicator): super(EfficacyIndicator, self).__init__(indicator) - self.value = indicator.get('value', None) - self.name = indicator.get('name', None) - self.description = indicator.get('description', None) - self.unit = indicator.get('unit', None) + self.value = getattr(indicator, 'value', None) + self.name = getattr(indicator, 'name', None) + self.description = getattr(indicator, 'description', None) + self.unit = getattr(indicator, 'unit', None)