Files
Mrpzx 977f97995a tripocli v2.0.0:Tripo AI 3D 生成与加工 CLI(面向 Agent 与开发者,纯 Python 标准库、零第三方依赖)
覆盖文生 3D、图生 3D、多视图、批量生成,以及重拓扑、绑定、动画、智能分割、
纹理、PBR、智能 UV、部件补全、格式导出与下载。

代码组织:一个功能一个模块(tripo/features/),入口薄壳 tripocli.py。
2026-10-13 19:22:54 +08:00

58 lines
2.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""本地账号管理服务 — tripocli serve.
tripocli serve # 打开 http://127.0.0.1:8765/
tripocli serve --port 9000 --open # 指定端口并自动打开浏览器
页面里可以粘贴/更新 cookie、查看会话有效期与积分额度、切换当前账号、删除账号。
默认只监听 127.0.0.1:能访问到它的人就能以该账号身份调用接口。
"""
import subprocess
import sys
import webbrowser
from ..server import serve
NAME = "serve"
HELP = "启动本地账号管理服务(网页里粘贴/更新 cookie、看有效期与积分)"
LOOPBACK = {"127.0.0.1", "localhost", "::1"}
def add_arguments(parser):
parser.add_argument("--host", default="127.0.0.1", help="监听地址(默认 127.0.0.1)")
parser.add_argument("--port", type=int, default=8765, help="监听端口(默认 8765,0 表示自动分配)")
parser.add_argument("--open", action="store_true", help="启动后自动打开浏览器")
parser.add_argument("--quiet", action="store_true", help="不打印请求日志")
def run(ctx):
args = ctx.args
httpd, url = serve(host=args.host, port=args.port)
if args.quiet:
httpd.RequestHandlerClass.log_message = lambda *a, **k: None
ctx.out.line(f"🖥 账号管理服务已启动: {url}")
ctx.out.line(f" 账号文件: {ctx.accounts.path}")
if args.host not in LOOPBACK:
ctx.out.line(f" ⚠️ 正在监听 {args.host},局域网内任何人都能访问并操作该账号,请谨慎使用")
ctx.out.line(" 按 Ctrl+C 停止")
if args.open:
try:
webbrowser.open(url)
except Exception:
try:
subprocess.Popen(["open", url])
except Exception:
ctx.out.line(" (无法自动打开浏览器,请手动访问上面的地址)")
try:
httpd.serve_forever()
except KeyboardInterrupt:
ctx.out.line("\n已停止")
finally:
httpd.server_close()
return {"url": url}