mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-27 07:54:19 +00:00
perf: 禁止双击运行
This commit is contained in:
@@ -49,6 +49,19 @@ async def main_entry():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
import os
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
allowed_parent_process = ['cmd.exe', 'powershell.exe', 'wsl.exe']
|
||||||
|
|
||||||
|
parent_process = psutil.Process(os.getppid()).name()
|
||||||
|
|
||||||
|
if parent_process not in allowed_parent_process:
|
||||||
|
print("请在命令行中运行此程序。")
|
||||||
|
input("按任意键退出...")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
asyncio.run(main_entry())
|
asyncio.run(main_entry())
|
||||||
|
|||||||
Reference in New Issue
Block a user