fix: open HTML report in Windows browser when running in WSL#1148
Open
xuli500177 wants to merge 1 commit into
Open
fix: open HTML report in Windows browser when running in WSL#1148xuli500177 wants to merge 1 commit into
xuli500177 wants to merge 1 commit into
Conversation
WSL users currently see a broken popup when TrendRadar tries to open the HTML report, because Python's webbrowser.open() launches a Linux browser that has no display. This fix detects the WSL environment and uses PowerShell's Start-Process to open the report in the user's Windows default browser instead. Changes: - Add _is_wsl() to detect WSL via /proc/version - Add _open_in_windows_browser() using wslpath + powershell.exe - Non-WSL environments are unaffected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
WSL 环境下运行 TrendRadar 时,自动打开 HTML 报告会弹出错误弹窗。原因是 Python 的
webbrowser.open()启动了 WSL 内的 Linux 浏览器,但 WSL 没有图形显示环境,导致打开失败。方案
检测 WSL 环境,改用
powershell.exe的Start-Process在 Windows 默认浏览器中打开报告。改动
_is_wsl():通过读取/proc/version检测 WSL 环境_open_in_windows_browser():用wslpath转换路径 +powershell.exe打开测试