tools: 缺 lupa 时给出安装提示而不是 traceback
部署/开发机未装 lupa 时,脚本直接退出码 2 并提示 pip install lupa;宿主运行时自带该依赖,此处仅影响校验环境。
This commit is contained in:
1 parent
e07cc5ec83
commit
4f0b9bdc19
1 file changed
+11
-1
+11
-1
@@ -22,7 +22,17 @@ import urllib.request
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from lua.worker import LuaPlugin # noqa: E402
|
||||
try:
|
||||
from lua.worker import LuaPlugin # noqa: E402
|
||||
except ImportError as exc: # pragma: no cover - 依赖缺失时的友好提示
|
||||
if "lupa" in str(exc):
|
||||
sys.stderr.write(
|
||||
"缺少 lupa:本脚本需要用它加载 Lua 插件。\n"
|
||||
" pip install lupa\n"
|
||||
"(宿主运行时自带 lupa,这里缺的是开发机上的校验环境)\n"
|
||||
)
|
||||
raise SystemExit(2)
|
||||
raise
|
||||
|
||||
LIMITS = {
|
||||
"lua_memory_bytes": 268435456,
|
||||
|
||||
Reference in new issue
Block a user