Skip to content

Commit

Permalink
fix(api/category): plugin init_settings add more detail in log info (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wklken authored May 11, 2022
1 parent cdc79bc commit 83b1d8a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/api/bkuser_core/categories/plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,20 @@ def init_settings(self, setting_meta_key: str, meta_info: dict):
# 理论上目录不能够被直接恢复, 所以已经被删除的目录不会被更新
# 仅做新增,避免覆盖已有配置
for category in ProfileCategory.objects.filter(type=self.category_type, enabled=True):
ins, created = Setting.objects.get_or_create(
meta=meta, category_id=category.id, defaults={"value": meta.default}
)
if created:
logger.debug("\n------ Setting<%s> of category<%s> created.", ins, category)
try:
ins, created = Setting.objects.get_or_create(
meta=meta, category_id=category.id, defaults={"value": meta.default}
)
if created:
logger.debug("\n------ Setting<%s> of category<%s> created.", ins, category)
except Exception: # pylint: disable=broad-except
logger.exception(
"Setting default of meta<%s>, category_id<%s>, defaults<%s> can not been created.",
meta,
category.id,
meta.default,
)
continue

def load_settings_from_yaml(self):
"""从 yaml 中加载 SettingMeta 配置"""
Expand Down

0 comments on commit 83b1d8a

Please sign in to comment.