Mzdyl / LiteLoaderQQNT_Install

针对 LiteLoaderQQNT 的安装脚本
BSD 3-Clause "New" or "Revised" License
1.41k stars 53 forks source link

1.18 Again #156

Closed Mzdyl closed 3 weeks ago

Mzdyl commented 3 weeks ago

Sourcery 提供的摘要

将当前版本更新至 1.18.1,并通过重构的连接检查、简化的插件安装逻辑、改进的代理支持下载处理以及更好的 PyInstaller 和 Nuitka 兼容性来增强安装脚本。

增强功能:

Original summary in English ## Sourcery的总结 将当前版本更新至1.18.1,并通过重构连接检查、简化插件安装逻辑、改进代理支持的下载处理以及提高与PyInstaller和Nuitka的兼容性来增强安装脚本。 增强功能: - 重构连接检查功能,使其更通用,允许对任何URL进行连接性检查,并可自定义超时时间。 - 通过合并条件和删除冗余代码路径来简化插件安装逻辑。 - 改进下载逻辑,更稳健地处理代理使用,如果在需要时没有可用代理,则抛出错误。 - 通过调整确定外部数据路径的方法来增强与PyInstaller和Nuitka的兼容性。
Original summary in English ## Summary by Sourcery Update the current version to 1.18.1 and enhance the installation script with refactored connection checks, simplified plugin installation logic, improved proxy-supported download handling, and better compatibility with PyInstaller and Nuitka. Enhancements: - Refactor connection check function to be more generic, allowing connectivity checks to any URL with customizable timeout. - Simplify plugin installation logic by merging conditions and removing redundant code paths. - Improve download logic to handle proxy usage more robustly, raising an error if no proxy is available when needed. - Enhance compatibility with PyInstaller and Nuitka by adjusting the method for determining external data paths.
sweep-ai[bot] commented 3 weeks ago

Hey @Mzdyl, here is an example of how you can ask me to improve this pull request:

@sweep Add unit tests for the new `can_connect(url, timeout)` function to verify:
- It returns True for valid URLs with 200-399 status codes
- It returns False for URLs with status codes outside 200-399 range
- It handles timeouts correctly
- It handles invalid URLs/connection failures

:book: For more information on how to use Sweep, please read our documentation.

sourcery-ai[bot] commented 3 weeks ago

审核指南由 Sourcery 提供

此 PR 将版本更新至 1.18.1,并对安装脚本进行了多项改进。更改的重点是增强连接处理、简化插件安装、通过代理支持提高下载可靠性,并增加与 PyInstaller 和 Nuitka 打包的更好兼容性。

带有代理支持的下载过程序列图

sequenceDiagram
    participant User
    participant Script
    participant Proxy
    participant URL

    User->>Script: 发起下载
    Script->>URL: 检查连接
    alt URL 可达
        Script->>URL: 下载文件
    else URL 不可达
        Script->>Proxy: 获取可用代理
        alt 代理可用
            Script->>Proxy: 使用代理下载
            Proxy->>URL: 下载文件
        else 无可用代理
            Script->>User: 抛出错误 "无可用代理"
        end
    end

更新后的连接和下载功能类图

classDiagram
    class ConnectionHandler {
        +can_connect(url: str, timeout: int) bool
    }
    class DownloadManager {
        +get_download_url(url: str) str
        +download_file(url_or_path: str, filepath: str, timeout: int)
    }
    class ProxyManager {
        +get_working_proxy() str
    }
    ConnectionHandler <|-- DownloadManager
    ProxyManager <|-- DownloadManager
    note for ConnectionHandler "重构以处理任何 URL 并支持自定义超时"
    note for DownloadManager "改进的下载逻辑,支持代理"
    note for ProxyManager "处理代理检索"

文件级更改

更改 详情 文件
重构连接检查功能以更灵活
  • 将函数名称从 can_connect_to_github 重命名为 can_connect
  • 添加可自定义的超时参数
  • 修改状态码检查以接受任何成功的 HTTP 响应 (200-399)
install_windows.py
简化插件商店安装逻辑
  • 将安装条件合并为单一检查
  • 移除冗余代码路径
  • 为损坏的安装添加更好的错误检测
