From 50e6c963588275a8676126c777c4e63e0aa3a437 Mon Sep 17 00:00:00 2001 From: Bai Date: Fri, 5 Feb 2021 17:05:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20component=20status?= =?UTF-8?q?=20=E8=8E=B7=E5=8F=96key=20error=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/models/terminal.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/terminal/models/terminal.py b/apps/terminal/models/terminal.py index b8b44dfbc..48e225cfd 100644 --- a/apps/terminal/models/terminal.py +++ b/apps/terminal/models/terminal.py @@ -6,10 +6,14 @@ from django.utils.translation import ugettext_lazy as _ from django.conf import settings from django.core.cache import cache +from common.utils import get_logger from users.models import User from .. import const +logger = get_logger(__file__) + + class ComputeStatusMixin: # system status @@ -40,7 +44,11 @@ class ComputeStatusMixin: ] system_status = [] for system_status_key in system_status_keys: - state_value = state[system_status_key] + state_value = state.get(system_status_key) + if state_value is None: + msg = 'state: {}, state_key: {}, state_value: {}' + logger.debug(msg.format(state, system_status_key, state_value)) + state_value = 0 status = getattr(self, f'_compute_{system_status_key}_status')(state_value) system_status.append(status) return system_status