chore: 新增调试入口脚本

This commit is contained in:
XcantloadX 2025-03-28 13:13:31 +08:00
parent ea7ddcc5b5
commit 1805ff719d
3 changed files with 41 additions and 0 deletions

View File

@ -15,6 +15,12 @@
3. 打开 VSCode 设置,搜索 `imageComments.pathMode` 并设置为 `relativeToWorkspace`
4. 编译资源:在 VSCode 中选择“Terminal” -> “Run Task” -> “Make R.py”并执行。
## 运行单个任务
如果使用 VSCode只需要在运行配置里选择 `Python: Current Module` 即可。
如果使用 PyCharm按照下图新建一个 Run Configuration
![pycharm_run_config.png](images/pycharm_run_config.png)
## 打包 & 安装
```bash

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

35
kotonebot/debug_entry.py Normal file
View File

@ -0,0 +1,35 @@
import runpy
import logging
import argparse
from kotonebot.tasks.common import BaseConfig
def run_script(script_path: str) -> None:
"""
使用 runpy 运行指定的 Python 脚本
Args:
script_path: Python 脚本的路径
"""
# 获取模块名
module_name = script_path.strip('.py').replace('\\', '/').strip('/').replace('/', '.')
print(f"正在运行脚本: {script_path}")
# 运行脚本
from kotonebot.backend.context import init_context
logging.basicConfig(level=logging.INFO, format='[%(asctime)s] [%(levelname)s] [%(name)s] [%(funcName)s] [%(lineno)d] %(message)s')
logging.getLogger('kotonebot').setLevel(logging.DEBUG)
init_context(config_type=BaseConfig)
runpy.run_module(module_name, run_name="__main__")
def main():
parser = argparse.ArgumentParser(description='运行指定的 Python 脚本')
parser.add_argument('script_path', help='要运行的 Python 脚本路径')
args = parser.parse_args()
run_script(args.script_path)
if __name__ == '__main__':
main()