mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-04 17:01:09 +00:00
fix: update platform script (#9479)
* fix: update platform script * perf: check protocol setting --------- Co-authored-by: Eric <xplzv@126.com>
This commit is contained in:
@@ -77,15 +77,18 @@ def wait_pid(pid):
|
||||
break
|
||||
|
||||
|
||||
class DictObj:
|
||||
def __init__(self, in_dict: dict):
|
||||
assert isinstance(in_dict, dict)
|
||||
for key, val in in_dict.items():
|
||||
class DictObj(dict):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
for key, val in self.items():
|
||||
if isinstance(val, (list, tuple)):
|
||||
setattr(self, key, [DictObj(x) if isinstance(x, dict) else x for x in val])
|
||||
else:
|
||||
setattr(self, key, DictObj(val) if isinstance(val, dict) else val)
|
||||
|
||||
def __getattr__(self, item):
|
||||
return self.get(item, None)
|
||||
|
||||
|
||||
class User(DictObj):
|
||||
id: str
|
||||
@@ -151,11 +154,32 @@ class Account(DictObj):
|
||||
secret_type: LabelValue
|
||||
|
||||
|
||||
class ProtocolSetting(DictObj):
|
||||
autofill: str
|
||||
username_selector: str
|
||||
password_selector: str
|
||||
submit_selector: str
|
||||
script: list[Step]
|
||||
|
||||
|
||||
class PlatformProtocolSetting(DictObj):
|
||||
name: str
|
||||
port: int
|
||||
setting: ProtocolSetting
|
||||
|
||||
|
||||
class Platform(DictObj):
|
||||
id: str
|
||||
name: str
|
||||
charset: LabelValue
|
||||
type: LabelValue
|
||||
protocols: list[PlatformProtocolSetting]
|
||||
|
||||
def get_protocol_setting(self, protocol):
|
||||
for item in self.protocols:
|
||||
if item.name == protocol:
|
||||
return item.setting
|
||||
return None
|
||||
|
||||
|
||||
class Manifest(DictObj):
|
||||
|
Reference in New Issue
Block a user