feat(资产管理): 账号状态列 + 任务变量回写;通用任务 App 回退
- device_account 新增 account_status(schema v21),资产表可手改 - 任务「读取文字」var=account_status 自动回写当前账号;元素不存在=正常 - 计划:任务段没有 open_app 时回退到唯一 App(创作者中心这类通用任务) - 测试/文档同步
This commit is contained in:
@@ -24,6 +24,7 @@ from flask import Flask # noqa: E
|
||||
from core.models import db, init_db, DeviceAccount # noqa: E402
|
||||
from core import account_folder as af # noqa: E402
|
||||
from core import device_pool # noqa: E402
|
||||
from tasks.generic import task as gt # noqa: E402
|
||||
|
||||
fails = []
|
||||
|
||||
@@ -133,6 +134,49 @@ row = [x for x in af.roster_rows() if x["nickname"] == "锋哥苏州探店实录
|
||||
check("删得掉", af.delete_roster_row(row["id"]), True)
|
||||
check("删不存在的 → False", af.delete_roster_row("nope"), False)
|
||||
|
||||
print("▶ ⑤ 账号状态:手动写 + 任务变量回写")
|
||||
check("手动写状态", af.set_account_status("周周苏州吃喝玩乐", "账号异常"), True)
|
||||
check("roster_rows 带出状态",
|
||||
[x["account_status"] for x in af.roster_rows()
|
||||
if x["nickname"] == "周周苏州吃喝玩乐"], ["账号异常"])
|
||||
check("账号库里没有的号 → 不新建行",
|
||||
af.set_account_status("没这个号", "正常"), False)
|
||||
|
||||
|
||||
class _El:
|
||||
def __init__(self, flag, text=""):
|
||||
self._flag, self._text = flag, text
|
||||
|
||||
def wait(self, timeout=0):
|
||||
return self._flag
|
||||
|
||||
def get_text(self, timeout=None):
|
||||
return self._text
|
||||
|
||||
|
||||
class _D:
|
||||
def __init__(self, flag, text=""):
|
||||
self.flag, self.text = flag, text
|
||||
|
||||
def xpath(self, v):
|
||||
return _El(self.flag, self.text)
|
||||
|
||||
|
||||
w = gt.GenericStepsWorker("S1", {})
|
||||
w._vars["target_name"] = "周周苏州吃喝玩乐"
|
||||
p = {"selector_type": "xpath", "selector_value": "//x", "var": "account_status",
|
||||
"clean": "strip", "on_missing": "skip"}
|
||||
w._exec_read_text(_D(True, "账号异常"), p)
|
||||
db.session.expire_all()
|
||||
check("任务变量 account_status 回写账号库",
|
||||
DeviceAccount.query.filter_by(nickname="周周苏州吃喝玩乐").first().account_status,
|
||||
"账号异常")
|
||||
w._exec_read_text(_D(False, ""), p)
|
||||
db.session.expire_all()
|
||||
check("元素不存在 = 没检出异常 → 写「正常」",
|
||||
DeviceAccount.query.filter_by(nickname="周周苏州吃喝玩乐").first().account_status,
|
||||
"正常")
|
||||
|
||||
print()
|
||||
if fails:
|
||||
print("❌ 失败 %d 项:%s" % (len(fails), "、".join(fails)))
|
||||
|
||||
Reference in New Issue
Block a user