Skip to content

feat(core): 添加 NSP 处理相关功能#8

Merged
qingchenyouforcc merged 5 commits into
mainfrom
master
Jul 19, 2025
Merged

feat(core): 添加 NSP 处理相关功能#8
qingchenyouforcc merged 5 commits into
mainfrom
master

Conversation

@qingchenyouforcc
Copy link
Copy Markdown
Owner

feat(core): 添加 NSP 处理相关功能

  • 新增 NSP_handle 模块,实现对 NSP 文件和进程的管理- 添加配置项以保存 NSP 文件路径
  • 实现启动 NSP 进程、检查进程状态等功能
  • 添加获取 NSP版本信息、文件夹占用情况等辅助功能
  • 优化错误处理和日志记录

Copilot

This pull request introduces significant updates to the NSP_handle.py script to improve process handling, especially for Windows systems, and includes minor adjustments to other files. The main changes involve adding support for win32api to handle process creation on Windows, enhancing cross-platform compatibility, and refining version retrieval logic.

Process Handling Updates:

  • Introduced win32api, win32con, and win32process modules for advanced process management on Windows systems, including creating fully detached processes using win32process.CreateProcess. A fallback mechanism is provided for systems without pywin32 installed. (src/core/NSP_handle.py, [1] [2]
  • Enhanced non-Windows process handling by using nohup for detached execution, ensuring compatibility with Unix-based systems. (src/core/NSP_handle.py, src/core/NSP_handle.pyL52-R116)

Version Retrieval Logic:

  • Simplified the logic for extracting version information from the GetFileVersionInfo API by using bitwise operations instead of helper methods like HIWORD and LOWORD. (src/core/NSP_handle.py, src/core/NSP_handle.pyL268-R323)

Usability Enhancements:

  • Added user-friendly messages to indicate when the NSP program has successfully started and is running in the background, allowing the user to safely close the script. (src/core/NSP_handle.py, src/core/NSP_handle.pyR476-R482)

Code Cleanup:

  • Removed redundant comments and streamlined sections related to version checks, folder usage, and memory usage in the test cases. (src/core/NSP_handle.py, [1] [2] [3] [4]

Minor Adjustments:

  • Updated .vscode/settings.json to include "nohup" in the recognized keywords. (.vscode/settings.json, .vscode/settings.jsonR22)

- 在 Windows 系统下使用 win32api.ShellExecute 启动 NSP 程序- 在非 Windows 系统下使用 nohup 命令启动 NSP 程序- 确保 NSP程序在完全独立的进程中运行,不继承控制台
- 添加启动成功后的提示信息
- 优化代码结构,提高可读性和可维护性
…平台兼容性

- 修复了 Linux 版本的 NSP启动方式,增加了进程信息日志输出
- 将字符串格式化方法从传统的 % 格式化改为更现代的 f-string 格式化
- 提高了代码的可读性和维护性
@qingchenyouforcc qingchenyouforcc requested a review from Copilot July 19, 2025 03:06
@qingchenyouforcc qingchenyouforcc added the feat new function label Jul 19, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces comprehensive NSP (NeuroSongSpider) process management functionality with enhanced cross-platform support. The main focus is on improving Windows process creation using win32api while maintaining compatibility with Unix systems.

Key Changes:

  • Enhanced Windows process management using win32api with fallback mechanisms
  • Added cross-platform process launching with nohup support for Unix systems
  • Simplified version information extraction using bitwise operations
  • Improved user experience with status messages and background operation notifications

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/core/NSP_handle.py Major refactoring of process management with win32api integration, improved version extraction logic, and enhanced user feedback
.vscode/settings.json Added "nohup" to VS Code spell checker dictionary

Comment thread src/core/NSP_handle.py Outdated
Comment thread src/core/NSP_handle.py Outdated
Comment thread src/core/NSP_handle.py
Comment thread src/core/NSP_handle.py Outdated
qingchenyouforcc and others added 2 commits July 19, 2025 11:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@qingchenyouforcc qingchenyouforcc merged commit e750c43 into main Jul 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants