From b5347be4e3cf4bf54fb466f3cdd1736e107cc763 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Tue, 21 Feb 2023 11:37:30 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20Navicat=E4=B8=BAxpack=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20(#9650)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: Navicat移动到xpack功能 * 优化 * fix: 去掉多余的import * perf: 优化逻辑 * perf: 修改打印位置 --- apps/terminal/applets/__init__.py | 4 ++-- apps/terminal/models/applet/applet.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/terminal/applets/__init__.py b/apps/terminal/applets/__init__.py index bb09feecd..0d8e50a3b 100644 --- a/apps/terminal/applets/__init__.py +++ b/apps/terminal/applets/__init__.py @@ -11,9 +11,9 @@ def install_or_update_builtin_applets(): path = os.path.join(BASE_DIR, d) if not os.path.isdir(path) or not os.path.exists(os.path.join(path, 'manifest.yml')): continue - print("Install or update applet: {}".format(path)) try: - Applet.install_from_dir(path) + if Applet.install_from_dir(path): + print("Install or update applet: {}".format(path)) except Exception as e: print(e) diff --git a/apps/terminal/models/applet/applet.py b/apps/terminal/models/applet/applet.py index 1fd8a670f..c71fe95c2 100644 --- a/apps/terminal/models/applet/applet.py +++ b/apps/terminal/models/applet/applet.py @@ -12,6 +12,7 @@ from rest_framework.serializers import ValidationError from common.db.models import JMSBaseModel from common.utils import lazyproperty, get_logger +from jumpserver.utils import has_valid_xpack_license logger = get_logger(__name__) @@ -95,6 +96,9 @@ class Applet(JMSBaseModel): manifest = cls.validate_pkg(path) name = manifest['name'] + if not has_valid_xpack_license() and name.lower() in ('navicat', ): + return + instance = cls.objects.filter(name=name).first() serializer = AppletSerializer(instance=instance, data=manifest) serializer.is_valid()