fix: update platform script (#9479)

* fix: update platform script

* perf: check protocol setting

---------

Co-authored-by: Eric <xplzv@126.com>
pull/9480/head
fit2bot 2 years ago committed by GitHub
parent 4f6a17290a
commit c7c5805b18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -93,14 +93,21 @@ class WebAPP(object):
self.asset = asset
self.account = account
self.platform = platform
self.extra_data = self.asset.spec_info
self._steps = list()
autofill_type = self.asset.spec_info.autofill
extra_data = self.asset.spec_info
autofill_type = extra_data.autofill
if not autofill_type:
protocol_setting = self.platform.get_protocol_setting("http")
if not protocol_setting:
print("No protocol setting found")
return
extra_data = protocol_setting
autofill_type = extra_data.autofill
if autofill_type == "basic":
self._steps = self._default_custom_steps()
self._steps = self._default_custom_steps(extra_data)
elif autofill_type == "script":
script_list = self.asset.spec_info.script
script_list = extra_data.script
steps = sorted(script_list, key=lambda step_item: step_item.step)
for item in steps:
val = item.value
@ -110,9 +117,8 @@ class WebAPP(object):
item.value = val
self._steps.append(item)
def _default_custom_steps(self) -> list:
def _default_custom_steps(self, spec_info) -> list:
account = self.account
spec_info = self.asset.spec_info
default_steps = [
Step({
"step": 1,

@ -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):

Loading…
Cancel
Save