feat: integrate native diagnostics and coordinated CBB transactions
This commit is contained in:
1 parent
9e230e1a46
commit
da67de026f
91 files changed
+14370
-435
No files matched your search
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, fields, replace
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from typing import Any, Sequence
|
||||
@@ -185,6 +186,39 @@ def _decision(rule: DialogRule) -> RuleDecision:
|
||||
)
|
||||
|
||||
|
||||
def pcb_version_choice(snapshot):
|
||||
"""Describe the captured native choice; never select or approve a version."""
|
||||
if (snapshot.title != 'Database Restoration' or snapshot.window_class != '#32770'
|
||||
or snapshot.process_name.casefold() != 'expeditionpcb.exe' or snapshot.process_role != 'pcb'
|
||||
or snapshot.phase != DialogPhase.PCB_STARTING):
|
||||
return None
|
||||
explanation = ('The system has detected this design abnormally terminated the last time it was used. '
|
||||
'The user has to decide what database (if any) to associate with the design.')
|
||||
if not any(c.control_id == 6208 and ' '.join(c.name.split()) == explanation for c in snapshot.controls):
|
||||
return None
|
||||
candidates = []
|
||||
for identifier, kind, prefix in ((6213, 'last_user_saved', 'Load the last user saved database dated '),
|
||||
(6206, 'autosave', 'Load the autosave database dated ')):
|
||||
controls = [c for c in snapshot.controls if c.control_id == identifier and c.class_name == 'Button']
|
||||
if len(controls) != 1: return None
|
||||
control = controls[0]
|
||||
match = re.fullmatch(re.escape(prefix) + r'(.+)\.', ' '.join(control.name.split()))
|
||||
if not match: return None
|
||||
candidates.append({'kind': kind, 'control_id': identifier, 'label': control.name,
|
||||
'date': match.group(1), 'enabled': control.enabled,
|
||||
'selected': control.selected or control.checked})
|
||||
return {'candidates': candidates, 'automatic_selection': False}
|
||||
|
||||
|
||||
def archive_version_choice(snapshot, root):
|
||||
choice = pcb_version_choice(snapshot)
|
||||
if choice is None: raise ValueError('Not the recognized native PCB version choice')
|
||||
path = Path(root)/'pcb-version-choice.json'
|
||||
path.write_text(json.dumps({**choice, 'snapshot': snapshot.to_record()},
|
||||
ensure_ascii=False, indent=2), encoding='utf-8')
|
||||
return path
|
||||
|
||||
|
||||
def decide(snapshot: WindowSnapshot, rules: Sequence[DialogRule]) -> RuleDecision:
|
||||
# Windows Text Services Framework language-bar window exposed by Mentor's
|
||||
# process is not a Mentor modal: it has no controls and must not abort a run.
|
||||
@@ -197,6 +231,12 @@ def decide(snapshot: WindowSnapshot, rules: Sequence[DialogRule]) -> RuleDecisio
|
||||
if parse_session_loss(combined):
|
||||
return RuleDecision(error_code=ERROR_CODE,
|
||||
detail=' | '.join(snapshot.texts) or snapshot.title)
|
||||
choice = pcb_version_choice(snapshot)
|
||||
if choice is not None:
|
||||
labels = {'last_user_saved': '最后用户保存', 'autosave': '自动保存'}
|
||||
detail = ';'.join(f'{labels[c["kind"]]}:{c["date"]}' for c in choice['candidates'])
|
||||
return RuleDecision(error_code='PCB_VERSION_CHOICE_REQUIRED',
|
||||
detail=f'PCB需选择恢复版本,尚未校验通过。候选版本:{detail}。未自动选择或确认任何版本。')
|
||||
# These prompts require knowledge of database ownership or a recovery
|
||||
# choice. A generic Yes/restore rule cannot establish either fact.
|
||||
if any(marker in combined for marker in (
|
||||
|
||||
Reference in new issue
Block a user