Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba69f86628 |
No files matched your search
@@ -0,0 +1,31 @@
|
|||||||
|
# Issue 33 D5 · BOM 未知列验收
|
||||||
|
|
||||||
|
现场 B3 的 `INVALID_C1_bad_header_extra_col.xlsx` 带有 `extra_column`。名称归一化将未知列映射为空,后续只复制模板定义的列。导入成功时,工作区原先只报告保存行数与失败行数。
|
||||||
|
|
||||||
|
现在 BOM 导入保留模板列的精确映射,并为每个被忽略的具名列显示来源文件、原始列名与警告计数。详情和任务事件同时记录这些警告。缺失必需列时,导入停止,错误详情列出具体缺失项并对相近列名给出改名建议。
|
||||||
|
|
||||||
|
## Windows 11 重放
|
||||||
|
|
||||||
|
通过 Qt 工作区的“导入 BOM”按钮和真实任务服务运行,测试替换的是文件选择对话框的返回值。现场文件复制到临时目录,仅把第一条记录的工程名称与路径绑定到临时工程,保留了原始表头和替换字段。
|
||||||
|
|
||||||
|
| 工作簿 | 结果 |
|
||||||
|
| --- | --- |
|
||||||
|
| 两个额外列「供应商」「备注」 | 保存 1 行、失败 0 行、警告 2 项。详情逐列列名,任务事件记录同一组警告 |
|
||||||
|
| 现场 B3 `extra_column` | 保存 1 行、失败 0 行、警告 1 项。详情保留该列名 |
|
||||||
|
| 用「新料号编码」替换必需的「新料号」 | 指出缺少「新料号」,并建议将「新料号编码」改为「新料号」 |
|
||||||
|
| 缺少「新料号」 | 指出具体缺失项 |
|
||||||
|
| 表头公式与额外列中的数据公式 | 分别拒绝表头公式和第 2 行公式 |
|
||||||
|
| 原模板 | 保存 1 行、失败 0 行,无警告 |
|
||||||
|
|
||||||
|
BOM 草稿导入时未启动工程位号采集。回归还检查了由监督子进程返回的真实预览报告能携带同样的警告。包含现场工作簿重放的定向回归共通过 110 项。
|
||||||
|
|
||||||
|
## 复跑
|
||||||
|
|
||||||
|
在仓库根目录运行。现场文件从工单附件 `05_实测证据/paper2_bom` 解出。普通回归可省略 `DX_ISSUE33_D5_FIELD`,此时跳过现场文件重放。
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:PYTHONUTF8 = '1'
|
||||||
|
$env:PYTHONPATH = (Resolve-Path src).Path
|
||||||
|
$env:DX_ISSUE33_D5_FIELD = 'C:/path/to/INVALID_C1_bad_header_extra_col.xlsx'
|
||||||
|
python -m pytest -q -s tests/v1_1/test_bom_header_feedback.py tests/v1_1/test_bom_import_report.py tests/v1_1/test_bom_pending.py tests/v1_1/test_bom_sources_supervision.py tests/trial_task_center/test_bom_import_review.py tests/trial_task_center/test_item_value_and_bom_sources.py
|
||||||
|
```
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# Issue #33 D6 · DxDataBook 加载失败验证
|
|
||||||
|
|
||||||
现场 `WIFI_RTL8723DU` 的 `LWB01` 在加载目标 `4885-S018D0-M220` 时超时。原报告记录了可见列表窗口,阶段为 `preflight`,本项写入凭据为 `prepared`。同代次此前的项已有写入凭据,项目进入保留和对账流程。类似的失败也出现在 `BOB` 与 `BOB_SHIELD` 的目标 `4885-S033D0-M220` 上。现场空标题窗口 `10750260` 属于同批后续 `WIFI_RTL8192FC` 会话的启动阶段。它与 `LWB01` 超时分属不同 CAD 进程和代次。现场日志能定位超时阶段及保留原因,库服务状态和窗口复建情况仍待同代次采样。
|
|
||||||
|
|
||||||
加载阶段根据 DxDataBook 控件是否已存在采用 45 秒或 20 秒窗口。加载过程重新发现同一窗口下的列表与筛选器,控件重建后重发筛选并重新验证行稳定性。超时前写下本项凭据状态,超时后至多重试一次。重试要求本项仍有身份匹配的 `prepared` 凭据。空窗口处理进一步要求窗口在本次浏览后出现,属于同一 CAD 进程、线程和替换对话框,且替换对话框已被禁用。窗口和子控件证据先写盘,随后才发送关闭消息并观察结果。替换提交、属性恢复和保存继续使用既有的写入凭据与关闭检查点。
|
|
||||||
|
|
||||||
## Windows 验证
|
|
||||||
|
|
||||||
| 场景 | 观测结果 |
|
|
||||||
| --- | --- |
|
|
||||||
| 冷加载列表重建注入 | 原列表 `10` 更新为 `20`,筛选器从 `11` 切换到 `21`,稳定性窗口重新计时,最终使用新列表。 |
|
|
||||||
| 控件枚举与访问之间发生重建 | 筛选消息返回 Win32 `1400`,或列表读取返回 UIA `0x80040201`。两种故障都在当前加载时限内重取控件,访问新筛选器并选中正确的行。 |
|
|
||||||
| 真实 Win32 空窗口,凭据 `prepared` | 私有桌面创建的 HWND `19728876` 属于替换对话框,保存窗口树后只关闭该窗口。加载重试一次后返回目标,原有同 PID 无关窗口仍打开,凭据仍为 `prepared`。 |
|
|
||||||
| 真实 Win32 空窗口,凭据 `mutation_possible` | 窗口 `1183362` 具备同样的结构和归属,仅留下诊断。未重试,窗口与写入凭据均保留。 |
|
|
||||||
| 先前已有暂存写入,当前项失败 | Windows `cscript.exe` 执行生产 VBS 清理过程。当前未写且无暂存项时经过原始状态核验并以 `SaveChanges=False` 关闭。已有前项暂存写入、当前项写入状态无法确认或保存已请求时,保留工程供对账。 |
|
|
||||||
|
|
||||||
真实 HWND 注入运行生产窗口检查和加载重试代码,测试用 Win32 窗口模拟 DxDataBook 的无按钮提示。测试将等待时间缩短到 1.5 秒,筛选响应由测试控制。原始诊断见 [prepared.json](evidence/2026-11-25-issue33-d6/prepared.json) 和 [mutation_possible.json](evidence/2026-11-25-issue33-d6/mutation_possible.json)。
|
|
||||||
|
|
||||||
另一组注入使用原生 ListView、Edit、UIA 行读取和消息驱动生产 `run_native`,CAD COM 属性与菜单资源由替身提供。先销毁筛选框触发 Win32 `1400`,再销毁列表触发 UIA `0x80040201`。程序复取新列表和筛选器,扫描两行后命中精确料号。提交回调只触发一次并读到持久化状态 `mutation_possible`。只有相似料号的对照执行两次筛选后超时,提交数为零,凭据仍为 `prepared`。 [精确命中](evidence/2026-11-25-issue33-d6/native-controls-positive.json) [没有精确命中](evidence/2026-11-25-issue33-d6/native-controls-negative.json)
|
|
||||||
|
|
||||||
定向回归 114 项通过,包含加载、窗口归属、写入凭据、VBS 失败收尾和现有目标 Cell 路径。另执行扩展集成测试时,丢失 UID 的旧测试出现保存回读证明缺失,用 `origin/main` 的原始 VBS 同例复现。
|
|
||||||
|
|
||||||
## 真实工程副本
|
|
||||||
|
|
||||||
- 现场备份 `WIFI_RTL8723DU` 使用本机 `Skyworth_Lib` 中央库替代现场 `S:\mentor_lib.lmc`,BOM 核验找到 `LWB01` 并确认 UID。执行停在 `open_project` 249 秒,回到 `open_sheet` 安全边界时停止,关闭检查点仍观测到工程打开。写入凭据为 `prepared`,工程保护标记保留。此次在进入 DxDataBook 前结束,现场目标件换料及保存回读尚待验证。 [现场副本记录](evidence/2026-11-25-issue33-d6/field-copy.json)
|
|
||||||
- `Audio_D2128` 副本上,`RV05` 从 `4100-CA0000-T7` 换为 `4100-CA0000-T0`。已存在的 DxDataBook 控件在 2.703 秒内返回目标。原生替换报告成功,保存请求和返回各一次,工程完成关闭及重新读取,状态为 `saved_ok/project_committed`,独立网表比对为 `verified`。关闭整个 CAD 进程时超出 15 秒并触发资源释放保护标记,任务目录未产生业务不确定标记。 [正常副本记录](evidence/2026-11-25-issue33-d6/normal-copy.json)
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
{
|
|
||||||
"mode": "field",
|
|
||||||
"environment": "Windows, DxDesigner 7.9.5, source runtime",
|
|
||||||
"library_mapping": "Skyworth_Lib",
|
|
||||||
"library_lmc_unchanged": true,
|
|
||||||
"project": "WIFI_RTL8723DU.prj",
|
|
||||||
"request_old_new_refdes": [
|
|
||||||
"483C-S018D0-M210",
|
|
||||||
"4885-S018D0-M220",
|
|
||||||
"LWB01"
|
|
||||||
],
|
|
||||||
"attempt": {
|
|
||||||
"session_id": "bf846ff076254e5fbb3bc7ccf1ee859d",
|
|
||||||
"generation": 1,
|
|
||||||
"attempt_id": "44a747ec3c5d440fb60d5a2a407b8037",
|
|
||||||
"job_id": "08d6ebdc6cc540f7b2296a2ef737947a_0",
|
|
||||||
"state": "prepared"
|
|
||||||
},
|
|
||||||
"native": [],
|
|
||||||
"status_log": [
|
|
||||||
"job_id\tstate\tcode\tmessage"
|
|
||||||
],
|
|
||||||
"operation_log_excerpt": [
|
|
||||||
"2026/11/25 9:57:21\tINFO\tstage=open_project target=<copy-root>\\project\\WIFI_RTL8723DU.prj",
|
|
||||||
"2026/11/25 10:01:30\tERROR\tstage=open_sheet number=-2147220644 source=QuickPartReplace.SafeStop description=stopped at a safe boundary before native mutation after inactivity; prewrite pause closure was not proven: %7F3A%5C11%5BF9%8C61",
|
|
||||||
"quick_run_uncertain monitor_failure error=project close checkpoint failed: owned CAD still has a project open; no implicit save or discard\\r\\n"
|
|
||||||
],
|
|
||||||
"independent_verification": [
|
|
||||||
"not_completed"
|
|
||||||
],
|
|
||||||
"uncertain_flags_relative_to_data_root": [
|
|
||||||
"batch-resources/bf846ff076254e5fbb3bc7ccf1ee859d/generation-1/uncertain.flag",
|
|
||||||
"tasks/546160ef-0e8f-4b15-8394-e35f8c562366/quick-run/uncertain.flag"
|
|
||||||
],
|
|
||||||
"queue_outcome": "project remained open at the close checkpoint"
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"stage": "preflight",
|
|
||||||
"databook": {
|
|
||||||
"loads": [
|
|
||||||
{
|
|
||||||
"mode": "warm",
|
|
||||||
"timeout_seconds": 20,
|
|
||||||
"attempt_state_before_load": "mutation_possible",
|
|
||||||
"list_handle": 17,
|
|
||||||
"filter_handle": 18,
|
|
||||||
"error": "Native DxDataBook did not finish loading target part: NEW",
|
|
||||||
"elapsed_seconds": 1.594,
|
|
||||||
"dialogs": [
|
|
||||||
{
|
|
||||||
"hwnd": 1183362,
|
|
||||||
"owner": 200514,
|
|
||||||
"pid": 56180,
|
|
||||||
"title": "",
|
|
||||||
"children": [],
|
|
||||||
"browser": false,
|
|
||||||
"dismissible": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"attempt_state": "mutation_possible",
|
|
||||||
"retry": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"window_closed": [],
|
|
||||||
"marker_state": "mutation_possible"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
{
|
|
||||||
"attempt": "prepared",
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"controls": [
|
|
||||||
21630720,
|
|
||||||
528470
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"edit_hwnd": 528470,
|
|
||||||
"text": "NEW"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"read_list": 21630720,
|
|
||||||
"row_count": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"read_list": 21630720,
|
|
||||||
"row_count": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"edit_hwnd": 528470,
|
|
||||||
"text": "NEW"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"read_list": 21630720,
|
|
||||||
"row_count": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"read_list": 21630720,
|
|
||||||
"row_count": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"report": {
|
|
||||||
"native_command": {
|
|
||||||
"id": 33977,
|
|
||||||
"executable": "C:\\Users\\ABS_Windows\\AppData\\Local\\Programs\\Python\\Python312\\python.exe",
|
|
||||||
"trigger": "resource_command"
|
|
||||||
},
|
|
||||||
"native_options": {
|
|
||||||
"1704": {
|
|
||||||
"text": "Option",
|
|
||||||
"checked": true
|
|
||||||
},
|
|
||||||
"1105": {
|
|
||||||
"text": "Option",
|
|
||||||
"checked": true
|
|
||||||
},
|
|
||||||
"1697": {
|
|
||||||
"text": "Option",
|
|
||||||
"checked": true
|
|
||||||
},
|
|
||||||
"1700": {
|
|
||||||
"text": "Option",
|
|
||||||
"checked": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"databook": {
|
|
||||||
"main_visible_before_browse": true,
|
|
||||||
"browse_button": 3017658,
|
|
||||||
"loads": [
|
|
||||||
{
|
|
||||||
"mode": "cold",
|
|
||||||
"timeout_seconds": 45,
|
|
||||||
"attempt_state_before_load": "prepared",
|
|
||||||
"list_handle": 21630720,
|
|
||||||
"filter_handle": 528470,
|
|
||||||
"error": "Native DxDataBook did not finish loading target part: NEW",
|
|
||||||
"elapsed_seconds": 3.437,
|
|
||||||
"dialogs": [],
|
|
||||||
"attempt_state": "prepared",
|
|
||||||
"retry": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mode": "warm",
|
|
||||||
"timeout_seconds": 20,
|
|
||||||
"attempt_state_before_load": "prepared",
|
|
||||||
"list_handle": 21630720,
|
|
||||||
"filter_handle": 528470,
|
|
||||||
"error": "Native DxDataBook did not finish loading target part: NEW",
|
|
||||||
"elapsed_seconds": 3.344,
|
|
||||||
"dialogs": [],
|
|
||||||
"attempt_state": "prepared",
|
|
||||||
"retry": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"error": "TimeoutError('Native DxDataBook did not finish loading target part: NEW')"
|
|
||||||
}
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
{
|
|
||||||
"attempt": "mutation_possible",
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"controls": [
|
|
||||||
21696256,
|
|
||||||
594006
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"controls": [
|
|
||||||
21761792,
|
|
||||||
659542
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dead_edit": 594006,
|
|
||||||
"winerror": 1400
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"edit_hwnd": 659542,
|
|
||||||
"text": "NEW"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"read_list": 21761792,
|
|
||||||
"row_count": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"controls": [
|
|
||||||
21827328,
|
|
||||||
725078
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dead_ui_list": 21761792,
|
|
||||||
"hresult": -2147220991,
|
|
||||||
"exception": "COMError(-2147220991, '\u4e8b\u4ef6\u65e0\u6cd5\u8c03\u7528\u4efb\u4f55\u8ba2\u6237', (None, None, None, 0, None))"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"edit_hwnd": 725078,
|
|
||||||
"text": "NEW"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"read_list": 21827328,
|
|
||||||
"row_count": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"read_list": 21827328,
|
|
||||||
"row_count": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"submit": "mutation_possible"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"report": {
|
|
||||||
"native_command": {
|
|
||||||
"id": 33977,
|
|
||||||
"executable": "C:\\Users\\ABS_Windows\\AppData\\Local\\Programs\\Python\\Python312\\python.exe",
|
|
||||||
"trigger": "resource_command"
|
|
||||||
},
|
|
||||||
"native_options": {
|
|
||||||
"1704": {
|
|
||||||
"text": "Option",
|
|
||||||
"checked": true
|
|
||||||
},
|
|
||||||
"1105": {
|
|
||||||
"text": "Option",
|
|
||||||
"checked": true
|
|
||||||
},
|
|
||||||
"1697": {
|
|
||||||
"text": "Option",
|
|
||||||
"checked": true
|
|
||||||
},
|
|
||||||
"1700": {
|
|
||||||
"text": "Option",
|
|
||||||
"checked": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"databook": {
|
|
||||||
"main_visible_before_browse": true,
|
|
||||||
"browse_button": 3017658,
|
|
||||||
"loads": [
|
|
||||||
{
|
|
||||||
"mode": "warm",
|
|
||||||
"timeout_seconds": 20,
|
|
||||||
"attempt_state_before_load": "prepared",
|
|
||||||
"list_handle": 21827328,
|
|
||||||
"filter_handle": 725078,
|
|
||||||
"elapsed_seconds": 6.125
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"list_handle": 21827328,
|
|
||||||
"list_visible": true,
|
|
||||||
"main_visible_after_load": true
|
|
||||||
},
|
|
||||||
"library_row": [
|
|
||||||
"DATA",
|
|
||||||
"NEW",
|
|
||||||
"LIB:EXACT",
|
|
||||||
"",
|
|
||||||
"Exact",
|
|
||||||
"Target"
|
|
||||||
],
|
|
||||||
"slot_count": 1,
|
|
||||||
"row_rectangle": [
|
|
||||||
157,
|
|
||||||
398,
|
|
||||||
769,
|
|
||||||
422
|
|
||||||
],
|
|
||||||
"list_handle": 21827328,
|
|
||||||
"target_text": "NEW",
|
|
||||||
"symbol_text": "LIB:EXACT",
|
|
||||||
"target_submit_enabled": true,
|
|
||||||
"transaction": {
|
|
||||||
"snapshot_sha256": "d36e0c485331eac7b3c0d25de6dbfc5e915b761dd7eb738caf49b69d89640daa",
|
|
||||||
"project_path": "g:\\dx33\\acceptance\\d6-native-controls-03\\positive\\synthetic.prj",
|
|
||||||
"sheet_identity": "MAIN:1",
|
|
||||||
"old_part_number": "OLD",
|
|
||||||
"new_part_number": "NEW",
|
|
||||||
"source_uids": [
|
|
||||||
"uid"
|
|
||||||
],
|
|
||||||
"target_selectors": null,
|
|
||||||
"library_row": [
|
|
||||||
"DATA",
|
|
||||||
"NEW",
|
|
||||||
"LIB:EXACT",
|
|
||||||
"",
|
|
||||||
"Exact",
|
|
||||||
"Target"
|
|
||||||
],
|
|
||||||
"target_symbol": "LIB:EXACT",
|
|
||||||
"slot_count": 1
|
|
||||||
},
|
|
||||||
"stage": "native_replace_verified",
|
|
||||||
"replaced_uids": [
|
|
||||||
"uid"
|
|
||||||
],
|
|
||||||
"promoted_pins": []
|
|
||||||
},
|
|
||||||
"error": null
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
{
|
|
||||||
"mode": "normal",
|
|
||||||
"environment": "Windows, DxDesigner 7.9.5, source runtime",
|
|
||||||
"library_mapping": "Skyworth_CBB_Lib",
|
|
||||||
"library_lmc_unchanged": true,
|
|
||||||
"project": "Audio_D2128.prj",
|
|
||||||
"request_old_new_refdes": [
|
|
||||||
"4100-CA0000-T7",
|
|
||||||
"4100-CA0000-T0",
|
|
||||||
"RV05"
|
|
||||||
],
|
|
||||||
"attempt": {
|
|
||||||
"session_id": "588db35caf664589a499f02800559ff0",
|
|
||||||
"generation": 1,
|
|
||||||
"attempt_id": "65d0375a0a3e4e02a0e0225f5cd7da1d",
|
|
||||||
"job_id": "3fd4cca09997419cbf0850fe2907f1b5_0",
|
|
||||||
"state": "mutation_possible"
|
|
||||||
},
|
|
||||||
"native": [
|
|
||||||
{
|
|
||||||
"ok": true,
|
|
||||||
"stage": "native_replace_applied",
|
|
||||||
"databook": {
|
|
||||||
"main_visible_before_browse": true,
|
|
||||||
"browse_button": 1577092,
|
|
||||||
"loads": [
|
|
||||||
{
|
|
||||||
"mode": "warm",
|
|
||||||
"timeout_seconds": 20,
|
|
||||||
"attempt_state_before_load": "prepared",
|
|
||||||
"list_handle": 266464,
|
|
||||||
"filter_handle": 266532,
|
|
||||||
"elapsed_seconds": 2.703
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"list_handle": 266464,
|
|
||||||
"list_visible": true,
|
|
||||||
"main_visible_after_load": true
|
|
||||||
},
|
|
||||||
"library_row": [
|
|
||||||
"RESISTOR",
|
|
||||||
"4100-CA0000-T0",
|
|
||||||
"skyworth:res01",
|
|
||||||
"unassigned",
|
|
||||||
"RESC1608N",
|
|
||||||
"0R",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"replaced_uids": [
|
|
||||||
"$2I2014"
|
|
||||||
],
|
|
||||||
"pin_promotion_phase": "promotion_complete"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"status_log": [
|
|
||||||
"job_id\tstate\tcode\tmessage",
|
|
||||||
"3fd4cca09997419cbf0850fe2907f1b5_0\tawaiting_native_replace\t\tSnapshot captured; automatic native replacement is starting.",
|
|
||||||
"3fd4cca09997419cbf0850fe2907f1b5_0\tpending_save\tsession_staged\tWrites staged; awaiting engineering project save and saved native data verification.",
|
|
||||||
"3fd4cca09997419cbf0850fe2907f1b5_0\tpending_save\tproject_saved\tEngineering project saved and closed; awaiting saved native data verification.",
|
|
||||||
"3fd4cca09997419cbf0850fe2907f1b5_0\tsaved_ok\tproject_committed\t%5DE5%7A0B%7EDF%4E00%4FDD%5B58%FF0C%539F%751F%6570%636E%6838%9A8C%901A%8FC7%3002"
|
|
||||||
],
|
|
||||||
"operation_log_excerpt": [
|
|
||||||
"2026/11/25 10:03:45\tINFO\tstage=open_project target=<copy-root>\\project\\Audio_D2128.prj",
|
|
||||||
"2026/11/25 10:03:59\tINFO\tstage=open_sheet schematic=Audio-D2128 sheet=S905L CVBS-LR",
|
|
||||||
"2026/11/25 10:04:49\tINFO\tnative_helper_exit code=0",
|
|
||||||
"2026/11/25 10:05:16\tINFO\treplacement RV05 4100-CA0000-T7 -> 4100-CA0000-T0",
|
|
||||||
"2026/11/25 10:05:17\tINFO\tsave_requested job=3fd4cca09997419cbf0850fe2907f1b5_0",
|
|
||||||
"2026/11/25 10:05:17\tINFO\tsave_returned job=3fd4cca09997419cbf0850fe2907f1b5_0",
|
|
||||||
"2026/11/25 10:05:22\tINFO\tproject_closed job=3fd4cca09997419cbf0850fe2907f1b5_0"
|
|
||||||
],
|
|
||||||
"independent_verification": [
|
|
||||||
"verified"
|
|
||||||
],
|
|
||||||
"uncertain_flags_relative_to_data_root": [
|
|
||||||
"batch-resources/588db35caf664589a499f02800559ff0/generation-1/uncertain.flag"
|
|
||||||
],
|
|
||||||
"queue_outcome": "CAD exit exceeded 15 seconds during batch resource cleanup after the saved business receipt"
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"stage": "preflight",
|
|
||||||
"databook": {
|
|
||||||
"loads": [
|
|
||||||
{
|
|
||||||
"mode": "warm",
|
|
||||||
"timeout_seconds": 20,
|
|
||||||
"attempt_state_before_load": "prepared",
|
|
||||||
"list_handle": 17,
|
|
||||||
"filter_handle": 18,
|
|
||||||
"error": "Native DxDataBook did not finish loading target part: NEW",
|
|
||||||
"elapsed_seconds": 1.547,
|
|
||||||
"dialogs": [
|
|
||||||
{
|
|
||||||
"hwnd": 19728876,
|
|
||||||
"owner": 134972,
|
|
||||||
"pid": 5004,
|
|
||||||
"title": "",
|
|
||||||
"children": [],
|
|
||||||
"browser": false,
|
|
||||||
"dismissible": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"attempt_state": "prepared",
|
|
||||||
"retry": true,
|
|
||||||
"closed_dialog": 19728876
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mode": "warm",
|
|
||||||
"timeout_seconds": 20,
|
|
||||||
"attempt_state_before_load": "prepared",
|
|
||||||
"list_handle": 17,
|
|
||||||
"filter_handle": 18,
|
|
||||||
"elapsed_seconds": 0.187
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"window_closed": [
|
|
||||||
19728876
|
|
||||||
],
|
|
||||||
"marker_state": "prepared"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1123,8 +1123,7 @@ Sub QPDiscardFailedBatchProject(ByRef ErrorDescription)
|
|||||||
If (Not QP_BatchMode And Not QP_SessionMode) Or Not QP_OwnedProject Or QP_App Is Nothing Then Exit Sub
|
If (Not QP_BatchMode And Not QP_SessionMode) Or Not QP_OwnedProject Or QP_App Is Nothing Then Exit Sub
|
||||||
HasStagedItems = False
|
HasStagedItems = False
|
||||||
If IsObject(QP_SessionItems) Then HasStagedItems = (QP_SessionItems.Count > 0)
|
If IsObject(QP_SessionItems) Then HasStagedItems = (QP_SessionItems.Count > 0)
|
||||||
If QP_NativeMutationPossible Or QP_NativeCallActive Or QP_RestoreTransactionOpen Or _
|
If QP_NativeMutationPossible Or QP_BatchSaveRequested Or QP_BatchSaveCommitted Or HasStagedItems Then
|
||||||
QP_BatchSaveRequested Or QP_BatchSaveCommitted Or HasStagedItems Then
|
|
||||||
ErrorDescription = "write or save outcome requires reconciliation; owned project retained without automatic save or discard"
|
ErrorDescription = "write or save outcome requires reconciliation; owned project retained without automatic save or discard"
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
@@ -1659,7 +1658,6 @@ Sub QPNativeReplace(ByRef Command, ByVal SnapshotPath)
|
|||||||
End If
|
End If
|
||||||
CommandLine = CommandLine & " --native-helper --snapshot " & Chr(34) & SnapshotPath & Chr(34)
|
CommandLine = CommandLine & " --native-helper --snapshot " & Chr(34) & SnapshotPath & Chr(34)
|
||||||
Set Shell = CreateObject("WScript.Shell")
|
Set Shell = CreateObject("WScript.Shell")
|
||||||
QP_Stage = "native_replace"
|
|
||||||
QP_NativeCallActive = True
|
QP_NativeCallActive = True
|
||||||
QPProgress "native_replace", 0, 1
|
QPProgress "native_replace", 0, 1
|
||||||
ExitCode = Shell.Run(CommandLine, 0, True)
|
ExitCode = Shell.Run(CommandLine, 0, True)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class BomImportReport:
|
|||||||
source_map_path: Path | None = None
|
source_map_path: Path | None = None
|
||||||
passed_preview: BomBatchPreview | None = None
|
passed_preview: BomBatchPreview | None = None
|
||||||
deferred: bool = False
|
deferred: bool = False
|
||||||
|
warnings: tuple[str, ...] = ()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total_rows(self):
|
def total_rows(self):
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ def resolution_binding(store, task_id):
|
|||||||
|
|
||||||
def import_drafts(service, task_id, sources, *, stop_event=None, on_progress=None, on_phase=None, allow_partial=False):
|
def import_drafts(service, task_id, sources, *, stop_event=None, on_progress=None, on_phase=None, allow_partial=False):
|
||||||
"""Persist routed spreadsheet requests without opening CAD or resolving parts."""
|
"""Persist routed spreadsheet requests without opening CAD or resolving parts."""
|
||||||
rows = load_sources(sources, stop_event=stop_event, on_progress=on_progress, allow_partial=allow_partial)
|
warnings = []
|
||||||
|
rows = load_sources(sources, stop_event=stop_event, on_progress=on_progress,
|
||||||
|
allow_partial=allow_partial, warnings=warnings)
|
||||||
scope = _scope(service._store, task_id)
|
scope = _scope(service._store, task_id)
|
||||||
paths = tuple(project.path for _, project in scope)
|
paths = tuple(project.path for _, project in scope)
|
||||||
names = {project.path: task.name for task, project in scope}
|
names = {project.path: task.name for task, project in scope}
|
||||||
@@ -93,7 +95,8 @@ def import_drafts(service, task_id, sources, *, stop_event=None, on_progress=Non
|
|||||||
write_routed_bom(normalized, rows, routes, project_names=names)
|
write_routed_bom(normalized, rows, routes, project_names=names)
|
||||||
append_task_event(service._logging, level='INFO', task_id=task_id,
|
append_task_event(service._logging, level='INFO', task_id=task_id,
|
||||||
operation='import_bom_drafts', message='BOM 表格来源记录已保存,工程位号待核验',
|
operation='import_bom_drafts', message='BOM 表格来源记录已保存,工程位号待核验',
|
||||||
details={'source_map_path': str(mapping), 'source_count': len({row.source for row in rows})})
|
details={'source_map_path': str(mapping), 'source_count': len({row.source for row in rows}),
|
||||||
|
'warnings': warnings})
|
||||||
try:
|
try:
|
||||||
report = inspect_batch(service, task_id, normalized, stop_event=stop_event, on_progress=on_progress,
|
report = inspect_batch(service, task_id, normalized, stop_event=stop_event, on_progress=on_progress,
|
||||||
on_phase=on_phase, spreadsheet_only=True, allow_partial=allow_partial)
|
on_phase=on_phase, spreadsheet_only=True, allow_partial=allow_partial)
|
||||||
@@ -110,7 +113,7 @@ def import_drafts(service, task_id, sources, *, stop_event=None, on_progress=Non
|
|||||||
if report.deferred and result.project_path not in failed_paths:
|
if report.deferred and result.project_path not in failed_paths:
|
||||||
reason = '表格已保存,执行前核验工程位号'
|
reason = '表格已保存,执行前核验工程位号'
|
||||||
annotated.append(replace(result, source_file=str(source.source), source_row=source.excel_row, reason=reason))
|
annotated.append(replace(result, source_file=str(source.source), source_row=source.excel_row, reason=reason))
|
||||||
report = replace(report, rows=tuple(annotated), source_map_path=mapping)
|
report = replace(report, rows=tuple(annotated), source_map_path=mapping, warnings=tuple(warnings))
|
||||||
if report.deferred:
|
if report.deferred:
|
||||||
accepted_sources = tuple(source for result, source in zip(report.rows, rows, strict=True)
|
accepted_sources = tuple(source for result, source in zip(report.rows, rows, strict=True)
|
||||||
if result.project_path not in failed_paths)
|
if result.project_path not in failed_paths)
|
||||||
|
|||||||
@@ -292,8 +292,7 @@ def wait_for(callback, description, timeout=15):
|
|||||||
raise TimeoutError(description)
|
raise TimeoutError(description)
|
||||||
|
|
||||||
|
|
||||||
def wait_for_library_rows(callback, target, timeout=30, stable_for=0.45, poll_interval=0.15,
|
def wait_for_library_rows(callback, target, timeout=30, stable_for=0.45, poll_interval=0.15):
|
||||||
scope=lambda: None):
|
|
||||||
deadline = time.monotonic() + timeout
|
deadline = time.monotonic() + timeout
|
||||||
previous = None
|
previous = None
|
||||||
stable_since = None
|
stable_since = None
|
||||||
@@ -310,7 +309,7 @@ def wait_for_library_rows(callback, target, timeout=30, stable_for=0.45, poll_in
|
|||||||
previous = stable_since = None
|
previous = stable_since = None
|
||||||
time.sleep(poll_interval)
|
time.sleep(poll_interval)
|
||||||
continue
|
continue
|
||||||
signature = (scope(), tuple(tuple(str(value) for value in columns) for _, columns in latest))
|
signature = tuple(tuple(str(value) for value in columns) for _, columns in latest)
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
if signature != previous:
|
if signature != previous:
|
||||||
previous = signature
|
previous = signature
|
||||||
@@ -322,106 +321,6 @@ def wait_for_library_rows(callback, target, timeout=30, stable_for=0.45, poll_in
|
|||||||
raise TimeoutError(f"Native DxDataBook did not finish loading target part: {target}")
|
raise TimeoutError(f"Native DxDataBook did not finish loading target part: {target}")
|
||||||
|
|
||||||
|
|
||||||
def load_databook_target(snapshot, report, target, *, controls, browse, filter_part,
|
|
||||||
list_rows, dialogs, close_dialog):
|
|
||||||
"""Load the target before the native submit boundary and retry a prepared batch once."""
|
|
||||||
from .batch_attempt import can_retry_attempt
|
|
||||||
|
|
||||||
diagnostic = report.setdefault('databook', {})
|
|
||||||
loads = diagnostic['loads'] = []
|
|
||||||
baseline = {row['hwnd'] for row in dialogs()}
|
|
||||||
initial = snapshot_attempt(snapshot)
|
|
||||||
warm = controls() is not None
|
|
||||||
for index in range(2):
|
|
||||||
timeout = 20 if warm else 45
|
|
||||||
started = time.monotonic()
|
|
||||||
load = {'mode': 'warm' if warm else 'cold', 'timeout_seconds': timeout,
|
|
||||||
'attempt_state_before_load': initial[1]['state'] if initial else None}
|
|
||||||
loads.append(load)
|
|
||||||
save_report(snapshot, report)
|
|
||||||
pair = None
|
|
||||||
|
|
||||||
def read():
|
|
||||||
nonlocal pair
|
|
||||||
current = controls()
|
|
||||||
if current is None:
|
|
||||||
pair = None
|
|
||||||
return []
|
|
||||||
try:
|
|
||||||
if current != pair:
|
|
||||||
filter_part(current[1])
|
|
||||||
pair = current
|
|
||||||
load.update(list_handle=pair[0], filter_handle=pair[1])
|
|
||||||
return list_rows(pair[0])
|
|
||||||
except Exception as error:
|
|
||||||
if (getattr(error, 'winerror', None) != 1400 # ERROR_INVALID_WINDOW_HANDLE
|
|
||||||
and getattr(error, 'hresult', None) != -2147220991): # UIA_E_ELEMENTNOTAVAILABLE
|
|
||||||
raise
|
|
||||||
pair = None
|
|
||||||
return []
|
|
||||||
|
|
||||||
try:
|
|
||||||
if index == 0 or controls() is None:
|
|
||||||
browse()
|
|
||||||
rows = wait_for_library_rows(read, target, timeout=timeout, scope=lambda: pair)
|
|
||||||
except TimeoutError as error:
|
|
||||||
load['error'] = str(error)
|
|
||||||
load['elapsed_seconds'] = round(time.monotonic() - started, 3)
|
|
||||||
load['dialogs'] = [row for row in dialogs() if row['hwnd'] not in baseline]
|
|
||||||
bound = snapshot_attempt(snapshot)
|
|
||||||
prepared = initial is not None and initial[1]['state'] == 'prepared' and can_retry_attempt(*initial)
|
|
||||||
load['attempt_state'] = bound[1]['state'] if bound else None
|
|
||||||
blockers = [row for row in load['dialogs'] if not row.get('browser')]
|
|
||||||
candidates = [row for row in blockers if row['dismissible']]
|
|
||||||
retry = index == 0 and prepared and bool(os.environ.get('DXPART_DESKTOP'))
|
|
||||||
# A different modal must get its normal operator handling.
|
|
||||||
retry = retry and (not blockers or len(blockers) == len(candidates) == 1)
|
|
||||||
load['retry'] = retry
|
|
||||||
save_report(snapshot, report)
|
|
||||||
if not retry:
|
|
||||||
raise
|
|
||||||
if candidates:
|
|
||||||
close_dialog(candidates[0])
|
|
||||||
load['closed_dialog'] = candidates[0]['hwnd']
|
|
||||||
warm = True
|
|
||||||
else:
|
|
||||||
load['elapsed_seconds'] = round(time.monotonic() - started, 3)
|
|
||||||
return pair[0], rows
|
|
||||||
|
|
||||||
|
|
||||||
def databook_dialogs(gui, process, pid, replacement, main_handle):
|
|
||||||
from .cad_dialogs import _text
|
|
||||||
|
|
||||||
replacement_thread, _ = process.GetWindowThreadProcessId(replacement)
|
|
||||||
rows = []
|
|
||||||
|
|
||||||
def dialog(handle, _):
|
|
||||||
if (handle in {replacement, main_handle} or not gui.IsWindowVisible(handle)
|
|
||||||
or process.GetWindowThreadProcessId(handle)[1] != pid
|
|
||||||
or gui.GetClassName(handle) != '#32770'):
|
|
||||||
return
|
|
||||||
owner = gui.GetWindow(handle, 4) # GW_OWNER
|
|
||||||
row = {'hwnd': handle, 'owner': owner, 'pid': pid, 'title': '', 'children': [],
|
|
||||||
'browser': False, 'dismissible': False}
|
|
||||||
rows.append(row)
|
|
||||||
children = []
|
|
||||||
try:
|
|
||||||
row['title'] = _text(handle)
|
|
||||||
gui.EnumChildWindows(handle, lambda child, _: children.append(child), None)
|
|
||||||
row['children'] = [{'hwnd': child, 'parent': gui.GetParent(child), 'class': gui.GetClassName(child),
|
|
||||||
'id': gui.GetDlgCtrlID(child)} for child in children[:64]]
|
|
||||||
row['browser'] = {('SysListView32', 4000), ('Edit', 4006)} <= {
|
|
||||||
(child['class'], child['id']) for child in row['children']}
|
|
||||||
row['dismissible'] = (not row['title'].strip() and not children and owner == replacement
|
|
||||||
and process.GetWindowThreadProcessId(handle)[0] == replacement_thread
|
|
||||||
and not gui.IsWindowEnabled(replacement))
|
|
||||||
except (OSError, gui.error) as error:
|
|
||||||
row['read_error'] = str(error)
|
|
||||||
|
|
||||||
gui.EnumWindows(dialog, None)
|
|
||||||
return rows
|
|
||||||
|
|
||||||
|
|
||||||
def target_symbol_matches(displayed, library_symbol, slot_count):
|
def target_symbol_matches(displayed, library_symbol, slot_count):
|
||||||
actual = str(displayed).casefold()
|
actual = str(displayed).casefold()
|
||||||
expected = str(library_symbol).casefold()
|
expected = str(library_symbol).casefold()
|
||||||
@@ -949,8 +848,8 @@ def run_native(snapshot, report):
|
|||||||
raise ValueError("Multiple replacement dialogs")
|
raise ValueError("Multiple replacement dialogs")
|
||||||
return matches[0] if matches else None
|
return matches[0] if matches else None
|
||||||
|
|
||||||
def message(handle, code, wparam=0, lparam=0, *, timeout=15000):
|
def message(handle, code, wparam=0, lparam=0):
|
||||||
return win32gui.SendMessageTimeout(handle, code, wparam, lparam, win32con.SMTO_ABORTIFHUNG, timeout)
|
return win32gui.SendMessageTimeout(handle, code, wparam, lparam, win32con.SMTO_ABORTIFHUNG, 15000)
|
||||||
|
|
||||||
def control_text(control):
|
def control_text(control):
|
||||||
buffer = ctypes.create_unicode_buffer(2048)
|
buffer = ctypes.create_unicode_buffer(2048)
|
||||||
@@ -966,9 +865,9 @@ def run_native(snapshot, report):
|
|||||||
control = dlg_item(dialog, identifier)
|
control = dlg_item(dialog, identifier)
|
||||||
if not control:
|
if not control:
|
||||||
raise ValueError(f"Required native option {identifier} is unavailable")
|
raise ValueError(f"Required native option {identifier} is unavailable")
|
||||||
if message(control, 0x00F0)[1] != 1:
|
if win32gui.SendMessage(control, 0x00F0, 0, 0) != 1:
|
||||||
click(control)
|
click(control)
|
||||||
if message(control, 0x00F0)[1] != 1:
|
if win32gui.SendMessage(control, 0x00F0, 0, 0) != 1:
|
||||||
raise ValueError(f"Native option {identifier} was not enabled")
|
raise ValueError(f"Native option {identifier} was not enabled")
|
||||||
report.setdefault("native_options", {})[str(identifier)] = {
|
report.setdefault("native_options", {})[str(identifier)] = {
|
||||||
"text": control_text(control),
|
"text": control_text(control),
|
||||||
@@ -997,68 +896,31 @@ def run_native(snapshot, report):
|
|||||||
"main_visible_before_browse": bool(win32gui.IsWindowVisible(main_handle)),
|
"main_visible_before_browse": bool(win32gui.IsWindowVisible(main_handle)),
|
||||||
"browse_button": int(dlg_item(dialog, 1366)),
|
"browse_button": int(dlg_item(dialog, 1366)),
|
||||||
}
|
}
|
||||||
|
click(dlg_item(dialog, 1366))
|
||||||
|
|
||||||
def query_message(handle, code, wparam=0, lparam=0):
|
def part_list():
|
||||||
try:
|
report["databook"]["main_visible_during_wait"] = bool(
|
||||||
message(handle, code, wparam, lparam, timeout=5000)
|
win32gui.IsWindowVisible(main_handle)
|
||||||
except win32gui.error as error:
|
)
|
||||||
if error.winerror == 1460:
|
|
||||||
raise TimeoutError('Native DxDataBook browse or filter did not respond') from error
|
|
||||||
raise
|
|
||||||
|
|
||||||
def browse():
|
|
||||||
button = dlg_item(dialog, 1366)
|
|
||||||
if button and win32gui.IsWindowEnabled(dialog) and win32gui.IsWindowEnabled(button):
|
|
||||||
query_message(button, 0x00F5) # BM_CLICK
|
|
||||||
|
|
||||||
def controls():
|
|
||||||
lists, filters = {}, {}
|
|
||||||
for handle in owned_windows(include_hidden=True):
|
for handle in owned_windows(include_hidden=True):
|
||||||
try:
|
if win32gui.GetClassName(handle) == "SysListView32" and win32gui.GetDlgCtrlID(handle) == 4000:
|
||||||
kind = (win32gui.GetClassName(handle), win32gui.GetDlgCtrlID(handle))
|
return handle
|
||||||
if kind == ('SysListView32', 4000):
|
return None
|
||||||
lists[handle] = win32gui.GetAncestor(handle, 2)
|
list_handle = wait_for(part_list, "Native DxDataBook part list did not open", timeout=30)
|
||||||
elif kind == ('Edit', 4006):
|
|
||||||
filters[handle] = win32gui.GetAncestor(handle, 2)
|
|
||||||
except win32gui.error:
|
|
||||||
if win32gui.IsWindow(handle):
|
|
||||||
raise
|
|
||||||
pairs = [(part_list, part_filter) for part_list, list_root in lists.items()
|
|
||||||
for part_filter, filter_root in filters.items() if list_root == filter_root]
|
|
||||||
visible = [pair for pair in pairs if all(win32gui.IsWindowVisible(handle) for handle in pair)]
|
|
||||||
pairs = visible or pairs
|
|
||||||
return pairs[0] if len(pairs) == 1 else None
|
|
||||||
|
|
||||||
def filter_part(handle):
|
|
||||||
query_message(handle, win32con.WM_SETTEXT, 0, metadata[3])
|
|
||||||
|
|
||||||
def current_library_rows(list_handle):
|
|
||||||
try:
|
|
||||||
return [(row, [text.window_text() for text in row.children(control_type="Text")])
|
|
||||||
for row in desktop.window(handle=list_handle).descendants(control_type="ListItem")]
|
|
||||||
except Exception:
|
|
||||||
if win32gui.IsWindow(list_handle):
|
|
||||||
raise
|
|
||||||
return []
|
|
||||||
|
|
||||||
def dialogs():
|
|
||||||
return databook_dialogs(win32gui, win32process, process_id, dialog, main_handle)
|
|
||||||
|
|
||||||
def close_dialog(expected):
|
|
||||||
if expected not in dialogs():
|
|
||||||
raise OSError('DxDataBook dialog changed before close')
|
|
||||||
win32gui.PostMessage(expected['hwnd'], win32con.WM_CLOSE, 0, 0)
|
|
||||||
wait_for(lambda: not win32gui.IsWindowVisible(expected['hwnd']),
|
|
||||||
'Native DxDataBook dialog did not close', timeout=3)
|
|
||||||
|
|
||||||
list_handle, rows = load_databook_target(snapshot, report, metadata[3], controls=controls,
|
|
||||||
browse=browse, filter_part=filter_part, list_rows=current_library_rows,
|
|
||||||
dialogs=dialogs, close_dialog=close_dialog)
|
|
||||||
report["databook"].update(
|
report["databook"].update(
|
||||||
list_handle=int(list_handle),
|
list_handle=int(list_handle),
|
||||||
list_visible=bool(win32gui.IsWindowVisible(list_handle)),
|
list_visible=bool(win32gui.IsWindowVisible(list_handle)),
|
||||||
main_visible_after_load=bool(win32gui.IsWindowVisible(main_handle)),
|
main_visible_after_load=bool(win32gui.IsWindowVisible(main_handle)),
|
||||||
)
|
)
|
||||||
|
filter_handles = [handle for handle in owned_windows(include_hidden=True)
|
||||||
|
if win32gui.GetDlgCtrlID(handle) == 4006 and win32gui.GetClassName(handle) == "Edit"]
|
||||||
|
if len(filter_handles) != 1:
|
||||||
|
raise ValueError("Cannot uniquely identify native Part Number filter")
|
||||||
|
message(filter_handles[0], win32con.WM_SETTEXT, 0, metadata[3])
|
||||||
|
def current_library_rows():
|
||||||
|
return [(row, [text.window_text() for text in row.children(control_type="Text")])
|
||||||
|
for row in desktop.window(handle=list_handle).descendants(control_type="ListItem")]
|
||||||
|
rows = wait_for_library_rows(current_library_rows, metadata[3])
|
||||||
row, columns = exact_target(rows, metadata[3])
|
row, columns = exact_target(rows, metadata[3])
|
||||||
report["library_row"] = columns
|
report["library_row"] = columns
|
||||||
symbol_parts = columns[2].split(":", 1)
|
symbol_parts = columns[2].split(":", 1)
|
||||||
@@ -1068,9 +930,6 @@ def run_native(snapshot, report):
|
|||||||
report["slot_count"] = slot_count
|
report["slot_count"] = slot_count
|
||||||
if slot_count < 1:
|
if slot_count < 1:
|
||||||
raise ValueError("Library target has no valid slots")
|
raise ValueError("Library target has no valid slots")
|
||||||
current_pair = controls()
|
|
||||||
if current_pair is None or current_pair[0] != list_handle:
|
|
||||||
raise ValueError("DxDataBook controls changed after target selection")
|
|
||||||
rectangle = row.rectangle()
|
rectangle = row.rectangle()
|
||||||
list_rectangle = win32gui.GetWindowRect(list_handle)
|
list_rectangle = win32gui.GetWindowRect(list_handle)
|
||||||
if rectangle.height() <= 0 or rectangle.top < list_rectangle[1] or rectangle.bottom > list_rectangle[3]:
|
if rectangle.height() <= 0 or rectangle.top < list_rectangle[1] or rectangle.bottom > list_rectangle[3]:
|
||||||
|
|||||||
@@ -245,7 +245,8 @@ class TaskCenterService:
|
|||||||
on_phase(BomImportPhase.READING, message)
|
on_phase(BomImportPhase.READING, message)
|
||||||
if on_progress is not None:
|
if on_progress is not None:
|
||||||
on_progress(message)
|
on_progress(message)
|
||||||
rows = load_sources(sources, stop_event=stop_event, on_progress=on_progress,
|
warnings = []
|
||||||
|
rows = load_sources(sources, stop_event=stop_event, on_progress=on_progress, warnings=warnings,
|
||||||
**({'allow_partial': True} if allow_partial else {}))
|
**({'allow_partial': True} if allow_partial else {}))
|
||||||
scope = _scope(self._store, task_id)
|
scope = _scope(self._store, task_id)
|
||||||
paths = tuple(project.path for _, project in scope)
|
paths = tuple(project.path for _, project in scope)
|
||||||
@@ -278,7 +279,7 @@ class TaskCenterService:
|
|||||||
reason = '位号在 BOM 中重复(' + ';'.join(locations) + ')'
|
reason = '位号在 BOM 中重复(' + ';'.join(locations) + ')'
|
||||||
annotated.append(replace(row, source_file=str(source.source), source_row=source.excel_row,
|
annotated.append(replace(row, source_file=str(source.source), source_row=source.excel_row,
|
||||||
reason=reason + f';来源:{source.source} 第 {source.excel_row} 行'))
|
reason=reason + f';来源:{source.source} 第 {source.excel_row} 行'))
|
||||||
annotated_report = replace(report, rows=tuple(annotated), source_map_path=mapping)
|
annotated_report = replace(report, rows=tuple(annotated), source_map_path=mapping, warnings=tuple(warnings))
|
||||||
return bind_source_report(annotated_report,
|
return bind_source_report(annotated_report,
|
||||||
tuple(dict.fromkeys((str(row.source), row.source_sha256) for row in rows)), mapping)
|
tuple(dict.fromkeys((str(row.source), row.source_sha256) for row in rows)), mapping)
|
||||||
|
|
||||||
@@ -290,7 +291,8 @@ class TaskCenterService:
|
|||||||
write_routed_bom(normalized, rows, routes, project_names=names)
|
write_routed_bom(normalized, rows, routes, project_names=names)
|
||||||
append_task_event(self._logging, level='INFO', task_id=task_id,
|
append_task_event(self._logging, level='INFO', task_id=task_id,
|
||||||
operation='preview_bom_sources', message='BOM 导入来源记录已保存',
|
operation='preview_bom_sources', message='BOM 导入来源记录已保存',
|
||||||
details={'source_map_path': str(mapping), 'source_count': len({row.source for row in rows})})
|
details={'source_map_path': str(mapping), 'source_count': len({row.source for row in rows}),
|
||||||
|
'warnings': warnings})
|
||||||
report = inspect_batch(self, task_id, normalized, stop_event=stop_event,
|
report = inspect_batch(self, task_id, normalized, stop_event=stop_event,
|
||||||
on_progress=on_progress, on_phase=inspection_phase, runtime=runtime,
|
on_progress=on_progress, on_phase=inspection_phase, runtime=runtime,
|
||||||
**({'allow_partial': True} if allow_partial else {}))
|
**({'allow_partial': True} if allow_partial else {}))
|
||||||
|
|||||||
@@ -779,21 +779,22 @@ class ProjectPlanPanel(QWidget):
|
|||||||
report = state.report
|
report = state.report
|
||||||
if report is None:
|
if report is None:
|
||||||
return '', '', ''
|
return '', '', ''
|
||||||
|
warning_summary = f' · 警告 {len(report.warnings)} 项' if report.warnings else ''
|
||||||
if report.deferred:
|
if report.deferred:
|
||||||
failed_paths = {row.project_path for row in report.rows if row.status == 'failed'}
|
failed_paths = {row.project_path for row in report.rows if row.status == 'failed'}
|
||||||
accepted = tuple(row for row in report.rows if row.project_path not in failed_paths)
|
accepted = tuple(row for row in report.rows if row.project_path not in failed_paths)
|
||||||
summary = (f'BOM 表格已保存,工程位号待核验:{len(accepted)} 行、'
|
summary = (f'BOM 表格已保存,工程位号待核验:{len(accepted)} 行、'
|
||||||
f'{len({row.project_path for row in accepted})} 个工程;失败 {report.failed_rows} 行。')
|
f'{len({row.project_path for row in accepted})} 个工程;失败 {report.failed_rows} 行{warning_summary}。')
|
||||||
details = [summary, '确认执行后仅核验当前工程;本次导入未读取工程位号。']
|
details = [summary, *report.warnings, '确认执行后仅核验当前工程;本次导入未读取工程位号。']
|
||||||
details.extend(f'{row.project_name} · {Path(row.source_file).name} 第 {row.source_row} 行:{row.reason}'
|
details.extend(f'{row.project_name} · {Path(row.source_file).name} 第 {row.source_row} 行:{row.reason}'
|
||||||
for row in report.rows)
|
for row in report.rows)
|
||||||
return summary, '\n'.join(details), 'BOM 已保存 · 待核验 · 详情'
|
return summary, '\n'.join(details), f'BOM 已保存 · 待核验{warning_summary} · 详情'
|
||||||
outcome = '校验通过' if state.phase is BomImportPhase.PREVIEW_READY else '校验未通过'
|
outcome = '校验通过' if state.phase is BomImportPhase.PREVIEW_READY else '校验未通过'
|
||||||
summary = (f'BOM {outcome}:共 {report.total_rows} 行,通过 {report.passed_rows} 行、'
|
summary = (f'BOM {outcome}:共 {report.total_rows} 行,通过 {report.passed_rows} 行、'
|
||||||
f'失败 {report.failed_rows} 行、未检查 {report.unchecked_rows} 行;'
|
f'失败 {report.failed_rows} 行、未检查 {report.unchecked_rows} 行;'
|
||||||
f'共 {report.total_projects} 个工程,通过 {report.passed_projects} 个、'
|
f'共 {report.total_projects} 个工程,通过 {report.passed_projects} 个、'
|
||||||
f'失败 {report.failed_projects} 个、未检查 {report.unchecked_projects} 个。')
|
f'失败 {report.failed_projects} 个、未检查 {report.unchecked_projects} 个{warning_summary}。')
|
||||||
details = [summary, *report.errors]
|
details = [summary, *report.errors, *report.warnings]
|
||||||
if report.source_map_path is not None:
|
if report.source_map_path is not None:
|
||||||
details.append(f'导入来源记录:{report.source_map_path}')
|
details.append(f'导入来源记录:{report.source_map_path}')
|
||||||
details.extend(f'{Path(row.source_file).name + " · " if row.source_file else ""}'
|
details.extend(f'{Path(row.source_file).name + " · " if row.source_file else ""}'
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
"""Safe multi-file BOM loading and project routing for workspace imports."""
|
"""Safe multi-file BOM loading and project routing for workspace imports."""
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from difflib import get_close_matches
|
||||||
import hashlib
|
import hashlib
|
||||||
from pathlib import Path, PureWindowsPath
|
from pathlib import Path, PureWindowsPath
|
||||||
|
|
||||||
from openpyxl import load_workbook
|
from openpyxl import load_workbook
|
||||||
|
|
||||||
|
from .bom_import_report import BomImportReport, BomInspectionError
|
||||||
from .bom_plan import BOM_HEADERS, _normal_headers, _part_number_text, write_bom_template
|
from .bom_plan import BOM_HEADERS, _normal_headers, _part_number_text, write_bom_template
|
||||||
from .errors import TaskCenterError
|
from .errors import TaskCenterError
|
||||||
|
|
||||||
@@ -55,7 +57,37 @@ def _selected_xlsx(sources):
|
|||||||
return tuple(sorted(paths, key=lambda path: str(path).casefold()))
|
return tuple(sorted(paths, key=lambda path: str(path).casefold()))
|
||||||
|
|
||||||
|
|
||||||
def load_sources(sources, *, stop_event=None, on_progress=None, allow_partial=False):
|
_REQUIRED_HEADERS = (
|
||||||
|
('old_part_number', '旧料号'), ('new_part_number', '新料号'), ('refdes', '位号'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _source_headers(path, cells):
|
||||||
|
headers = _normal_headers(tuple(cell.value for cell in cells))
|
||||||
|
names = tuple(name for name in headers if name)
|
||||||
|
unknown = tuple(str(cell.value).strip() for cell, name in zip(cells, headers, strict=True)
|
||||||
|
if not name and cell.value is not None and str(cell.value).strip())
|
||||||
|
if any(cell.data_type == 'f' for cell in cells):
|
||||||
|
reason = 'BOM 表头不接受公式'
|
||||||
|
elif len(names) != len(set(names)):
|
||||||
|
reason = 'BOM 列名重复'
|
||||||
|
else:
|
||||||
|
missing = [(name, label) for name, label in _REQUIRED_HEADERS if name not in names]
|
||||||
|
if not missing:
|
||||||
|
return {name: index for index, name in enumerate(headers) if name}, unknown
|
||||||
|
labels = '、'.join(label for _, label in missing)
|
||||||
|
hints = []
|
||||||
|
for name, label in missing:
|
||||||
|
matches = (get_close_matches(label, unknown, n=1, cutoff=.7)
|
||||||
|
or get_close_matches(name, unknown, n=1, cutoff=.8))
|
||||||
|
if matches:
|
||||||
|
hints.append(f'请将「{matches[0]}」改为「{label}」')
|
||||||
|
reason = '。'.join([f'BOM 缺少必需列「{labels}」', *hints])
|
||||||
|
message = f'{path.name} 第 1 行:{reason}'
|
||||||
|
raise BomInspectionError(TaskCenterError('bom_import', message), BomImportReport((), (), errors=(message,)))
|
||||||
|
|
||||||
|
|
||||||
|
def load_sources(sources, *, stop_event=None, on_progress=None, allow_partial=False, warnings=None):
|
||||||
"""Read every selected workbook before any CAD operation starts."""
|
"""Read every selected workbook before any CAD operation starts."""
|
||||||
from .operation_control import check_cancelled
|
from .operation_control import check_cancelled
|
||||||
|
|
||||||
@@ -74,17 +106,7 @@ def load_sources(sources, *, stop_event=None, on_progress=None, allow_partial=Fa
|
|||||||
if len(workbook.worksheets) != 1:
|
if len(workbook.worksheets) != 1:
|
||||||
raise ValueError('BOM 只能包含一个工作表')
|
raise ValueError('BOM 只能包含一个工作表')
|
||||||
rows = iter(workbook.active.iter_rows())
|
rows = iter(workbook.active.iter_rows())
|
||||||
header_cells = next(rows, ())
|
positions, unknown = _source_headers(path, next(rows, ()))
|
||||||
headers = _normal_headers(tuple(cell.value for cell in header_cells))
|
|
||||||
names = tuple(name for name in headers if name)
|
|
||||||
if len(names) != len(set(names)):
|
|
||||||
raise ValueError('BOM 列名重复')
|
|
||||||
required = {'old_part_number', 'new_part_number', 'refdes'}
|
|
||||||
if not required <= set(names):
|
|
||||||
raise ValueError('BOM 必须包含旧料号、新料号和位号列')
|
|
||||||
if any(cell.data_type == 'f' for cell in header_cells):
|
|
||||||
raise ValueError('BOM 表头不接受公式')
|
|
||||||
positions = {name: index for index, name in enumerate(headers) if name}
|
|
||||||
for excel_row, cells in enumerate(rows, 2):
|
for excel_row, cells in enumerate(rows, 2):
|
||||||
check_cancelled(stop_event)
|
check_cancelled(stop_event)
|
||||||
formula = any(cell.data_type == 'f' for cell in cells)
|
formula = any(cell.data_type == 'f' for cell in cells)
|
||||||
@@ -116,6 +138,8 @@ def load_sources(sources, *, stop_event=None, on_progress=None, allow_partial=Fa
|
|||||||
result.append(SourceRow(path, excel_row, values, value_mode, source_sha256))
|
result.append(SourceRow(path, excel_row, values, value_mode, source_sha256))
|
||||||
if hashlib.sha256(path.read_bytes()).hexdigest() != source_sha256:
|
if hashlib.sha256(path.read_bytes()).hexdigest() != source_sha256:
|
||||||
raise ValueError('BOM 来源在读取期间已改变,请重新导入')
|
raise ValueError('BOM 来源在读取期间已改变,请重新导入')
|
||||||
|
if warnings is not None:
|
||||||
|
warnings.extend(f'{path.name}:已忽略未知列「{name}」' for name in unknown)
|
||||||
except TaskCenterError:
|
except TaskCenterError:
|
||||||
raise
|
raise
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from openpyxl import load_workbook
|
||||||
|
from PySide6.QtWidgets import QFileDialog
|
||||||
|
|
||||||
|
from test_bom_batch import batch, records_for
|
||||||
|
from dx_productivity.trial_task_center.bom_plan import write_bom_template
|
||||||
|
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('case', ['extra', 'near', 'missing', 'header_formula', 'row_formula', 'original'])
|
||||||
|
def test_bom_header_feedback_through_workspace(case, batch, tmp_path, qtbot, monkeypatch):
|
||||||
|
service, _, tasks, targets, inventory_calls = batch
|
||||||
|
task = tasks[0]
|
||||||
|
record = records_for(tasks, targets)[0]
|
||||||
|
source = write_bom_template(tmp_path / f'{case}.xlsx', [record])
|
||||||
|
workbook = load_workbook(source)
|
||||||
|
sheet = workbook.active
|
||||||
|
if case == 'extra':
|
||||||
|
sheet['L1'], sheet['L2'] = '供应商', 'Example supplier'
|
||||||
|
sheet['M1'], sheet['M2'] = '备注', 'Example note'
|
||||||
|
elif case == 'near':
|
||||||
|
sheet['D1'] = '新料号编码'
|
||||||
|
elif case == 'missing':
|
||||||
|
sheet['D1'] = None
|
||||||
|
elif case == 'header_formula':
|
||||||
|
sheet['L1'] = '=1+1'
|
||||||
|
elif case == 'row_formula':
|
||||||
|
sheet['L1'], sheet['L2'] = '备注', '=1+1'
|
||||||
|
workbook.save(source)
|
||||||
|
workbook.close()
|
||||||
|
assert_workspace_import(case, source, task, service, inventory_calls, qtbot, monkeypatch)
|
||||||
|
|
||||||
|
|
||||||
|
def test_field_extra_column_through_workspace(batch, tmp_path, qtbot, monkeypatch):
|
||||||
|
field = os.environ.get('DX_ISSUE33_D5_FIELD')
|
||||||
|
if not field:
|
||||||
|
pytest.skip('set DX_ISSUE33_D5_FIELD to replay the field attachment')
|
||||||
|
service, _, tasks, targets, inventory_calls = batch
|
||||||
|
source = tmp_path / Path(field).name
|
||||||
|
workbook = load_workbook(field)
|
||||||
|
sheet = workbook.active
|
||||||
|
# Rebind to the local fixture project. Keep the original Excel header and BOM cells.
|
||||||
|
sheet['A2'] = tasks[0].name
|
||||||
|
sheet['B2'] = str(targets[tasks[0].task_id][0].project_path)
|
||||||
|
workbook.save(source)
|
||||||
|
workbook.close()
|
||||||
|
assert_workspace_import('field', source, tasks[0], service, inventory_calls, qtbot, monkeypatch)
|
||||||
|
|
||||||
|
|
||||||
|
def assert_workspace_import(case, source, task, service, inventory_calls, qtbot, monkeypatch):
|
||||||
|
window = TrialTaskCenterWindow(service)
|
||||||
|
window.auto_intervention_check.setChecked(False)
|
||||||
|
qtbot.addWidget(window)
|
||||||
|
window.open_task(task.task_id)
|
||||||
|
panel = window.plan_panel
|
||||||
|
qtbot.waitUntil(panel.import_bom_button.isEnabled, timeout=5000)
|
||||||
|
monkeypatch.setattr(QFileDialog, 'getOpenFileNames', lambda *args: ([str(source)], 'Excel (*.xlsx)'))
|
||||||
|
panel.import_bom_button.click()
|
||||||
|
qtbot.waitUntil(lambda: not window._workers, timeout=8000)
|
||||||
|
status = window.run_panel.operator_band.text()
|
||||||
|
print(status)
|
||||||
|
pending = service.pending_bom(task.task_id)
|
||||||
|
assert not inventory_calls
|
||||||
|
if case in {'extra', 'field', 'original', 'near', 'missing', 'header_formula'}:
|
||||||
|
panel.report_toggle.setChecked(True)
|
||||||
|
assert panel.report_dialog is not None
|
||||||
|
details = panel.report_dialog.view.toPlainText()
|
||||||
|
print(details)
|
||||||
|
if case in {'extra', 'field', 'original'}:
|
||||||
|
assert len(pending) == 1
|
||||||
|
assert panel.last_bom_report.failed_rows == 0 and panel.last_bom_report.deferred
|
||||||
|
if case == 'extra':
|
||||||
|
assert '失败 0 行' in status and '警告 2 项' in status
|
||||||
|
assert all(text in details for text in ('已忽略', '供应商', '备注', source.name))
|
||||||
|
assert pending[0].record.new == 'NEW-0'
|
||||||
|
events = (service._logging.root / 'tasks' / task.task_id / 'events.jsonl').read_text(encoding='utf-8')
|
||||||
|
entries = [json.loads(line) for line in events.splitlines()]
|
||||||
|
entry = next(event for event in entries if event['operation'] == 'import_bom_drafts')
|
||||||
|
assert tuple(entry['details']['warnings']) == panel.last_bom_report.warnings
|
||||||
|
elif case == 'field':
|
||||||
|
assert '警告 1 项' in status and 'extra_column' in details
|
||||||
|
else:
|
||||||
|
assert '警告' not in status and '已忽略' not in details
|
||||||
|
else:
|
||||||
|
assert not pending
|
||||||
|
if case == 'near':
|
||||||
|
assert '缺少必需列「新料号」' in status
|
||||||
|
assert '「新料号编码」' in details and '改为「新料号」' in details
|
||||||
|
elif case == 'missing':
|
||||||
|
assert '缺少必需列「新料号」' in status and '新料号' in details
|
||||||
|
elif case == 'header_formula':
|
||||||
|
assert 'BOM 表头不接受公式' in status and 'BOM 表头不接受公式' in details
|
||||||
|
else:
|
||||||
|
assert '第 2 行不接受公式' in status
|
||||||
|
window.close()
|
||||||
@@ -9,6 +9,8 @@ from test_bom_batch import batch
|
|||||||
|
|
||||||
|
|
||||||
def test_real_supervised_sources_roundtrip_origin_metadata_and_preview(batch, tmp_path):
|
def test_real_supervised_sources_roundtrip_origin_metadata_and_preview(batch, tmp_path):
|
||||||
|
from openpyxl import load_workbook
|
||||||
|
|
||||||
from dx_productivity.trial_task_center.bom_plan import write_bom_template
|
from dx_productivity.trial_task_center.bom_plan import write_bom_template
|
||||||
service, store, tasks, targets, calls = batch
|
service, store, tasks, targets, calls = batch
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
@@ -17,9 +19,14 @@ def test_real_supervised_sources_roundtrip_origin_metadata_and_preview(batch, tm
|
|||||||
'project_name': task.name, 'project_path': str(targets[task.task_id][0].project_path),
|
'project_name': task.name, 'project_path': str(targets[task.task_id][0].project_path),
|
||||||
'old_part_number': 'OLD', 'new_part_number': 'NEW', 'refdes': 'R1', 'value_mode': 'part_number',
|
'old_part_number': 'OLD', 'new_part_number': 'NEW', 'refdes': 'R1', 'value_mode': 'part_number',
|
||||||
},)) for index, task in enumerate(tasks))
|
},)) for index, task in enumerate(tasks))
|
||||||
|
workbook = load_workbook(sources[0])
|
||||||
|
workbook.active['M1'] = '备注'
|
||||||
|
workbook.save(sources[0])
|
||||||
|
workbook.close()
|
||||||
service._supervised = True
|
service._supervised = True
|
||||||
report = service.preview_bom_sources(tasks[0].task_id, sources)
|
report = service.preview_bom_sources(tasks[0].task_id, sources)
|
||||||
assert report.passed_rows == 2 and report.preview is not None
|
assert report.passed_rows == 2 and report.preview is not None
|
||||||
|
assert report.warnings == ('source-0.xlsx:已忽略未知列「备注」',)
|
||||||
assert tuple(row.source_file for row in report.rows) == tuple(str(path.resolve()) for path in sources)
|
assert tuple(row.source_file for row in report.rows) == tuple(str(path.resolve()) for path in sources)
|
||||||
assert all(row.source_row == 2 for row in report.rows)
|
assert all(row.source_row == 2 for row in report.rows)
|
||||||
assert report.source_map_path.is_file()
|
assert report.source_map_path.is_file()
|
||||||
|
|||||||
@@ -1,175 +0,0 @@
|
|||||||
from types import SimpleNamespace
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from dx_productivity.trial_task_center import native_helper as native
|
|
||||||
from dx_productivity.trial_task_center.batch_attempt import prepare_attempt, read_attempt
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def attempt(tmp_path, monkeypatch):
|
|
||||||
job = 'job'
|
|
||||||
project = tmp_path / 'board.prj'
|
|
||||||
record_path = tmp_path / 'attempt.json'
|
|
||||||
snapshot = tmp_path / f'snapshot-{job}.tsv'
|
|
||||||
snapshot.write_text(f'M\t{project}\tOLD\tNEW\tMAIN:1\nC\tuid\tR1\t0\t0\t0\t1\t\n', encoding='utf-8')
|
|
||||||
(tmp_path / 'command.tsv').write_text(
|
|
||||||
f'job_id\ttask_id\tproject_path\n{job}\ttask\t{project}\n', encoding='utf-8')
|
|
||||||
record = prepare_attempt(record_path, session_id='session', generation=1,
|
|
||||||
job_id=job, task_id='task', project_path=project)
|
|
||||||
for name, value in {
|
|
||||||
'DXPART_DESKTOP': 'dx-test',
|
|
||||||
'DXPART_ATTEMPT_FILE': record_path,
|
|
||||||
'DXPART_ATTEMPT_ID': record['attempt_id'],
|
|
||||||
'DXPART_BATCH_GENERATION': record['generation'],
|
|
||||||
'DXPART_BATCH_SESSION_ID': record['session_id'],
|
|
||||||
}.items():
|
|
||||||
monkeypatch.setenv(name, str(value))
|
|
||||||
return snapshot, record_path
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def clock(monkeypatch):
|
|
||||||
now = [0.]
|
|
||||||
monkeypatch.setattr(native, 'time', SimpleNamespace(
|
|
||||||
monotonic=lambda: now[0], sleep=lambda seconds: now.__setitem__(0, now[0] + seconds)))
|
|
||||||
return now
|
|
||||||
|
|
||||||
|
|
||||||
def test_cold_list_recreation_reapplies_filter_and_uses_the_new_handle(attempt, clock):
|
|
||||||
snapshot, record = attempt
|
|
||||||
report, filtered = {}, []
|
|
||||||
browsing = False
|
|
||||||
|
|
||||||
def browse():
|
|
||||||
nonlocal browsing
|
|
||||||
browsing = True
|
|
||||||
|
|
||||||
def controls():
|
|
||||||
if browsing:
|
|
||||||
return (10, 11) if clock[0] < .3 else (20, 21)
|
|
||||||
return None
|
|
||||||
|
|
||||||
list_handle, rows = native.load_databook_target(snapshot, report, 'NEW',
|
|
||||||
controls=controls, browse=browse, filter_part=lambda handle: filtered.append(handle),
|
|
||||||
list_rows=lambda handle: [(handle, ['GATE', 'NEW', 'lib:SYM'])],
|
|
||||||
dialogs=lambda: (), close_dialog=lambda handle: pytest.fail('unexpected close'))
|
|
||||||
assert (list_handle, rows[0][0], filtered) == (20, 20, [11, 21])
|
|
||||||
assert report['databook']['loads'][0]['mode'] == 'cold'
|
|
||||||
assert read_attempt(record)['state'] == 'prepared'
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('during', ['filter', 'rows'])
|
|
||||||
def test_control_destroyed_between_discovery_and_access_is_reacquired(attempt, clock, during):
|
|
||||||
snapshot, record = attempt
|
|
||||||
state = {'controls': (10, 11)}
|
|
||||||
visited = []
|
|
||||||
|
|
||||||
def destroyed():
|
|
||||||
state['controls'] = (20, 21)
|
|
||||||
error = OSError('stale DxDataBook control')
|
|
||||||
if during == 'filter':
|
|
||||||
error.winerror = 1400
|
|
||||||
else:
|
|
||||||
error.hresult = -2147220991
|
|
||||||
raise error
|
|
||||||
|
|
||||||
def filter_part(handle):
|
|
||||||
visited.append(handle)
|
|
||||||
if during == 'filter' and handle == 11:
|
|
||||||
destroyed()
|
|
||||||
|
|
||||||
def rows(handle):
|
|
||||||
if during == 'rows' and handle == 10:
|
|
||||||
destroyed()
|
|
||||||
return [(handle, ['GATE', 'NEW', 'lib:SYM'])]
|
|
||||||
|
|
||||||
report = {}
|
|
||||||
handle, _ = native.load_databook_target(snapshot, report, 'NEW',
|
|
||||||
controls=lambda: state['controls'], browse=lambda: None, filter_part=filter_part,
|
|
||||||
list_rows=rows, dialogs=lambda: (), close_dialog=lambda _: pytest.fail('unexpected close'))
|
|
||||||
assert handle == 20 and visited == [11, 21]
|
|
||||||
assert len(report['databook']['loads']) == 1
|
|
||||||
assert read_attempt(record)['state'] == 'prepared'
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('already_written', [False, True])
|
|
||||||
def test_timeout_reissues_filter_once_only_with_bound_prepared_attempt(attempt, clock, already_written):
|
|
||||||
snapshot, record = attempt
|
|
||||||
if already_written:
|
|
||||||
native.mark_snapshot_mutation(snapshot)
|
|
||||||
report, filters = {}, []
|
|
||||||
|
|
||||||
def run():
|
|
||||||
return native.load_databook_target(snapshot, report, 'NEW',
|
|
||||||
controls=lambda: (10, 11), browse=lambda: None,
|
|
||||||
filter_part=lambda handle: filters.append(handle), list_rows=lambda handle: [],
|
|
||||||
dialogs=lambda: (), close_dialog=lambda handle: pytest.fail('unexpected close'))
|
|
||||||
|
|
||||||
with pytest.raises(TimeoutError, match='DxDataBook'):
|
|
||||||
run()
|
|
||||||
loads = report['databook']['loads']
|
|
||||||
assert [load['mode'] for load in loads] == ['warm'] * (1 if already_written else 2)
|
|
||||||
assert len(filters) == len(loads)
|
|
||||||
assert read_attempt(record)['state'] == ('mutation_possible' if already_written else 'prepared')
|
|
||||||
|
|
||||||
|
|
||||||
def test_retry_closes_only_new_owned_empty_dialog_and_persists_evidence_first(attempt, clock):
|
|
||||||
snapshot, record = attempt
|
|
||||||
report, closed = {}, []
|
|
||||||
blank = {'hwnd': 19, 'owner': 7, 'title': '', 'children': [], 'dismissible': True}
|
|
||||||
previous = dict(blank, hwnd=18)
|
|
||||||
named = dict(blank, hwnd=20, title='Save', dismissible=False)
|
|
||||||
|
|
||||||
def dialogs():
|
|
||||||
return [previous, named] if clock[0] == 0 else [previous, blank, named]
|
|
||||||
|
|
||||||
def close(row):
|
|
||||||
import json
|
|
||||||
|
|
||||||
evidence = json.loads(snapshot.with_suffix('.tsv.native.json').read_bytes())
|
|
||||||
assert evidence['databook']['loads'][0]['dialogs'][0]['hwnd'] == 19
|
|
||||||
assert evidence['databook']['loads'][0]['attempt_state'] == 'prepared'
|
|
||||||
closed.append(row['hwnd'])
|
|
||||||
|
|
||||||
native.load_databook_target(snapshot, report, 'NEW',
|
|
||||||
controls=lambda: (10, 11), browse=lambda: None, filter_part=lambda handle: None,
|
|
||||||
list_rows=lambda handle: [(handle, ['GATE', 'NEW', 'lib:SYM'])] if closed else [],
|
|
||||||
dialogs=dialogs, close_dialog=close)
|
|
||||||
assert closed == [19]
|
|
||||||
assert len(report['databook']['loads']) == 2
|
|
||||||
assert read_attempt(record)['state'] == 'prepared'
|
|
||||||
|
|
||||||
|
|
||||||
def test_named_or_unowned_prompt_keeps_operator_handling(attempt, clock):
|
|
||||||
snapshot, _ = attempt
|
|
||||||
report = {}
|
|
||||||
with pytest.raises(TimeoutError, match='DxDataBook'):
|
|
||||||
native.load_databook_target(snapshot, report, 'NEW',
|
|
||||||
controls=lambda: (10, 11), browse=lambda: None, filter_part=lambda handle: None,
|
|
||||||
list_rows=lambda handle: [],
|
|
||||||
dialogs=lambda: [{'hwnd': 20, 'dismissible': False}] if clock[0] else [],
|
|
||||||
close_dialog=lambda row: pytest.fail('unrecognized prompt was closed'))
|
|
||||||
assert len(report['databook']['loads']) == 1
|
|
||||||
|
|
||||||
|
|
||||||
def test_dialog_fingerprint_requires_same_owner_pid_thread_and_empty_controls(monkeypatch):
|
|
||||||
from dx_productivity.trial_task_center import cad_dialogs
|
|
||||||
|
|
||||||
owner, pid = 7, 8
|
|
||||||
windows = {10: (1, pid, owner), 11: (1, pid, 99), 12: (2, pid, owner),
|
|
||||||
13: (1, 99, owner), 14: (1, pid, owner), owner: (1, pid, 99)}
|
|
||||||
monkeypatch.setattr(cad_dialogs, '_text', lambda hwnd: '')
|
|
||||||
gui = SimpleNamespace(
|
|
||||||
error=RuntimeError, IsWindowVisible=lambda hwnd: True, IsWindowEnabled=lambda hwnd: False,
|
|
||||||
EnumWindows=lambda callback, _: [callback(hwnd, None) for hwnd in windows],
|
|
||||||
GetWindow=lambda hwnd, _: windows[hwnd][2],
|
|
||||||
EnumChildWindows=lambda hwnd, callback, _: callback(20, None) if hwnd == 14 else None,
|
|
||||||
GetClassName=lambda hwnd: 'Button' if hwnd == 20 else '#32770',
|
|
||||||
GetDlgCtrlID=lambda hwnd: 1, GetParent=lambda hwnd: 14,
|
|
||||||
)
|
|
||||||
process = SimpleNamespace(GetWindowThreadProcessId=lambda hwnd: windows[hwnd][:2])
|
|
||||||
rows = native.databook_dialogs(gui, process, pid, owner, 99)
|
|
||||||
assert [row['hwnd'] for row in rows] == [10, 11, 12, 14]
|
|
||||||
assert [row['hwnd'] for row in rows if row['dismissible']] == [10]
|
|
||||||
assert rows[-1]['children'] == [{'hwnd': 20, 'parent': 14, 'class': 'Button', 'id': 1}]
|
|
||||||
@@ -3,8 +3,7 @@ import test_accuracy_vbs_guards as guards
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('fault', ['', 'snapshot', 'identity', 'transaction', 'native',
|
@pytest.mark.parametrize('fault', ['', 'snapshot', 'identity', 'transaction', 'native',
|
||||||
'native_unresolved', 'prior_staged_write', 'save_requested',
|
'save_requested', 'save_committed', 'close'])
|
||||||
'save_committed', 'close'])
|
|
||||||
def test_safe_pause_cannot_interrupt_verified_failure_cleanup(tmp_path, fault):
|
def test_safe_pause_cannot_interrupt_verified_failure_cleanup(tmp_path, fault):
|
||||||
output = guards.run_vbs(tmp_path, ['QPProgress', 'QPDiscardFailedBatchProject',
|
output = guards.run_vbs(tmp_path, ['QPProgress', 'QPDiscardFailedBatchProject',
|
||||||
'QPCloseBatchProject', 'QPReadUtf8'], '''
|
'QPCloseBatchProject', 'QPReadUtf8'], '''
|
||||||
@@ -34,8 +33,6 @@ Set QP_Fso=CreateObject("Scripting.FileSystemObject")
|
|||||||
QP_Root="''' + str(tmp_path) + '''":QP_AttemptToken="token":QP_ProgressSequence=0
|
QP_Root="''' + str(tmp_path) + '''":QP_AttemptToken="token":QP_ProgressSequence=0
|
||||||
QP_BatchMode=True:QP_OwnedProject=True:QP_OwnedProjectPath="board.prj"
|
QP_BatchMode=True:QP_OwnedProject=True:QP_OwnedProjectPath="board.prj"
|
||||||
QP_NativeMutationPossible=''' + str(fault == 'native') + '''
|
QP_NativeMutationPossible=''' + str(fault == 'native') + '''
|
||||||
QP_NativeCallActive=''' + str(fault == 'native_unresolved') + '''
|
|
||||||
If ''' + str(fault == 'prior_staged_write') + ''' Then QP_SessionItems.Add "previous-job", "restored_ok"
|
|
||||||
QP_BatchSaveRequested=''' + str(fault == 'save_requested') + '''
|
QP_BatchSaveRequested=''' + str(fault == 'save_requested') + '''
|
||||||
QP_BatchSaveCommitted=''' + str(fault == 'save_committed') + '''
|
QP_BatchSaveCommitted=''' + str(fault == 'save_committed') + '''
|
||||||
Class FakeApp
|
Class FakeApp
|
||||||
@@ -88,8 +85,8 @@ End Sub
|
|||||||
Sub QPLog(ByVal Root,ByVal Level,ByVal Message)
|
Sub QPLog(ByVal Root,ByVal Level,ByVal Message)
|
||||||
End Sub
|
End Sub
|
||||||
''')
|
''')
|
||||||
paused_before = fault not in {'native', 'native_unresolved'}
|
paused_before = fault != 'native'
|
||||||
paused_after = fault not in {'native', 'native_unresolved', 'transaction'}
|
paused_after = fault not in {'native', 'transaction'}
|
||||||
assert output.splitlines()[-1] == f'result:{paused_before}:{not fault}:{bool(fault)}:{paused_after}'
|
assert output.splitlines()[-1] == f'result:{paused_before}:{not fault}:{bool(fault)}:{paused_after}'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ def test_native_catalog_checks_cannot_cold_read_or_submit_on_miss(tmp_path, monk
|
|||||||
elif code == 0xF5 and handle == 1695:
|
elif code == 0xF5 and handle == 1695:
|
||||||
submits.append(handle)
|
submits.append(handle)
|
||||||
raise RuntimeError('native submit reached')
|
raise RuntimeError('native submit reached')
|
||||||
return 1, 1
|
|
||||||
gui = SimpleNamespace(error=RuntimeError, GetAncestor=lambda *args: 1, EnumWindows=enum_windows,
|
gui = SimpleNamespace(error=RuntimeError, GetAncestor=lambda *args: 1, EnumWindows=enum_windows,
|
||||||
EnumChildWindows=lambda *args: None, IsWindowVisible=lambda handle: True,
|
EnumChildWindows=lambda *args: None, IsWindowVisible=lambda handle: True,
|
||||||
GetClassName=lambda handle: {2: '#32770', 3: 'SysListView32', 4: 'Edit'}.get(handle, 'Main'),
|
GetClassName=lambda handle: {2: '#32770', 3: 'SysListView32', 4: 'Edit'}.get(handle, 'Main'),
|
||||||
@@ -180,7 +179,7 @@ def test_native_catalog_checks_cannot_cold_read_or_submit_on_miss(tmp_path, monk
|
|||||||
monkeypatch.setattr(native_helper, 'selection', lambda *args: None)
|
monkeypatch.setattr(native_helper, 'selection', lambda *args: None)
|
||||||
monkeypatch.setattr(native_helper, 'replacement_command_from_resources', lambda *args: 33977)
|
monkeypatch.setattr(native_helper, 'replacement_command_from_resources', lambda *args: 33977)
|
||||||
monkeypatch.setattr(native_helper, 'wait_for', lambda callback, *args, **kwargs: callback())
|
monkeypatch.setattr(native_helper, 'wait_for', lambda callback, *args, **kwargs: callback())
|
||||||
monkeypatch.setattr(native_helper, 'wait_for_library_rows', lambda callback, *args, **kwargs: callback())
|
monkeypatch.setattr(native_helper, 'wait_for_library_rows', lambda callback, *args: callback())
|
||||||
monkeypatch.setattr(native_helper, 'wait_for_native_target', lambda callback, *args: callback())
|
monkeypatch.setattr(native_helper, 'wait_for_native_target', lambda callback, *args: callback())
|
||||||
report = {}
|
report = {}
|
||||||
with pytest.raises(ValueError if fail_at else RuntimeError, match='重新读取目标封装' if fail_at else 'native submit reached'):
|
with pytest.raises(ValueError if fail_at else RuntimeError, match='重新读取目标封装' if fail_at else 'native submit reached'):
|
||||||
|
|||||||
Reference in new issue
Block a user