fix: 错误输出
This commit is contained in:
parent
efdfb7ad87
commit
ab9895e9ca
@ -5,10 +5,14 @@ from __future__ import annotations
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
|
||||
sys.stderr = sys.stdout
|
||||
|
||||
|
||||
FETCH_API_URL = "https://api.pearktrue.cn/api/today_wife"
|
||||
FALLBACK_TEXT = "今天的美女图片暂时没拿到,等我再找找。"
|
||||
|
||||
@ -75,4 +79,10 @@ def main() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
raise SystemExit(main())
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception:
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
raise SystemExit(1)
|
||||
@ -4,10 +4,14 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
import traceback
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
|
||||
sys.stderr = sys.stdout
|
||||
|
||||
|
||||
API_URL = "https://api.pearktrue.cn/api/kfc?type=json"
|
||||
FALLBACK_TEXT = "今天的肯德基文案暂时没拿到,等我再去问问。"
|
||||
|
||||
@ -33,4 +37,10 @@ def main() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
raise SystemExit(main())
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception:
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
raise SystemExit(1)
|
||||
@ -92,7 +92,7 @@ argument-hint: "需要 prompt 参数(画图提示词),可选 model(模
|
||||
|
||||
1. 当用户输入绘图相关内容时触发该技能。
|
||||
2. 从用户输入中提取 prompt(画图提示词),不对提示词做总结或修改。可选提取 model、negative_prompt、ratio、resolution 参数。
|
||||
3. 在执行脚本前,先安装依赖:`python3 skills/text-to-image/scripts/bootstrap.py`,或直接执行 `python3 -m pip install -r skills/text-to-image/scripts/requirements.txt`。
|
||||
3. 在执行脚本前,先安装依赖:`python3 skills/text-to-image/scripts/bootstrap.py`。
|
||||
4. 将参数组装为 JSON 字符串,在仓库根目录下执行本地脚本:`python3 text-to-image/scripts/text_to_image.py '<JSON参数>'`。
|
||||
5. 脚本内部执行逻辑:
|
||||
- 连接 MySQL 数据库(数据库名 = `ROBOT_CODE`)。
|
||||
|
||||
@ -4,15 +4,17 @@ from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
|
||||
sys.stderr = sys.stdout
|
||||
|
||||
def main() -> int:
|
||||
script_dir = Path(__file__).resolve().parent
|
||||
requirements_file = script_dir / "requirements.txt"
|
||||
|
||||
if not requirements_file.is_file():
|
||||
sys.stderr.write(f"未找到依赖文件: {requirements_file}\n")
|
||||
sys.stdout.write(f"未找到依赖文件: {requirements_file}\n")
|
||||
return 1
|
||||
|
||||
command = [
|
||||
@ -25,9 +27,9 @@ def main() -> int:
|
||||
]
|
||||
|
||||
try:
|
||||
subprocess.run(command, check=True)
|
||||
subprocess.run(command, check=True, stdout=sys.stdout, stderr=sys.stdout)
|
||||
except subprocess.CalledProcessError as exc:
|
||||
sys.stderr.write(f"安装依赖失败,退出码: {exc.returncode}\n")
|
||||
sys.stdout.write(f"安装依赖失败,退出码: {exc.returncode}\n")
|
||||
return exc.returncode or 1
|
||||
|
||||
sys.stdout.write("依赖安装完成\n")
|
||||
@ -35,4 +37,10 @@ def main() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
raise SystemExit(main())
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception:
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
raise SystemExit(1)
|
||||
@ -7,8 +7,12 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
import urllib.request
|
||||
|
||||
# The skill runner consumes stdout, so route Python error output there as well.
|
||||
sys.stderr = sys.stdout
|
||||
|
||||
import pymysql # type: ignore # noqa: E402
|
||||
|
||||
|
||||
@ -363,4 +367,10 @@ def main() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
raise SystemExit(main())
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception:
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
raise SystemExit(1)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user