install_windows.py
通过改进的代理支持增强下载处理
  • 添加新的 get_download_url 函数以处理 URL 解析
  • 改进代理不可用时的错误处理
  • 重构 download_file 函数以减少代码重复
install_windows.py
改善与 Python 打包工具的兼容性
  • 添加对 Nuitka 打包的支持
  • 增强 PyInstaller 路径解析
  • 改进外部数据路径检测逻辑
install_windows.py

提示和命令 #### 与 Sourcery 互动 - **触发新审核:** 在拉取请求上评论 `@sourcery-ai review`。 - **继续讨论:** 直接回复 Sourcery 的审核评论。 - **从审核评论生成 GitHub 问题:** 通过回复审核评论请求 Sourcery 创建问题。 - **生成拉取请求标题:** 在拉取请求标题的任何地方写 `@sourcery-ai` 以随时生成标题。 - **生成拉取请求摘要:** 在拉取请求正文的任何地方写 `@sourcery-ai summary` 以随时生成 PR 摘要。您也可以使用此命令指定摘要应插入的位置。 #### 自定义您的体验 访问您的[仪表板](https://app.sourcery.ai)以: - 启用或禁用审核功能,如 Sourcery 生成的拉取请求摘要、审核指南等。 - 更改审核语言。 - 添加、删除或编辑自定义审核说明。 - 调整其他审核设置。 #### 获取帮助 - [联系我们的支持团队](mailto:support@sourcery.ai)以获取问题或反馈。 - 访问我们的[文档](https://docs.sourcery.ai)以获取详细指南和信息。 - 通过关注我们在 [X/Twitter](https://x.com/SourceryAI)、[LinkedIn](https://www.linkedin.com/company/sourcery-ai/) 或 [GitHub](https://github.com/sourcery-ai) 上的 Sourcery 团队保持联系。
Original review guide in English ## Reviewer's Guide by Sourcery This PR updates the version to 1.18.1 and introduces several improvements to the installation script. The changes focus on enhancing connection handling, simplifying plugin installation, improving download reliability with proxy support, and adding better compatibility with PyInstaller and Nuitka packaging. #### Sequence diagram for download process with proxy support ```mermaid sequenceDiagram participant User participant Script participant Proxy participant URL User->>Script: Initiate download Script->>URL: Check connectivity alt URL is reachable Script->>URL: Download file else URL is not reachable Script->>Proxy: Get working proxy alt Proxy is available Script->>Proxy: Use proxy to download Proxy->>URL: Download file else No proxy available Script->>User: Raise error "No available proxy" end end ``` #### Updated class diagram for connection and download functions ```mermaid classDiagram class ConnectionHandler { +can_connect(url: str, timeout: int) bool } class DownloadManager { +get_download_url(url: str) str +download_file(url_or_path: str, filepath: str, timeout: int) } class ProxyManager { +get_working_proxy() str } ConnectionHandler <|-- DownloadManager ProxyManager <|-- DownloadManager note for ConnectionHandler "Refactored to handle any URL with customizable timeout" note for DownloadManager "Improved download logic with proxy support" note for ProxyManager "Handles proxy retrieval" ``` ### File-Level Changes | Change | Details | Files | | ------ | ------- | ----- | | Refactored connection checking functionality to be more flexible |
  • Renamed function from can_connect_to_github to can_connect
  • Added customizable timeout parameter
  • Modified status code check to accept any successful HTTP response (200-399)
| `install_windows.py` | | Simplified plugin store installation logic |
  • Consolidated installation conditions into a single check
  • Removed redundant code paths
  • Added better error detection for corrupted installations
| `install_windows.py` | | Enhanced download handling with improved proxy support |
  • Added new get_download_url function to handle URL resolution
  • Improved error handling for proxy unavailability
  • Restructured download_file function to reduce code duplication
| `install_windows.py` | | Improved compatibility with Python packagers |
  • Added support for Nuitka packaging
  • Enhanced PyInstaller path resolution
  • Improved external data path detection logic
| `install_windows.py` | ---
Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
Mzdyl commented 3 weeks ago

@sourcery-ai review