Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c61dbc551b | ||
|
|
9cb19902d9 | ||
|
|
4f8fbd7806 | ||
|
|
57b2c14056 | ||
|
|
b544d92702 | ||
|
|
bd88b2e39e |
No files matched your search
@@ -38,10 +38,11 @@ jobs:
|
||||
done
|
||||
apt-get -o Acquire::Retries=2 -o APT::Update::Error-Mode=any update
|
||||
fi
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=2 install -y --no-install-recommends python3 python3-venv libegl1 libopengl0 libgl1 libxkbcommon0 libdbus-1-3 libfontconfig1 libglib2.0-0 libxcb-cursor0 fonts-dejavu-core libnss3 libasound2 libxcomposite1 libxdamage1 libxrandr2 libxtst6 libgbm1
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=2 install -y --no-install-recommends python3 python3-venv libegl1 libopengl0 libgl1 libxkbcommon0 libdbus-1-3 libfontconfig1 libglib2.0-0 libxcb-cursor0 fonts-dejavu-core libnss3 libasound2 libxcomposite1 libxdamage1 libxrandr2 libxtst6 libgbm1 libxkbfile1 libxss1 libxshmfence1 libx11-xcb1
|
||||
python3 -m venv /opt/ci-python
|
||||
/opt/ci-python/bin/python3 -m pip install 'pytest>=8,<9' 'pytest-qt>=4.4,<5' 'PySide6>=6.7,<7' 'openpyxl>=3.1,<4'
|
||||
/opt/ci-python/bin/python3 --version
|
||||
/opt/ci-python/bin/python3 -c "from PySide6.QtWebEngineCore import QWebEnginePage; from PySide6.QtWebEngineWidgets import QWebEngineView; print('Qt WebEngine native libraries loaded')"
|
||||
- name: Install supported Node and locked offline Harness dependencies
|
||||
run: |
|
||||
# The cached Node 20 image boots this runner; Harness requires Node 24.9+.
|
||||
@@ -62,12 +63,15 @@ jobs:
|
||||
tests/dsh/test_issue_broker.py
|
||||
tests/dsh/test_incidents.py
|
||||
tests/dsh/test_availability.py
|
||||
tests/dsh/test_availability_harness.py
|
||||
tests/dsh/test_availability_retry.py
|
||||
tests/dsh/test_health.py
|
||||
tests/ui/test_dsh_native_menu.py
|
||||
tests/ui/test_dsh_blockers.py
|
||||
tests/ui/test_dsh_blocker_sources.py
|
||||
tests/ui/test_dsh_diagnosis_lifecycle.py
|
||||
tests/ui/test_dsh_status_indicator.py
|
||||
tests/ui/test_nonblocking_controls.py
|
||||
tests/ui/test_pr10_review_edges.py
|
||||
tests/ui/test_query_observability.py
|
||||
tests/packaging/test_dsh_runtime_staging.py
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
面向 **Windows + DxDesigner / Expedition Enterprise 7.9.5** 的器件批量替换工具。一个工程对应一个任务,可以只替换同料号下的部分位号;支持直接编辑和 Excel BOM 导入,同批工程按顺序执行。
|
||||
|
||||
**最新版本:V1.2.2(预发布)** · [自解压 EXE](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.2/DxPartReplace-1.2.2.exe) · [ZIP 便携包](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.2/DxPartReplace-1.2.2.zip) · [版本说明与附件](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/tag/v1.2.2) · [完整使用说明](docs/user/v1.1.0-project-tasks.md)
|
||||
**当前版本:V1.3.0(本地包已验证,尚未上传 Release)** · [本版变更](docs/releases/v1.3.0.md) · [构建记录与 SHA256](docs/releases/v1.3.0-build.md) · [完整使用说明](docs/user/v1.1.0-project-tasks.md)
|
||||
|
||||
V1.2.2 新增操作历史、安全续跑与内置 7-Zip 的自解压 EXE,同时提供完整 Node/Qt 运行时、DSH 任务功能和全部 UI 资源。升级前备份 data,完整更新 EXE 与 _internal,不要只替换 EXE。
|
||||
V1.3.0 使用最新紫蓝双环图标,包含原生三栏 DSH助手、异常自动介入与核验、多文件 BOM 导入、逐项 Value 策略,以及按单器件隔离失败与安全恢复。AI 等待和后台查询不占普通任务执行通道,同一持续异常不会重复介入;状态灯仅显示圆点,悬浮查看原因与阶段。
|
||||
|
||||
本版合并 PR15 与 PR17,补齐操作历史和模型设置,提供自解压 EXE 与 ZIP 两种同内容发行包。[本版变更](docs/releases/v1.2.2.md)。
|
||||
本地交付目录为 `outputs/releases/v1.3.0`:自解压 EXE 约 **341 MiB**,ZIP 便携包约 **481 MiB**,附 SHA256 和逐文件清单。两种包均保留完整 Node/Harness、Qt WebEngine 和应用资源。升级前退出旧程序并备份 `data`,完整更新 EXE 与 `_internal`,不要只替换 EXE。
|
||||
|
||||
**已发布的旧版:V1.2.2(预发布)** · [自解压 EXE](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.2/DxPartReplace-1.2.2.exe) · [ZIP 便携包](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.2/DxPartReplace-1.2.2.zip) · [版本说明与附件](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/tag/v1.2.2)。V1.3.0 的远端下载入口将在实际上传后提供。
|
||||
|
||||
本版提供[目标封装选择](docs/user/target-cell-selection.md):目标封装可留空,此时工具不主动覆写封装,可后续与中心库同步;需要指定时,在料号规则中读取并选择合法封装。BOM 保持原 11 列。
|
||||
|
||||
@@ -23,10 +25,11 @@ DSH助手围绕真实任务中心工作,支持:
|
||||
- 识别已保存的逐项 Value 策略(继承、保留、Part Label、料号或自定义);可从对话打开当前任务的原生 BOM 多文件选择流程,校验后仍需核对预览并手动保存。
|
||||
- 在原生确认后按冻结范围执行任务,支持安全暂停、原队列恢复和排期授权。
|
||||
- 顶部 **AI 自动介入** 开关默认开启并记住设置;异常、BOM 校验失败、预检阻断、资源释放问题和后台操作长期无进展时自动新建诊断对话,收集脱敏证据,按规则重试或清理自有资源并核验,未解决则转受限 Git 工单。
|
||||
- 右上角使用无外框的 **AI 状态灯**:绿色待机、黄色介入中、红色未配置/不可用或待人工处理;关闭 **AI 自动介入** 后显示灰色静默。悬浮可查看介入原因、所属任务和当前阶段。未配置模型或 API Key 时,仅提示状态,不自动启动诊断、复盘或工单流程,也不弹窗、锁住任务操作;仍可手动打开助手配置模型。
|
||||
- 右上角使用无外框、无常驻文字的 **AI 状态灯**:绿色待机、黄色检查或介入中、红色未配置/不可用或待人工处理;关闭 **AI 自动介入** 后显示灰色静默。悬浮可查看状态、介入原因、所属任务和当前阶段,点击进入助手,右键可取消本次介入。未配置模型或 API Key 时,仅提示状态,不自动启动诊断、复盘或工单流程,也不弹窗、锁住任务操作;仍可手动打开助手配置模型。
|
||||
- AI 等待模型、复盘、工单上报及后台查询使用独立工作通道,不锁住普通任务操作。只有实际修复及核验占用任务执行通道;执行前重新核对任务证据和所属轮次,期间有新任务、未保存编辑或现场变化则放弃旧建议,保留证据且不自动重排。在助手面板取消诊断,或右键状态灯选择 **取消本次 AI 介入**,会停止模型请求、保存本地证据并转人工接管;已进入执行的 CAD 步骤仍按原暂停/强停机制安全收尾。拒绝关闭或取消未保存计划的关闭确认时,诊断继续。诊断与复盘从原生会话准备好后共享等待预算,默认 180 秒,随模型超时设置调整为 90–300 秒;运行时启动和会话创建另有最多 300 秒的等待上限,不挤占分析时间。
|
||||
- 后台读取异常先在约 200 毫秒后复查,连续失败才介入;同一持续阻塞不会周期性重复建会话,关闭再开启自动介入可主动重新诊断。面板分别显示清理次数及独立核验结果;资源自行释放显示“自行解除”,不会计作 AI 修复。资源清理使用独立控制,不显示 CAD 暂停或强停按钮。
|
||||
- 模型配置的后台检查不会取消健康的在途诊断,也不会把“配置恢复”当成用户重新开启开关。同一异常保持原事件编号,完成后不因配置状态波动重新发诊断;只恢复此前尚未开始的待处理项。仅新异常、用户重新导入或主动关闭再开启允许再次介入。
|
||||
- 本地模型配置检查仅在超时时补试一次,每次最多 3 秒;连续超时显示检查状态,在途诊断和事件去重保持有效。配置检查不请求远端模型,检查中或临时检查失败时,普通任务的原始错误仍会正常反馈。
|
||||
- 在右侧任务监管中查看运行、影响、排期、经验、工单和用量;审计损坏、证据缺失和未知计数会明确显示。
|
||||
|
||||
AI 不能直接写入 CAD、运行 Shell 或绕过确认门禁。普通对话可按用户要求读取本地文件;自动异常诊断为只读事件快照。不确定执行不会自动重放,恢复必须重新核对冻结计划、检查点和业务证据。未配置模型时仍可使用任务监管和本地恢复功能,但不会产生真实模型回复。
|
||||
@@ -231,6 +234,8 @@ DxPartReplace/
|
||||
|
||||
## 验证范围与已知限制
|
||||
|
||||
V1.3.0 本地发行脚本回归 **1358 项通过**;主程序与自解压包的 10 档图标、1.3.0 版本资源、冻结进程启动、自有资源释放和实际助手界面点击均已验证。自解压 EXE 与 ZIP 的 **66,805 个文件**通过 SHA256 与 ZIP CRC 核对,从最终包解出的程序再次启动验证通过。详见 [V1.3.0 构建记录](docs/releases/v1.3.0-build.md)。本轮未发送真实模型请求、修改真实用户 CAD 工程或上传 Release;官方 Harness 前端保留自身的预览版标记,产物未做代码签名。
|
||||
|
||||
V1.1.4 Beta 4 沿用批次后台资源管理:一次 BOM 导入或顺序执行共用一个私有桌面,CAD 按需启动并在同批工程间复用,批次结束统一退出。若提示 **资源释放待处理**,已保存核验的结果保留,请点击 **重新清理资源**;该操作只清理后台资源,不会再次替换。旧的工程保护锁仍按“核验并恢复”处理。设计、异常边界与实机结果见[批次运行时验收记录](docs/testing/2026-10-21-batch-private-runtime.md)。
|
||||
|
||||
资源释放会追加日志:在 **替换结果 / 日志 → 完整日志** 查看本批开始释放、释放成功/失败及重新清理的结果。独立文件位于 `data/batch-resources/<批次ID>/resource-release.log`,记录批次、桌面、CAD PID、退出码、释放耗时、句柄关闭和桌面消失的分别确认,以及失败原因;同时保留 `session.json` 的原始释放证明。重启后重新检查也会追加记录,不覆盖原失败日志。
|
||||
@@ -260,3 +265,5 @@ py -3.12 -m venv .venv
|
||||
- [历史流程和独立 CLI 说明](docs/user/trial-task-center.md)
|
||||
- [CLI 与原生批处理集成](docs/user/part-replacement.md)
|
||||
- [V1.1.3 版本说明](docs/releases/v1.1.3.md)
|
||||
- [V1.3.0 版本说明](docs/releases/v1.3.0.md)
|
||||
- [V1.3.0 构建记录与校验值](docs/releases/v1.3.0-build.md)
|
||||
@@ -0,0 +1,30 @@
|
||||
# v1.3.0 本地构建记录
|
||||
|
||||
2026-11-09 从 main `4f8fbd78062b04203c106efb2fad476a5d6dbc82` 准备独立发行工作区,仅带入批准的紫蓝双环图标、1.3.0 版本元数据及发行说明。2026-11-10 整理并提交发行准备源码。
|
||||
|
||||
版本同步到 Python 包、应用显示版本和 Windows PE 资源;正式版标记为 0。图标以 1024×1024 `app-master.png` 为源,导出运行时 PNG、文档图标及 16/20/24/32/40/48/64/96/128/256 像素 ICO。
|
||||
|
||||
## 验证结果
|
||||
|
||||
- 现有 Windows 发行脚本完整回归:1358 passed,1 条 COM 线程模式提示,无失败。
|
||||
- 打包配置与版本检查:8 passed;随后显式指定官方 7-Zip 工具运行真实自解压场景,1 passed。
|
||||
- 冻结主程序及自解压 EXE 的 Windows 版本资源均为 1.3.0 / 1.3.0.0,所有语言资源已更新;10 档图标像素与批准的 ICO 一致。
|
||||
- 冻结监督进程、进程身份识别、自有后台资源释放和正常退出检查通过;从最终包解出的程序再次通过相同检查。
|
||||
- 实际 UI 操作验证原生 Harness 三栏界面、SVG 动画、工具设置、自定义模型入口、未发送草稿和页面切换保留;未配置 Key,未发送模型请求,所有自有子进程正常退出。
|
||||
- 实际运行最终自解压 EXE,66,805 个文件与逐文件清单的 SHA256 完全一致;ZIP 每个成员的 CRC 与 SHA256 通过。该机器实测解压约 306.5 秒。
|
||||
- 交付副本复制后再次核对产物 SHA256,结果一致;安装包不包含用户数据目录。
|
||||
|
||||
## 产物
|
||||
|
||||
| 文件 | 字节数 | SHA256 |
|
||||
| --- | ---: | --- |
|
||||
| `DxPartReplace-1.3.0.exe` | 357640754 | `a179ae3b003d73e7aa9fb2ffc20b76c45cc571a072dc438200bdffd64aa0db1d` |
|
||||
| `DxPartReplace-1.3.0.zip` | 504669931 | `0c3fa4599f7989da7c14d14c70cb04bbcdac2bee1cebb07d2f3325462484fb47` |
|
||||
|
||||
本地交付目录为 `outputs/releases/v1.3.0`,包含安装包、校验文件、逐文件清单、验收报告和界面截图。大型发行二进制不加入 Git 源码提交。
|
||||
|
||||
自解压包使用官方 7-Zip 解压器副本,先替换图标和版本资源,再附加压缩数据;原始安装的 7-Zip 未修改。完整 Node/Harness 与 Qt WebEngine 运行时保留。
|
||||
|
||||
## 范围
|
||||
|
||||
本地包未上传,未创建远端 Release 或 Git 标签,未做代码签名。没有执行真实模型请求、远端测试工单或真实用户 CAD 工程替换。官方 Harness 前端保留自身的预览版标记。源码提交仅补充发行说明,不改变已验收包中的应用代码或图标。
|
||||
@@ -0,0 +1,13 @@
|
||||
# v1.3.0
|
||||
|
||||
以 main `4f8fbd7` 为基础,统一最新紫蓝双环图标,版本信息更新为 1.3.0。发行候选包已完成本地构建与核验,源码发布准备通过 PR 提交;远端 Release 与 Git 标签尚未创建。
|
||||
|
||||
本版包含原生三栏 DSH 助手、自动异常介入与核验、任务创建及多文件 BOM 交接、逐项 Value 策略、按单器件隔离失败及安全恢复。AI 等待与后台查询不占普通任务执行通道;同一持续异常去重,执行前重新核对授权、任务轮次及现场。状态灯以纯圆点显示,悬浮可看状态与原因。配置检查超时最多补试一次,不重建已完成事件。
|
||||
|
||||
交付自解压 EXE、便携 ZIP、SHA256 与逐文件清单。两种包均包含完整 Node/Harness、Qt WebEngine 和应用资源,内容一致。
|
||||
|
||||
升级前退出旧程序并备份 `data`;先解压到新目录,再按需迁移数据。保留主程序和 `_internal` 的相对位置,不只替换单个 EXE,也不要让新旧程序同时使用同一数据目录。新安装需要自行配置 AI 模型及 Key;本机仍需 DxDesigner EE 7.9.5、许可证和中央库才能执行 CAD 操作。
|
||||
|
||||
发行验证以随包的本地验收报告为准。打包和界面启动检查不等于已对真实用户工程完成替换,也不证明远端模型网络连接可用。
|
||||
|
||||
本地构建结果与产物校验值见 [v1.3.0 构建记录](v1.3.0-build.md)。
|
||||
@@ -0,0 +1,36 @@
|
||||
# PR #19 评论 #352 后续修复
|
||||
|
||||
审查基线为 `bd88b2e`,此前合并为 `f8f07d3`(父提交 `3669a0a`、`aff228e`)。本记录补充逐文件合并说明,保留已发布提交与原验证记录。
|
||||
|
||||
## 本轮调整
|
||||
|
||||
- 更新资源清理测试的 `_run_async` 替身:先交付操作结果,再调用 `on_finished`,对应生产代码释放工作线程后的接续协议;继续分别验证选择 No 不强制释放、选择 Yes 仅显式确认后释放。
|
||||
- 将可用性单元测试的 Node 路径与 Harness 包元数据替换为独立临时运行时,位置在被检查的数据目录之外,保留首次安装与只读检查不落盘的断言。三个真实原生配置组合场景移入 `test_availability_harness.py`;仅缺 Node/Harness 时跳过,并提示安装 Node.js 24.9+ 与执行 `npm ci --prefix integration/dsh`。
|
||||
- 原生本地检查只对 `TimeoutExpired` 重试一次,每次最多 3 秒;连续超时单列 `configuration_timeout`,格式错误、系统错误、实际配置错误及缺失凭据不触发额外重试。状态控制器对这一临时检查错误沿用已有容忍行为。
|
||||
- CI 增加资源清理、原生 Harness 集成与超时重试测试,保留强制安装锁定依赖及真实 Harness 的 23 场景离线预检。
|
||||
|
||||
## 九处冲突解决说明
|
||||
|
||||
下表记录 `f8f07d3` 的最终语义;源码路径以 `src/dx_productivity/` 为根,测试与工作流路径以仓库为根。
|
||||
|
||||
| 冲突文件 | 合并后保留的行为 |
|
||||
| --- | --- |
|
||||
| `.gitea/workflows/ci.yml` | 保留 main 的 Debian HTTPS 与镜像回退;采用 runner 可启动的 Node 镜像,叠加 Python/Qt、受支持 Node、锁定 Harness 安装、DSH/UI 回归与实际执行计数。 |
|
||||
| `dsh/incidents.py` | 优先使用 main 的共享问题项重试预算及精确 `operation_keys`;保留 DSH 执行许可、取消与修复准入。预算用尽不会退回旧重试路径。 |
|
||||
| `trial_task_center/ui/dsh_automation.py` | 只在实际变更边界申请执行权;用锁和释放确认消除超时后晚准入;保留取消和关闭收尾,诊断完成后按任务/运行身份被动刷新且不再次介入。 |
|
||||
| `trial_task_center/ui/dsh_operations.py` | 区分只读查询与占用执行通道的变更;保留独立读线程与请求串行化,并在排期确认/提交前复查其他对话框。 |
|
||||
| `trial_task_center/ui/dsh_task_lifecycle.py` | 保留 DSH 生命周期确认与异步检查;恢复原队列时调用 `resume_preflight`,按实际剩余问题项进行前置检查。 |
|
||||
| `trial_task_center/ui/main_window.py` | 保留 main 的问题项界面、资源弹窗处理与“清理完成且用户确认”强制释放协议;合入 DSH 互斥、取消和关闭等待、未知配置状态下错误反馈及受守卫的队列恢复。 |
|
||||
| `trial_task_center/ui/project_plan.py` | 保留 main 的部分 BOM 校验与显式选择通过工程;沿用异步取消、按任务保存草稿和预览归属,避免覆盖原计划。 |
|
||||
| `tests/dsh/test_incident_admission.py`(add/add) | 合并 main 6 项与本分支 4 项,10 个原测试全部保留,覆盖双方准入与拒绝路径。 |
|
||||
| `tests/ui/test_dsh_ai_nonblocking.py`(add/add) | 本分支 8 个函数/11 个场景留在原文件;main 9 个函数/11 个场景移入 `test_dsh_ai_nonblocking_main.py`。拆文件以保留两套测试身份和各自替身,合计 17 个函数/22 个场景。 |
|
||||
|
||||
## 验证
|
||||
|
||||
- 资源清理回归修复前:`test_nonblocking_controls.py` 为 1 passed、1 failed,失败为选择 Yes 后未进入强制释放;修复后与两份可用性测试合跑,24 passed(11.39 秒),包含真实本地 Harness 的全部 3 个组合场景。
|
||||
- 在进程内将真实运行时定位器替换为缺失目录、Node 定位器替换为缺失错误,不移动或删除已安装依赖。可用性单元测试、重试测试与 Harness 集成测试合跑为 24 passed、3 skipped(3.50 秒);仅 3 个真实集成场景跳过,全部提示安装 Node 与 `npm ci`。
|
||||
- 比较合并提交及两个父提交:9 个冲突文件均不同于任一父版本;AST 核验准入测试两边并集 10 个、UI 原测试身份 8+9 个全部保留。
|
||||
- 本轮最终定向验证为两组互不重叠的 47 passed 与 34 passed,共 81 项。第一组覆盖可用性单元/真实集成/受控重试、状态灯和资源清理;第二组覆盖非阻塞 UI 双方保留场景及诊断生命周期。实际事件测试对 `configuration_timeout` 追加 75 轮状态波动,仍只有同一事件的一次诊断和一次复盘。
|
||||
- 超时恢复、连续超时与临时检查状态先确认旧实现失败,再确认修复后通过;原生模型只读检查 23 场景、独立代码审查和 `git diff --check` 均通过。
|
||||
|
||||
以上测试计数有重叠,不累计。此前 CI run 265/266 已成功是评论 #352 的基线记录,不代表本轮修改已通过远端 CI。测试仅使用伪凭据与本地配置,不调用真实模型、CAD 或工单服务。
|
||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 1.0 MiB |
@@ -1,10 +1,10 @@
|
||||
# UTF-8
|
||||
VSVersionInfo(
|
||||
ffi=FixedFileInfo(
|
||||
filevers=(1, 2, 2, 0),
|
||||
prodvers=(1, 2, 2, 0),
|
||||
filevers=(1, 3, 0, 0),
|
||||
prodvers=(1, 3, 0, 0),
|
||||
mask=0x3f,
|
||||
flags=0x2,
|
||||
flags=0x0,
|
||||
OS=0x40004,
|
||||
fileType=0x1,
|
||||
subtype=0x0,
|
||||
@@ -15,11 +15,11 @@ VSVersionInfo(
|
||||
StringTable('040904B0', [
|
||||
StringStruct('CompanyName', 'DxProductivity'),
|
||||
StringStruct('FileDescription', 'DxDesigner Part Replacement'),
|
||||
StringStruct('FileVersion', '1.2.2.0'),
|
||||
StringStruct('FileVersion', '1.3.0.0'),
|
||||
StringStruct('InternalName', 'DxPartReplace'),
|
||||
StringStruct('OriginalFilename', 'DxPartReplace.exe'),
|
||||
StringStruct('ProductName', 'DxDesigner Part Replacement'),
|
||||
StringStruct('ProductVersion', '1.2.2')
|
||||
StringStruct('ProductVersion', '1.3.0')
|
||||
])
|
||||
]),
|
||||
VarFileInfo([VarStruct('Translation', [1033, 1200])])
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "dx-productivity"
|
||||
version = "1.2.2"
|
||||
version = "1.3.0"
|
||||
requires-python = ">=3.12,<3.13"
|
||||
dependencies = ["PySide6>=6.7,<7", "pywin32>=306", "pywinauto>=0.6.9,<1", "openpyxl>=3.1,<4"]
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ _MESSAGES = {
|
||||
'missing_credential': 'AI 模型缺少凭据;AI 功能已停用。',
|
||||
'invalid_configuration': 'AI 模型配置不可用;AI 功能已停用。',
|
||||
'runtime_unavailable': 'AI 运行时不可用;AI 功能已停用。',
|
||||
'configuration_timeout': '本地 AI 配置检查超时,等待后台复查;普通任务不受影响。',
|
||||
}
|
||||
_HOST_KEYS = ('DSH_API_BASE', 'DSH_MODEL', 'DSH_API_KEY')
|
||||
|
||||
@@ -54,9 +55,15 @@ def check_availability(data_root: Path) -> dict:
|
||||
'model_selection': {'provider': 'dx', 'model': env['DSH_MODEL']}}
|
||||
env.update(DSH_HOME=str(home), DX_DSH_HOME=str(home), DSH_TELEMETRY_DISABLED='1')
|
||||
try:
|
||||
completed = subprocess.run([node, str(root / 'model_availability.mjs'), str(home)],
|
||||
cwd=str(directory if directory.is_dir() else root), env=env, capture_output=True, text=True, encoding='utf8',
|
||||
errors='replace', timeout=3, creationflags=getattr(subprocess, 'CREATE_NO_WINDOW', 0))
|
||||
for attempt in range(2):
|
||||
try:
|
||||
completed = subprocess.run([node, str(root / 'model_availability.mjs'), str(home)],
|
||||
cwd=str(directory if directory.is_dir() else root), env=env, capture_output=True, text=True, encoding='utf8',
|
||||
errors='replace', timeout=3, creationflags=getattr(subprocess, 'CREATE_NO_WINDOW', 0))
|
||||
break
|
||||
except subprocess.TimeoutExpired:
|
||||
if attempt:
|
||||
return _result('configuration_timeout')
|
||||
value = json.loads(completed.stdout)
|
||||
code = value['code']
|
||||
if completed.returncode != 0 or code not in _MESSAGES or value['available'] is not (code == 'available'):
|
||||
|
||||
|
After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 1.0 MiB |
@@ -1,18 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256">
|
||||
<defs>
|
||||
<linearGradient id="tile" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop stop-color="#164D91"/>
|
||||
<stop offset="1" stop-color="#079D98"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect x="16" y="16" width="224" height="224" rx="52" fill="url(#tile)"/>
|
||||
<g fill="none" stroke="#FFFFFF" stroke-width="12" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M62 97V82Q62 60 84 60H184M169 46L184 60L169 74"/>
|
||||
<path d="M194 159V174Q194 196 172 196H72M87 182L72 196L87 210"/>
|
||||
</g>
|
||||
<g fill="none" stroke="#FFFFFF" stroke-width="9" stroke-linecap="round">
|
||||
<rect x="88" y="96" width="80" height="64" rx="10"/>
|
||||
<path d="M76 112H88M76 128H88M76 144H88M168 112H180M168 128H180M168 144H180"/>
|
||||
</g>
|
||||
<rect x="109" y="117" width="38" height="22" rx="5" fill="#9BF0DE"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 883 B |
@@ -70,7 +70,8 @@ class DshStatusController(QObject):
|
||||
|
||||
@property
|
||||
def can_continue(self):
|
||||
return self.available or (self.availability.get('code') == 'runtime_unavailable' and not self._runtime_error)
|
||||
return self.available or (self.availability.get('code') in {'runtime_unavailable', 'configuration_timeout'}
|
||||
and not self._runtime_error)
|
||||
|
||||
def refresh(self):
|
||||
if not self.window._closed and not self.query.busy:
|
||||
@@ -126,7 +127,7 @@ class DshStatusController(QObject):
|
||||
if not window.auto_intervention_check.isChecked():
|
||||
indicator.set_state('silent', '静默', 'AI 自动介入已关闭,不会接管新的异常。手动对话仍可使用。')
|
||||
elif not self.available and not active:
|
||||
checking = self.availability.get('code') == 'checking' and not self._runtime_error
|
||||
checking = self.availability.get('code') in {'checking', 'configuration_timeout'} and not self._runtime_error
|
||||
message = self._runtime_error or self.availability['message']
|
||||
indicator.set_state('checking' if checking else 'unavailable', '检查配置' if checking else '不可用',
|
||||
message + '\n普通任务不受影响;点击进入 DSH助手配置模型。')
|
||||
|
||||
@@ -1 +1 @@
|
||||
VERSION = "1.2.2"
|
||||
VERSION = "1.3.0"
|
||||
@@ -7,6 +7,22 @@ import pytest
|
||||
from dx_productivity.dsh import availability
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def runtime_root(tmp_path_factory):
|
||||
"""Keep fake runtime metadata outside each read-only configuration root."""
|
||||
root = tmp_path_factory.mktemp('availability-unit-runtime')
|
||||
package = root / 'node_modules/@deepseek-ai/dsh/package.json'
|
||||
package.parent.mkdir(parents=True)
|
||||
package.write_text('{}', encoding='utf8')
|
||||
return root
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def isolated_runtime(monkeypatch, runtime_root):
|
||||
monkeypatch.setattr(availability, 'integration_root', lambda: runtime_root)
|
||||
monkeypatch.setattr(availability, 'node_executable', lambda: 'fixture-node')
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def isolated_environment(monkeypatch):
|
||||
for key in ('DSH_API_BASE', 'DSH_MODEL', 'DSH_API_KEY', 'DX_DSH_MODELS', 'DEEPSEEK_API_KEY', 'FIXTURE_NATIVE_KEY'):
|
||||
@@ -69,6 +85,13 @@ def test_host_configuration_requires_node(tmp_path, monkeypatch):
|
||||
assert availability.check_availability(tmp_path)['code'] == 'runtime_unavailable'
|
||||
|
||||
|
||||
def test_host_configuration_requires_harness(tmp_path, monkeypatch):
|
||||
host_env(monkeypatch)
|
||||
monkeypatch.setattr(availability, 'integration_root', lambda: tmp_path / 'missing-runtime')
|
||||
assert availability.check_availability(tmp_path)['code'] == 'runtime_unavailable'
|
||||
assert list(tmp_path.iterdir()) == []
|
||||
|
||||
|
||||
def test_native_only_credential_store_is_checked_without_profile_patch(tmp_path, monkeypatch):
|
||||
credentials = tmp_path / 'dsh/harness-home/.credentials.yaml'
|
||||
credentials.parent.mkdir(parents=True)
|
||||
@@ -91,39 +114,6 @@ def test_dpapi_host_configuration_is_available_without_writes(tmp_path):
|
||||
assert {path.name: path.read_bytes() for path in directory.iterdir()} == before
|
||||
|
||||
|
||||
@pytest.mark.parametrize('explicit_default', [True, False])
|
||||
def test_real_native_route_survives_corrupt_unused_host_metadata(tmp_path, explicit_default):
|
||||
directory = tmp_path / 'dsh'
|
||||
patch = directory / 'harness-home/profiles/dx-task/cordis.patch.yml'
|
||||
patch.parent.mkdir(parents=True)
|
||||
(directory / 'provider.json').write_text('{invalid-unused-host', encoding='utf8')
|
||||
rows = [
|
||||
{'id': 'llm-pi-ai', 'config': {'providers': {'native': {'api': 'openai-completions',
|
||||
'baseURL': 'https://example.invalid/v1', 'apiKeyEnv': 'FIXTURE_NATIVE_KEY',
|
||||
'models': [{'id': 'fixture-model'}]}}}},
|
||||
{'id': 'agent-default-model', 'config': {'provider': 'native', 'model': 'fixture-model'}}]
|
||||
patch.write_text(json.dumps(rows if explicit_default else rows[:1]), encoding='utf8')
|
||||
credentials = directory / 'harness-home/.credentials.yaml'
|
||||
credentials.write_text(json.dumps({'version': 1, 'refs': {'FIXTURE_NATIVE_KEY': 'fake-native-key'}}), encoding='utf8')
|
||||
before = {path: path.read_bytes() for path in directory.rglob('*') if path.is_file()}
|
||||
result = availability.check_availability(tmp_path)
|
||||
assert result['available'] is True, result
|
||||
assert result['source'] == 'native'
|
||||
assert result['environment_refs'] == []
|
||||
assert result['model_selection'] == {'provider': 'native', 'model': 'fixture-model'}
|
||||
assert 'fake-native-key' not in json.dumps(result)
|
||||
assert {path: path.read_bytes() for path in directory.rglob('*') if path.is_file()} == before
|
||||
|
||||
|
||||
def test_ambient_official_native_key_works_before_dsh_directory_exists(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv('DEEPSEEK_API_KEY', 'fake-official-native-key')
|
||||
result = availability.check_availability(tmp_path)
|
||||
assert result['available'] is True, result
|
||||
assert result['source'] == 'native'
|
||||
assert result['environment_refs'] == ['DEEPSEEK_API_KEY']
|
||||
assert not (tmp_path / 'dsh').exists()
|
||||
|
||||
|
||||
def test_native_extra_child_fields_are_discarded(tmp_path, monkeypatch):
|
||||
credentials = tmp_path / 'dsh/harness-home/.credentials.yaml'
|
||||
credentials.parent.mkdir(parents=True)
|
||||
@@ -178,8 +168,13 @@ def test_native_timeout_is_safe_and_bounded(tmp_path, monkeypatch):
|
||||
patch = tmp_path / 'dsh/harness-home/profiles/dx-task/cordis.patch.yml'
|
||||
patch.parent.mkdir(parents=True)
|
||||
patch.write_text('[]', encoding='utf8')
|
||||
calls = []
|
||||
def timeout(*args, **kwargs):
|
||||
assert kwargs['timeout'] <= 10
|
||||
raise availability.subprocess.TimeoutExpired('fake-secret', 8)
|
||||
calls.append(args)
|
||||
assert kwargs['timeout'] == 3
|
||||
raise availability.subprocess.TimeoutExpired('fake-secret', 3)
|
||||
monkeypatch.setattr(availability.subprocess, 'run', timeout)
|
||||
assert availability.check_availability(tmp_path)['code'] == 'runtime_unavailable'
|
||||
result = availability.check_availability(tmp_path)
|
||||
assert result['code'] == 'configuration_timeout'
|
||||
assert len(calls) == 2
|
||||
assert 'fake-secret' not in json.dumps(result)
|
||||
@@ -0,0 +1,56 @@
|
||||
"""Offline composition checks using the installed official Node/Harness runtime."""
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from dx_productivity.dsh import availability, native_runtime
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def installed_harness(monkeypatch):
|
||||
for key in ('DSH_API_BASE', 'DSH_MODEL', 'DSH_API_KEY', 'DX_DSH_MODELS',
|
||||
'DEEPSEEK_API_KEY', 'FIXTURE_NATIVE_KEY'):
|
||||
monkeypatch.delenv(key, raising=False)
|
||||
root = native_runtime.integration_root()
|
||||
install = 'Install Node.js 24.9+ and run npm ci --prefix integration/dsh to run offline Harness integration tests.'
|
||||
if not (root / 'node_modules/@deepseek-ai/dsh/package.json').is_file():
|
||||
pytest.skip(install)
|
||||
try:
|
||||
node = native_runtime.node_executable()
|
||||
except RuntimeError:
|
||||
pytest.skip(install)
|
||||
monkeypatch.setattr(availability, 'integration_root', lambda: root)
|
||||
monkeypatch.setattr(availability, 'node_executable', lambda: node)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('explicit_default', [True, False])
|
||||
def test_real_native_route_survives_corrupt_unused_host_metadata(tmp_path, explicit_default):
|
||||
directory = tmp_path / 'dsh'
|
||||
patch = directory / 'harness-home/profiles/dx-task/cordis.patch.yml'
|
||||
patch.parent.mkdir(parents=True)
|
||||
(directory / 'provider.json').write_text('{invalid-unused-host', encoding='utf8')
|
||||
rows = [
|
||||
{'id': 'llm-pi-ai', 'config': {'providers': {'native': {'api': 'openai-completions',
|
||||
'baseURL': 'https://example.invalid/v1', 'apiKeyEnv': 'FIXTURE_NATIVE_KEY',
|
||||
'models': [{'id': 'fixture-model'}]}}}},
|
||||
{'id': 'agent-default-model', 'config': {'provider': 'native', 'model': 'fixture-model'}}]
|
||||
patch.write_text(json.dumps(rows if explicit_default else rows[:1]), encoding='utf8')
|
||||
credentials = directory / 'harness-home/.credentials.yaml'
|
||||
credentials.write_text(json.dumps({'version': 1, 'refs': {'FIXTURE_NATIVE_KEY': 'fake-native-key'}}), encoding='utf8')
|
||||
before = {path: path.read_bytes() for path in directory.rglob('*') if path.is_file()}
|
||||
result = availability.check_availability(tmp_path)
|
||||
assert result['available'] is True, result
|
||||
assert result['source'] == 'native'
|
||||
assert result['environment_refs'] == []
|
||||
assert result['model_selection'] == {'provider': 'native', 'model': 'fixture-model'}
|
||||
assert 'fake-native-key' not in json.dumps(result)
|
||||
assert {path: path.read_bytes() for path in directory.rglob('*') if path.is_file()} == before
|
||||
|
||||
|
||||
def test_ambient_official_native_key_works_before_dsh_directory_exists(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv('DEEPSEEK_API_KEY', 'fake-official-native-key')
|
||||
result = availability.check_availability(tmp_path)
|
||||
assert result['available'] is True, result
|
||||
assert result['source'] == 'native'
|
||||
assert result['environment_refs'] == ['DEEPSEEK_API_KEY']
|
||||
assert not (tmp_path / 'dsh').exists()
|
||||
@@ -0,0 +1,81 @@
|
||||
import json
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from dx_productivity.dsh import availability
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def local_probe(tmp_path, monkeypatch):
|
||||
for key in (*availability._HOST_KEYS, 'DEEPSEEK_API_KEY'):
|
||||
monkeypatch.delenv(key, raising=False)
|
||||
root = tmp_path / 'runtime'
|
||||
package = root / 'node_modules/@deepseek-ai/dsh/package.json'
|
||||
package.parent.mkdir(parents=True)
|
||||
package.write_text('{}', encoding='utf8')
|
||||
data = tmp_path / 'data'
|
||||
credentials = data / 'dsh/harness-home/.credentials.yaml'
|
||||
credentials.parent.mkdir(parents=True)
|
||||
credentials.write_text('{}', encoding='utf8')
|
||||
monkeypatch.setattr(availability, 'integration_root', lambda: root)
|
||||
monkeypatch.setattr(availability, 'node_executable', lambda: 'controlled-node')
|
||||
return data
|
||||
|
||||
|
||||
def reply(code='available'):
|
||||
return SimpleNamespace(returncode=0, stderr='', stdout=json.dumps({
|
||||
'available': code == 'available', 'code': code,
|
||||
'source': 'native', 'environment_refs': [],
|
||||
'model_selection': {'provider': 'configured', 'model': 'fixture'}}))
|
||||
|
||||
|
||||
def test_one_cold_probe_timeout_recovers_without_disabling_ai(local_probe, monkeypatch):
|
||||
calls = []
|
||||
def probe(*args, **kwargs):
|
||||
calls.append(kwargs['timeout'])
|
||||
if len(calls) == 1:
|
||||
raise availability.subprocess.TimeoutExpired('fake-private-command', 3)
|
||||
return reply()
|
||||
monkeypatch.setattr(availability.subprocess, 'run', probe)
|
||||
result = availability.check_availability(local_probe)
|
||||
assert result['available']
|
||||
assert result['model_selection'] == {'provider': 'configured', 'model': 'fixture'}
|
||||
assert calls == [3, 3]
|
||||
assert 'fake-private' not in json.dumps(result)
|
||||
|
||||
|
||||
def test_repeated_timeout_is_bounded_and_distinct_from_missing_model(local_probe, monkeypatch):
|
||||
calls = []
|
||||
def probe(*args, **kwargs):
|
||||
calls.append(kwargs['timeout'])
|
||||
raise availability.subprocess.TimeoutExpired('fake-secret', 3)
|
||||
monkeypatch.setattr(availability.subprocess, 'run', probe)
|
||||
result = availability.check_availability(local_probe)
|
||||
assert result['code'] == 'configuration_timeout'
|
||||
assert not result['available']
|
||||
assert calls == [3, 3]
|
||||
assert 'fake-secret' not in json.dumps(result)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('code', ['missing_credential', 'invalid_configuration'])
|
||||
def test_confirmed_configuration_error_is_not_retried(local_probe, monkeypatch, code):
|
||||
calls = []
|
||||
def probe(*args, **kwargs):
|
||||
calls.append(True)
|
||||
return reply(code)
|
||||
monkeypatch.setattr(availability.subprocess, 'run', probe)
|
||||
assert availability.check_availability(local_probe)['code'] == code
|
||||
assert calls == [True]
|
||||
|
||||
|
||||
def test_invalid_child_output_is_not_retried_or_exposed(local_probe, monkeypatch):
|
||||
calls = []
|
||||
def probe(*args, **kwargs):
|
||||
calls.append(True)
|
||||
return SimpleNamespace(returncode=0, stdout='fake-secret-not-json', stderr='')
|
||||
monkeypatch.setattr(availability.subprocess, 'run', probe)
|
||||
result = availability.check_availability(local_probe)
|
||||
assert result['code'] == 'runtime_unavailable'
|
||||
assert calls == [True]
|
||||
assert 'fake-secret' not in json.dumps(result)
|
||||
@@ -100,6 +100,15 @@ def test_pending_intervention_tooltip_uses_new_request_instead_of_old_incident(n
|
||||
assert '旧任务错误' not in window.ai_status_indicator.toolTip()
|
||||
|
||||
|
||||
def test_local_probe_timeout_means_checking_instead_of_bad_configuration(no_model, ui):
|
||||
window = ui.window
|
||||
window._dsh_status._received({'available': False, 'code': 'configuration_timeout', 'message': '本地配置检查超时'})
|
||||
assert window.ai_status_indicator.property('state') == 'checking'
|
||||
assert '超时' in window.ai_status_indicator.toolTip()
|
||||
assert not window._dsh_status.available
|
||||
assert window._dsh_status.can_continue
|
||||
|
||||
|
||||
def test_running_harness_without_new_environment_ref_does_not_claim_ready(no_model, ui, monkeypatch):
|
||||
from .test_dsh_native_menu import HarnessView
|
||||
window = ui.window
|
||||
@@ -136,7 +145,8 @@ def test_availability_polling_never_reopens_completed_blocker(no_model, ui, monk
|
||||
assert submitted[0]['run_id'] != submitted[1]['run_id']
|
||||
|
||||
|
||||
def test_local_readiness_probe_does_not_cancel_or_revoke_running_diagnosis(no_model, ui, monkeypatch):
|
||||
@pytest.mark.parametrize('probe_code', ['runtime_unavailable', 'configuration_timeout'])
|
||||
def test_local_readiness_probe_does_not_cancel_or_revoke_running_diagnosis(no_model, ui, monkeypatch, probe_code):
|
||||
from dx_productivity.trial_task_center.ui.dsh_automation import DshAutomation
|
||||
window = ui.window
|
||||
window._dsh_status.timer.stop()
|
||||
@@ -150,7 +160,7 @@ def test_local_readiness_probe_does_not_cancel_or_revoke_running_diagnosis(no_mo
|
||||
permission = automation.execution_enabled
|
||||
try:
|
||||
for _ in range(10):
|
||||
window._dsh_status._received({'available': False, 'code': 'runtime_unavailable', 'message': 'Local probe timeout'})
|
||||
window._dsh_status._received({'available': False, 'code': probe_code, 'message': 'Local probe timeout'})
|
||||
window._dsh_status._received(ready)
|
||||
assert not automation.cancel_event.is_set()
|
||||
assert permission.is_set() and automation.execution_enabled is permission
|
||||
@@ -159,7 +169,8 @@ def test_local_readiness_probe_does_not_cancel_or_revoke_running_diagnosis(no_mo
|
||||
automation._current_identity = None
|
||||
|
||||
|
||||
def test_actual_incident_sends_one_diagnosis_and_one_reflection_despite_readiness_flaps(no_model, ui, monkeypatch, qtbot):
|
||||
@pytest.mark.parametrize('probe_code', ['runtime_unavailable', 'configuration_timeout'])
|
||||
def test_actual_incident_sends_one_diagnosis_and_one_reflection_despite_readiness_flaps(no_model, ui, monkeypatch, qtbot, probe_code):
|
||||
from PySide6.QtCore import Signal
|
||||
from .test_dsh_native_menu import HarnessView
|
||||
from dx_productivity.trial_task_center.ui import dsh_automation
|
||||
@@ -199,15 +210,15 @@ def test_actual_incident_sends_one_diagnosis_and_one_reflection_despite_readines
|
||||
assert request['phase'] == phase
|
||||
view.diagnosis_event.emit({'status': 'started', 'request_id': request['request_id'], 'session_id': 'controlled-session'})
|
||||
for _ in range(25):
|
||||
window._dsh_status._received({'available': False, 'code': 'runtime_unavailable', 'message': 'Controlled local probe timeout'})
|
||||
window._dsh_status._received({'available': False, 'code': probe_code, 'message': 'Controlled local probe timeout'})
|
||||
window._dsh_status._received(ready)
|
||||
# Keep the uncertain local check through the next phase boundary.
|
||||
window._dsh_status._received({'available': False, 'code': 'runtime_unavailable', 'message': 'Controlled local probe timeout'})
|
||||
window._dsh_status._received({'available': False, 'code': probe_code, 'message': 'Controlled local probe timeout'})
|
||||
view.diagnosis_event.emit({'status': 'completed', 'request_id': request['request_id'],
|
||||
'session_id': 'controlled-session', 'reply': '{"action":"none","summary":"Controlled BOM validation failure"}'})
|
||||
qtbot.waitUntil(lambda: window._dsh_automation.worker is None, timeout=5000)
|
||||
for _ in range(25):
|
||||
window._dsh_status._received({'available': False, 'code': 'runtime_unavailable', 'message': 'Controlled local probe timeout'})
|
||||
window._dsh_status._received({'available': False, 'code': probe_code, 'message': 'Controlled local probe timeout'})
|
||||
window._dsh_status._received(ready)
|
||||
qtbot.wait(20)
|
||||
assert [request['phase'] for request in view.requests] == ['diagnose', 'reflect']
|
||||
|
||||
@@ -27,7 +27,11 @@ def test_retained_resource_force_requires_explicit_operator_choice(ui, monkeypat
|
||||
monkeypatch.setattr(window.service, 'cleanup_batch_resources', lambda: ({'state': 'blocked'},))
|
||||
monkeypatch.setattr(window.service, 'force_pending_owned_resources',
|
||||
lambda *, confirmed=False: forced.append(confirmed) or ())
|
||||
monkeypatch.setattr(window, '_run_async', lambda action, done, *_a, **_k: done(action()))
|
||||
def run_async(action, done, *_a, on_finished=None, **_k):
|
||||
done(action())
|
||||
if on_finished is not None:
|
||||
on_finished()
|
||||
monkeypatch.setattr(window, '_run_async', run_async)
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *_a, **_k: QMessageBox.StandardButton.No)
|
||||
window.run_panel.cleanup_resources_button.setEnabled(True)
|
||||
window._cleanup_batch_resources()
|
||||
|
||||
@@ -1,33 +1,19 @@
|
||||
"""Render the editable SVG into the runtime PNG and Windows multi-size ICO."""
|
||||
from io import BytesIO
|
||||
"""Export the approved PNG master into application and documentation icons."""
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image
|
||||
from PySide6.QtCore import QBuffer, QIODevice, Qt
|
||||
from PySide6.QtGui import QImage, QPainter
|
||||
from PySide6.QtSvg import QSvgRenderer
|
||||
|
||||
|
||||
def main():
|
||||
assets = Path(__file__).resolve().parents[1] / 'src/dx_productivity/trial_task_center/assets'
|
||||
renderer = QSvgRenderer(str(assets / 'app.svg'))
|
||||
if not renderer.isValid():
|
||||
raise ValueError('Invalid application icon SVG')
|
||||
canvas = QImage(512, 512, QImage.Format.Format_ARGB32)
|
||||
canvas.fill(Qt.GlobalColor.transparent)
|
||||
painter = QPainter(canvas)
|
||||
try:
|
||||
renderer.render(painter)
|
||||
finally:
|
||||
painter.end()
|
||||
buffer = QBuffer()
|
||||
buffer.open(QIODevice.OpenModeFlag.WriteOnly)
|
||||
if not canvas.save(buffer, 'PNG'):
|
||||
raise OSError('Cannot render application icon')
|
||||
payload = bytes(buffer.data())
|
||||
(assets / 'app.png').write_bytes(payload)
|
||||
with Image.open(BytesIO(payload)) as image:
|
||||
image.save(assets / 'app.ico', sizes=[(n, n) for n in (16, 20, 24, 32, 40, 48, 64, 96, 128, 256)])
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
assets = root / 'src/dx_productivity/trial_task_center/assets'
|
||||
with Image.open(assets / 'app-master.png') as source:
|
||||
image = source.convert('RGBA')
|
||||
if image.size != (1024, 1024):
|
||||
raise ValueError('Application icon master must be 1024x1024')
|
||||
image.save(assets / 'app.png')
|
||||
image.save(assets / 'app.ico', sizes=[(n, n) for n in (16, 20, 24, 32, 40, 48, 64, 96, 128, 256)])
|
||||
image.save(root / 'docs/user/media/app-icon.png')
|
||||
print(assets / 'app.ico')
|
||||
|
||||
|
||||
|
||||