feat: resolve/pick accounts by login_id or label
All checks were successful
技能自动化发布 / release (push) Successful in 11s
All checks were successful
技能自动化发布 / release (push) Successful in 11s
This commit is contained in:
@@ -59,23 +59,30 @@ def cmd_account_ensure_web(
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
lid = (login_id or "").strip() or None
|
||||
lab = (label or "").strip() or None
|
||||
|
||||
existing_count = count_active_accounts(
|
||||
platform_key=key,
|
||||
environment=environment,
|
||||
tenant_id=tenant_id,
|
||||
role=role,
|
||||
login_id=lid,
|
||||
label=lab,
|
||||
)
|
||||
created = False
|
||||
if existing_count == 0:
|
||||
create_env = (environment or "").strip() or "production"
|
||||
create_role = (role or "").strip() or "default"
|
||||
create_label = (label or "").strip() or None
|
||||
create_label = lab or None
|
||||
if not create_label:
|
||||
create_label = f"{key} 默认"
|
||||
if lid:
|
||||
create_label = f"{key} {lid}"
|
||||
|
||||
created_payload = create_web_account_record(
|
||||
platform_input,
|
||||
login_id,
|
||||
lid,
|
||||
login_id_type,
|
||||
create_label,
|
||||
tenant_id,
|
||||
@@ -95,16 +102,19 @@ def cmd_account_ensure_web(
|
||||
return
|
||||
created = True
|
||||
log.info(
|
||||
"account_ensure_web_created id=%s platform=%s profile_dir=%s",
|
||||
"account_ensure_web_created id=%s platform=%s login_id=%s profile_dir=%s",
|
||||
created_payload.get("id"),
|
||||
key,
|
||||
lid,
|
||||
created_payload.get("profile_dir"),
|
||||
)
|
||||
else:
|
||||
log.info(
|
||||
"account_ensure_web_reuse platform=%s existing_active=%s",
|
||||
"account_ensure_web_reuse platform=%s existing_active=%s login_id=%s label=%s",
|
||||
key,
|
||||
existing_count,
|
||||
lid,
|
||||
lab,
|
||||
)
|
||||
|
||||
# Capture pick output so we can annotate / remap lease-busy errors.
|
||||
@@ -121,6 +131,8 @@ def cmd_account_ensure_web(
|
||||
environment=environment,
|
||||
tenant_id=tenant_id,
|
||||
role=role,
|
||||
login_id=lid,
|
||||
label=lab,
|
||||
do_lease=do_lease,
|
||||
ttl_sec=ttl_sec,
|
||||
holder=holder,
|
||||
@@ -145,9 +157,10 @@ def cmd_account_ensure_web(
|
||||
err = (payload.get("error") or {}) if isinstance(payload.get("error"), dict) else {}
|
||||
code = str(err.get("code") or "")
|
||||
if code == "ERROR:NO_ACCOUNT" and existing_count > 0 and not created:
|
||||
scope = "该筛选条件下" if (lid or lab) else "该平台下"
|
||||
_say(_err_json(
|
||||
"ERROR:LEASE_CONFLICT",
|
||||
"该平台下已有账号,但均被其他任务占用。请稍后重试或释放租约;不会自动新建账号。",
|
||||
f"{scope}已有账号,但均被其他任务占用。请稍后重试或释放租约;不会自动新建账号。",
|
||||
))
|
||||
return
|
||||
_say(raw)
|
||||
|
||||
Reference in New Issue
Block a user