From 301fe3b42caa8da4ce27d7cbe256d85f4da38ea7 Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Tue, 2 Dec 2025 11:25:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20HP=20=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E6=9C=BA=E6=8F=92=E4=BB=B6=E9=9D=9E=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E5=BC=8F=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 自动识别 hplip-plugin.run 文件 - 优先使用 hp-plugin 命令安装 - 备用方案使用 yes 管道自动确认 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- cups-driver-manager/driver_manager.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cups-driver-manager/driver_manager.py b/cups-driver-manager/driver_manager.py index 44d99c3..a81dcde 100644 --- a/cups-driver-manager/driver_manager.py +++ b/cups-driver-manager/driver_manager.py @@ -331,10 +331,25 @@ def install_rpm(filepath): def install_script(filepath): """执行安装脚本""" results = [] + filename = os.path.basename(filepath).lower() os.chmod(filepath, 0o755) - result = run_command(filepath, shell=True) - results.append(('执行安装脚本', result)) + + # HP 插件需要特殊处理(非交互式安装) + if 'hplip' in filename and 'plugin' in filename: + # 方法1:尝试使用 hp-plugin 命令安装 + hp_plugin_check = run_command(['which', 'hp-plugin']) + if hp_plugin_check['success']: + result = run_command(f'hp-plugin -i -p {filepath}', shell=True) + results.append(('使用 hp-plugin 安装 HP 插件', result)) + else: + # 方法2:使用 yes 命令自动确认交互式提示 + result = run_command(f'yes | {filepath}', shell=True) + results.append(('执行 HP 插件安装脚本', result)) + else: + # 普通脚本直接执行 + result = run_command(filepath, shell=True) + results.append(('执行安装脚本', result)) return results