diff --git a/astrbot/cli/commands/cmd_run.py b/astrbot/cli/commands/cmd_run.py index 76256ae4b..38113744f 100644 --- a/astrbot/cli/commands/cmd_run.py +++ b/astrbot/cli/commands/cmd_run.py @@ -4,6 +4,7 @@ from pathlib import Path import click import asyncio +import traceback from filelock import FileLock, Timeout @@ -59,4 +60,4 @@ def run(reload: bool, port: str) -> None: except Timeout: raise click.ClickException("无法获取锁文件,请检查是否有其他实例正在运行") except Exception as e: - raise click.ClickException(f"运行时出现错误: {e!s}") + raise click.ClickException(f"运行时出现错误: {e}\n{traceback.format_exc()}") diff --git a/astrbot/dashboard/routes/tools.py b/astrbot/dashboard/routes/tools.py index f8cd9c8f6..d38014c71 100644 --- a/astrbot/dashboard/routes/tools.py +++ b/astrbot/dashboard/routes/tools.py @@ -7,6 +7,7 @@ from quart import request from astrbot.core import logger from astrbot.core.core_lifecycle import AstrBotCoreLifecycle +from astrbot.core.utils.astrbot_path import get_astrbot_data_path from .route import Response, Route, RouteContext @@ -31,8 +32,7 @@ class ToolsRoute(Route): @property def mcp_config_path(self): - current_dir = os.path.dirname(os.path.abspath(__file__)) - data_dir = os.path.abspath(os.path.join(current_dir, "../../../data")) + data_dir = get_astrbot_data_path() return os.path.join(data_dir, "mcp_server.json") def load_mcp_config(self): diff --git a/astrbot/dashboard/server.py b/astrbot/dashboard/server.py index e4e4d60b7..124291718 100644 --- a/astrbot/dashboard/server.py +++ b/astrbot/dashboard/server.py @@ -13,10 +13,7 @@ from .routes.route import RouteContext, Response from astrbot.core import logger, WEBUI_SK from astrbot.core.db import BaseDatabase from astrbot.core.utils.io import get_local_ip_addresses - -DATAPATH = os.path.abspath( - os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../data") -) +from astrbot.core.utils.astrbot_path import get_astrbot_data_path class AstrBotDashboard: @@ -28,7 +25,7 @@ class AstrBotDashboard: ) -> None: self.core_lifecycle = core_lifecycle self.config = core_lifecycle.astrbot_config - self.data_path = os.path.abspath(os.path.join(DATAPATH, "dist")) + self.data_path = os.path.abspath(os.path.join(get_astrbot_data_path(), "dist")) self.app = Quart("dashboard", static_folder=self.data_path, static_url_path="/") self.app.config["MAX_CONTENT_LENGTH"] = ( 128 * 1024 * 1024