From e2b9b12613a9f53e07256e829336e642118eff56 Mon Sep 17 00:00:00 2001 From: nineven Date: Thu, 19 May 2022 07:37:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=BE=A9=E8=BD=AC=E6=8D=A2=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/common/core/sysconfig.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fir_ser/common/core/sysconfig.py b/fir_ser/common/core/sysconfig.py index c3d3adc..77cacbd 100644 --- a/fir_ser/common/core/sysconfig.py +++ b/fir_ser/common/core/sysconfig.py @@ -70,12 +70,16 @@ class ConfigCacheBase(object): logger.warning(f"db config - render failed {e}") except Exception as e: logger.warning(f"db config - render failed {e}") + try: + value = json.loads(value) + except Exception as e: + logger.warning(f"db config - json loads failed {e}") if isinstance(value, str): + if value.isdigit(): + return int(value) v_group = re.findall('"(.*?)"', value) if v_group and len(v_group) == 1 and v_group[0].isdigit(): return int(v_group[0]) - if value.isdigit(): - return int(value) return value def get_value_from_db(self, key): @@ -102,10 +106,6 @@ class ConfigCacheBase(object): db_data['value'] = json.dumps(data) db_data['key'] = key db_data['value'] = self.get_render_value(db_data['value']) - try: - db_data['value'] = json.loads(db_data['value']) - except Exception as e: - logger.warning(f"db config - json loads failed {e}") cache.set_storage_cache(db_data, timeout=self.timeout) return db_data.get('value')