gouyez

config.py

Nov 23rd, 2025
1,529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. from pathlib import Path
  2. import sys, os
  3.  
  4. APP_VERSION = "1.0.0"
  5.  
  6. # resource helper similar to earlier single-file
  7. def is_frozen():
  8.     return getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")
  9.  
  10. def resource_path(relative: str) -> Path:
  11.     if is_frozen():
  12.         base = Path(sys._MEIPASS)
  13.         return base / relative
  14.     return Path(relative).absolute()
  15.  
  16. # App dirs
  17. LOCAL_APP_ROOT = Path(os.environ.get("LOCALAPPDATA", str(Path.home() / "AppData" / "Local"))) / "GmailHybrid"
  18. MASTER_CHROME_DIR = LOCAL_APP_ROOT / "chrome_master"
  19. CHROMES_DIR = LOCAL_APP_ROOT / "chromes"
  20. PROFILES_DIR = LOCAL_APP_ROOT / "profiles"
  21. TOKENS_DIR = Path("emails")
  22.  
  23. def ensure_master_extracted(log_fn=print):
  24.     src = resource_path("chrome_master")
  25.     if not src.exists():
  26.         alt = Path(__file__).parent.parent / "chrome_master"
  27.         if alt.exists():
  28.             src = alt
  29.         else:
  30.             log_fn("[MASTER] chrome_master not found.")
  31.             return False
  32.     try:
  33.         MASTER_CHROME_DIR.mkdir(parents=True, exist_ok=True)
  34.         # if you want to actually copy master, keep previous logic here
  35.         return True
  36.     except Exception as e:
  37.         log_fn(f"[MASTER] extract failed: {e}")
  38.         return False
  39.  
  40. def ensure_tokens_dir():
  41.     TOKENS_DIR.mkdir(exist_ok=True)
  42.  
Advertisement