feat: 支持 HP 打印机插件非交互式安装

- 自动识别 hplip-plugin.run 文件
- 优先使用 hp-plugin 命令安装
- 备用方案使用 yes 管道自动确认

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-02 11:25:38 +08:00
parent f41b44238f
commit 301fe3b42c

View File

@@ -331,8 +331,23 @@ def install_rpm(filepath):
def install_script(filepath): def install_script(filepath):
"""执行安装脚本""" """执行安装脚本"""
results = [] results = []
filename = os.path.basename(filepath).lower()
os.chmod(filepath, 0o755) os.chmod(filepath, 0o755)
# 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) result = run_command(filepath, shell=True)
results.append(('执行安装脚本', result)) results.append(('执行安装脚本', result))