e5a586f903
Move business code under modules/, env template to config/, PM2 single qihuo process, and _legacy shims for old imports. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
987 B
Python
38 lines
987 B
Python
# Copyright (c) 2025-2026 马建军. All rights reserved.
|
|
|
|
"""Repository layout paths — single source for config, data, uploads."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# .../qihuo/modules/core/paths.py -> repo root
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
CONFIG_DIR = ROOT / "config"
|
|
ENV_FILE = CONFIG_DIR / ".env"
|
|
LEGACY_ENV_FILE = ROOT / ".env"
|
|
|
|
DATA_DIR = ROOT / "data"
|
|
UPLOADS_DIR = ROOT / "uploads"
|
|
LOGS_DIR = ROOT / "logs"
|
|
|
|
DB_PATH = str(ROOT / "futures.db")
|
|
|
|
|
|
def ensure_runtime_dirs() -> None:
|
|
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
|
UPLOADS_DIR.mkdir(parents=True, exist_ok=True)
|
|
LOGS_DIR.mkdir(parents=True, exist_ok=True)
|
|
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
def resolve_env_file() -> str:
|
|
"""Prefer config/.env, fall back to legacy root .env."""
|
|
if ENV_FILE.is_file():
|
|
return str(ENV_FILE)
|
|
if LEGACY_ENV_FILE.is_file():
|
|
return str(LEGACY_ENV_FILE)
|
|
return str(ENV_FILE)
|