mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 11:29:39 +08:00
feat: 依赖检查移动到main.py
This commit is contained in:
29
main.py
29
main.py
@@ -1,5 +1,5 @@
|
|||||||
import asyncio
|
# QChatGPT 终端启动入口
|
||||||
|
# 在此层级解决依赖项检查。
|
||||||
|
|
||||||
asciiart = r"""
|
asciiart = r"""
|
||||||
___ ___ _ _ ___ ___ _____
|
___ ___ _ _ ___ ___ _____
|
||||||
@@ -11,8 +11,29 @@ asciiart = r"""
|
|||||||
📖文档地址: https://q.rkcn.top
|
📖文档地址: https://q.rkcn.top
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
async def main_entry():
|
||||||
print(asciiart)
|
print(asciiart)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from pkg.core.bootutils import deps
|
||||||
|
|
||||||
|
missing_deps = await deps.check_deps()
|
||||||
|
|
||||||
|
if missing_deps:
|
||||||
|
print("以下依赖包未安装,将自动安装,请完成后重启程序:")
|
||||||
|
for dep in missing_deps:
|
||||||
|
print("-", dep)
|
||||||
|
await deps.install_deps(missing_deps)
|
||||||
|
print("已自动安装缺失的依赖包,请重启程序。")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
from pkg.core import boot
|
from pkg.core import boot
|
||||||
asyncio.run(boot.main())
|
await boot.main()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
asyncio.run(main_entry())
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .bootutils import files
|
from .bootutils import files
|
||||||
from .bootutils import deps
|
|
||||||
from .bootutils import log
|
from .bootutils import log
|
||||||
from .bootutils import config
|
from .bootutils import config
|
||||||
|
|
||||||
@@ -38,15 +36,6 @@ async def make_app() -> app.Application:
|
|||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
missing_deps = await deps.check_deps()
|
|
||||||
|
|
||||||
if missing_deps:
|
|
||||||
print("以下依赖包未安装,将自动安装,请完成后重启程序:")
|
|
||||||
for dep in missing_deps:
|
|
||||||
print("-", dep)
|
|
||||||
await deps.install_deps(missing_deps)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
qcg_logger = await log.init_logging()
|
qcg_logger = await log.init_logging()
|
||||||
|
|
||||||
# 生成标识符
|
# 生成标识符
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ log_colors_config = {
|
|||||||
|
|
||||||
|
|
||||||
async def init_logging() -> logging.Logger:
|
async def init_logging() -> logging.Logger:
|
||||||
|
# 删除所有现有的logger
|
||||||
|
for handler in logging.root.handlers[:]:
|
||||||
|
logging.root.removeHandler(handler)
|
||||||
|
|
||||||
level = logging.INFO
|
level = logging.INFO
|
||||||
|
|
||||||
if "DEBUG" in os.environ and os.environ["DEBUG"] in ["true", "1"]:
|
if "DEBUG" in os.environ and os.environ["DEBUG"] in ["true", "1"]:
|
||||||
@@ -46,7 +50,7 @@ async def init_logging() -> logging.Logger:
|
|||||||
|
|
||||||
qcg_logger.debug("日志初始化完成,日志级别:%s" % level)
|
qcg_logger.debug("日志初始化完成,日志级别:%s" % level)
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO, # 设置日志输出格式
|
level=logging.CRITICAL, # 设置日志输出格式
|
||||||
format="[DEPR][%(asctime)s.%(msecs)03d] %(pathname)s (%(lineno)d) - [%(levelname)s] :\n%(message)s",
|
format="[DEPR][%(asctime)s.%(msecs)03d] %(pathname)s (%(lineno)d) - [%(levelname)s] :\n%(message)s",
|
||||||
# 日志输出的格式
|
# 日志输出的格式
|
||||||
# -8表示占位符,让输出左对齐,输出长度都为8位
|
# -8表示占位符,让输出左对齐,输出长度都为8位
|
||||||
|
|||||||
Reference in New Issue
Block a user