Загрузить файлы в «/»
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
"""
|
||||
Пересохраняет .env в UTF-8 без BOM.
|
||||
Запусти один раз: python fix_env.py
|
||||
"""
|
||||
import os
|
||||
|
||||
env_path = os.path.join(os.path.dirname(__file__), ".env")
|
||||
|
||||
# Читаем с автоопределением кодировки
|
||||
for encoding in ("utf-8-sig", "cp1251", "cp1252", "latin-1"):
|
||||
try:
|
||||
with open(env_path, "r", encoding=encoding) as f:
|
||||
content = f.read()
|
||||
print(f"[fix_env] Прочитано в кодировке: {encoding}")
|
||||
break
|
||||
except (UnicodeDecodeError, FileNotFoundError) as e:
|
||||
if isinstance(e, FileNotFoundError):
|
||||
print(f"[fix_env] ❌ Файл .env не найден: {env_path}")
|
||||
exit(1)
|
||||
continue
|
||||
else:
|
||||
print("[fix_env] ❌ Не удалось определить кодировку .env")
|
||||
exit(1)
|
||||
|
||||
# Пишем обратно в UTF-8 без BOM
|
||||
with open(env_path, "w", encoding="utf-8", newline="\n") as f:
|
||||
f.write(content)
|
||||
|
||||
print("[fix_env] ✅ .env пересохранён в UTF-8. Теперь запускай: langgraph dev")
|
||||
Reference in New Issue
Block a user