Fix if folder does not exist
This commit is contained in:
parent
80ada82cb5
commit
d1dd755193
@ -6,13 +6,13 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
||||||
from env import CLIENT_NAME, API_BASE, TOKEN_FILE, IS_RENDER, ACCOUNT_JSON_URL, ACCOUNT_JSON_TOKEN
|
from app.env import CLIENT_NAME, API_BASE, TOKEN_FILE, IS_RENDER, ACCOUNT_JSON_URL, ACCOUNT_JSON_TOKEN
|
||||||
|
|
||||||
if IS_RENDER:
|
if IS_RENDER:
|
||||||
import requests
|
import requests
|
||||||
print("⚠️ Running in Render environment, downloading account.json with token in URL...")
|
print("⚠️ Running in Render environment, downloading account.json with token in URL...")
|
||||||
|
|
||||||
url = f"{ACCOUNT_JSON_URL}?token={ACCOUNT_JSON_TOKEN}"
|
url = f"{ACCOUNT_URL_JSON}?token={ACCOUNT_JSON_TOKEN}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
@ -21,10 +21,14 @@ if IS_RENDER:
|
|||||||
print(f"❌ Failed to download account.json: {e}")
|
print(f"❌ Failed to download account.json: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
Path(TOKEN_FILE).parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with open(TOKEN_FILE, "wb") as f:
|
with open(TOKEN_FILE, "wb") as f:
|
||||||
f.write(response.content)
|
f.write(response.content)
|
||||||
|
|
||||||
print("✅ account.json downloaded successfully.")
|
print("✅ account.json downloaded successfully.")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
def save_token(data):
|
def save_token(data):
|
||||||
data["created_at"] = datetime.now(timezone.utc).isoformat()
|
data["created_at"] = datetime.now(timezone.utc).isoformat()
|
2
run.py
2
run.py
@ -43,7 +43,7 @@ def main():
|
|||||||
print("Virtual environment found.")
|
print("Virtual environment found.")
|
||||||
|
|
||||||
print("Running VRChat authentication script...")
|
print("Running VRChat authentication script...")
|
||||||
run_in_venv(["app/prelaunch/vrchat_auth.py"])
|
run_in_venv(["prelaunch/vrchat_auth.py"])
|
||||||
|
|
||||||
print("Starting FastAPI server...")
|
print("Starting FastAPI server...")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user