Skip to content

Commit

Permalink
fix: 工作目录必须在 main.py 目录
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Mar 30, 2024
1 parent 5a3e7fe commit 2e9229a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# QChatGPT 终端启动入口
# 在此层级解决依赖项检查。
# QChatGPT/main.py

asciiart = r"""
___ ___ _ _ ___ ___ _____
Expand Down Expand Up @@ -62,6 +63,21 @@ async def main_entry():
input("按任意键退出...")
exit(0)

# 检查本目录是否有main.py,且包含QChatGPT字符串
invalid_pwd = False

if not os.path.exists('main.py'):
invalid_pwd = True
else:
with open('main.py', 'r', encoding='utf-8') as f:
content = f.read()
if "QChatGPT/main.py" not in content:
invalid_pwd = True
if invalid_pwd:
print("请在QChatGPT项目根目录下运行此程序。")
input("按任意键退出...")
exit(0)

import asyncio

asyncio.run(main_entry())

0 comments on commit 2e9229a

Please sign in to comment.