Browse Source

perf: Navicat为xpack功能 (#9650)

* perf: Navicat移动到xpack功能

* 优化

* fix: 去掉多余的import

* perf: 优化逻辑

* perf: 修改打印位置
pull/9649/head
jiangweidong 2 years ago committed by GitHub
parent
commit
b5347be4e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/terminal/applets/__init__.py
  2. 4
      apps/terminal/models/applet/applet.py

4
apps/terminal/applets/__init__.py

@ -11,9 +11,9 @@ def install_or_update_builtin_applets():
path = os.path.join(BASE_DIR, d) path = os.path.join(BASE_DIR, d)
if not os.path.isdir(path) or not os.path.exists(os.path.join(path, 'manifest.yml')): if not os.path.isdir(path) or not os.path.exists(os.path.join(path, 'manifest.yml')):
continue continue
print("Install or update applet: {}".format(path))
try: try:
Applet.install_from_dir(path) if Applet.install_from_dir(path):
print("Install or update applet: {}".format(path))
except Exception as e: except Exception as e:
print(e) print(e)

4
apps/terminal/models/applet/applet.py

@ -12,6 +12,7 @@ from rest_framework.serializers import ValidationError
from common.db.models import JMSBaseModel from common.db.models import JMSBaseModel
from common.utils import lazyproperty, get_logger from common.utils import lazyproperty, get_logger
from jumpserver.utils import has_valid_xpack_license
logger = get_logger(__name__) logger = get_logger(__name__)
@ -95,6 +96,9 @@ class Applet(JMSBaseModel):
manifest = cls.validate_pkg(path) manifest = cls.validate_pkg(path)
name = manifest['name'] name = manifest['name']
if not has_valid_xpack_license() and name.lower() in ('navicat', ):
return
instance = cls.objects.filter(name=name).first() instance = cls.objects.filter(name=name).first()
serializer = AppletSerializer(instance=instance, data=manifest) serializer = AppletSerializer(instance=instance, data=manifest)
serializer.is_valid() serializer.is_valid()

Loading…
Cancel
Save