From 7d509f5b9817fcb4f5b7fb01f5f04e226fe574d6 Mon Sep 17 00:00:00 2001 From: frarol96 Date: Sun, 24 Aug 2025 13:09:17 +0000 Subject: [PATCH] Update wrapper/wrapper.py --- wrapper/wrapper.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/wrapper/wrapper.py b/wrapper/wrapper.py index 6a6e3ac..45e4830 100644 --- a/wrapper/wrapper.py +++ b/wrapper/wrapper.py @@ -2,11 +2,12 @@ import os, sys, time, shutil, subprocess, signal, json, pathlib, re, datetime from typing import Tuple # ---------- Config (env) ---------- -REPO_URL = os.getenv("REPO_URL", "").strip() +# Provide sane defaults so a plain run works without envs. +REPO_URL = os.getenv("REPO_URL", "https://git.rolfsvaag.no/frarol96/shaiwatcher.git").strip() REPO_BRANCH = os.getenv("REPO_BRANCH", "main").strip() -REPO_TOKEN = os.getenv("REPO_TOKEN", "").strip() # optional +REPO_TOKEN = os.getenv("REPO_AHTOKEN", os.getenv("REPO_TOKEN", "")).strip() # optional -# prefer CHECK_TIME_UTC; fall back to old RECHECK_UTC +# prefer CHECK_TIME_UTC; fall back to old RECHECK_UTC (kept for compatibility with your wrapper envs only) CHECK_TIME_UTC = os.getenv("CHECK_TIME_UTC", os.getenv("RECHECK_UTC", "03:00")).strip() # 1 = ignore test-only bumps (e.g. v1.2.3.4-T3 -> v1.2.3.4-T4) @@ -133,12 +134,12 @@ def pip_install(cwd: pathlib.Path): log(e.stdout + "\n" + e.stderr) def set_boot_env(status: str, old_ver: str, new_ver: str, commit: str = "", subject: str = ""): - # Env passed to the bot; bot should read and post to modlog on_ready - os.environ["SHAI_BOOT_STATUS"] = status - os.environ["SHAI_BOOT_OLDVER"] = old_ver - os.environ["SHAI_BOOT_NEWVER"] = new_ver - os.environ["SHAI_BUILD_COMMIT"] = commit - os.environ["SHAI_BUILD_SUBJECT"]= subject + # Env passed to the bot; if you later choose to use them, they're non-SHAI now. + os.environ["BOOT_STATUS"] = status + os.environ["BOOT_OLDVER"] = old_ver + os.environ["BOOT_NEWVER"] = new_ver + os.environ["BUILD_COMMIT"] = commit + os.environ["BUILD_SUBJECT"] = subject def get_head_info(cwd: pathlib.Path) -> Tuple[str,str]: try: @@ -152,8 +153,8 @@ def get_head_info(cwd: pathlib.Path) -> Tuple[str,str]: def start_bot(cwd: pathlib.Path) -> subprocess.Popen: env = os.environ.copy() - # Make sure data dir exists (the bot should use SHAI_DATA or SHAI_DATA_FILE or config) - env.setdefault("SHAI_DATA", "/data/data.json") + # Make sure data file env is present under the new name (no SHAI_). + env.setdefault("DATA_FILE", "/data/data.json") # Run from the cached code directory return subprocess.Popen([sys.executable, "-u", "bot.py"], cwd=cwd, env=env) @@ -207,7 +208,8 @@ def run_loop(): while True: # sleep until next check (03:00 UTC by default) delay = next_utc(CHECK_TIME_UTC) - log(f"sleeping {int(delay)}s until {RECHECK_UTC} UTC for update check") + # FIX: use CHECK_TIME_UTC here (your original printed RECHECK_UTC) + log(f"sleeping {int(delay)}s until {CHECK_TIME_UTC} UTC for update check") time.sleep(delay) # check for update