61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
"""共享配置:dws 路径解析 + 群组定义"""
|
|
|
|
import os
|
|
import shutil
|
|
import platform
|
|
|
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
PROJECT_ROOT = os.path.dirname(SCRIPT_DIR)
|
|
TOOLS_DIR = os.path.join(PROJECT_ROOT, "tools")
|
|
|
|
# dws 路径查找优先级:
|
|
# 1. 环境变量 DWS_PATH
|
|
# 2. 项目 tools/ 目录(从 GitHub 下载的独立版本)
|
|
# 3. 悟空内置路径(向后兼容)
|
|
# 4. 系统 PATH
|
|
|
|
_WUKONG_PATHS = [
|
|
os.path.expanduser(r"~\.real\.bin\dws\bin\dws.exe"),
|
|
r"C:\Program Files\Wukong\0.9.51-26052503\bin\dws.exe",
|
|
]
|
|
|
|
|
|
def _find_dws():
|
|
# 1) 显式指定
|
|
env = os.environ.get("DWS_PATH")
|
|
if env and os.path.isfile(env):
|
|
return env
|
|
|
|
# 2) 项目 tools/ 目录
|
|
ext = ".exe" if platform.system() == "Windows" else ""
|
|
local = os.path.join(TOOLS_DIR, "dws" + ext)
|
|
if os.path.isfile(local):
|
|
return local
|
|
|
|
# 3) 悟空内置(向后兼容)
|
|
for p in _WUKONG_PATHS:
|
|
if os.path.isfile(p):
|
|
return p
|
|
|
|
# 4) 系统 PATH
|
|
found = shutil.which("dws")
|
|
if found:
|
|
return found
|
|
|
|
raise FileNotFoundError(
|
|
"找不到 dws CLI。请执行以下任一操作:\n"
|
|
" 1) 运行: python scripts/setup_dws.py (从 GitHub 自动下载)\n"
|
|
" 2) 手动下载: https://github.com/DingTalk-Real-AI/dingtalk-workspace-cli/releases/latest\n"
|
|
" 将 dws.exe 放到 tools/ 目录\n"
|
|
" 3) 设置环境变量: DWS_PATH=<你的 dws 路径>"
|
|
)
|
|
|
|
|
|
DWS = _find_dws()
|
|
|
|
# 钉钉群组 ID
|
|
GROUPS = {
|
|
"创新组": "cidMuM+itt5PeY7xNSWsv3M0g==",
|
|
"dc战略问题研究院": "cidoUneRB4Db8TAXaTrKxkQAw==",
|
|
}
|