Update wrapper/wrapper.py
Added playwright and chromium for data scraping, and simplified env designation
This commit is contained in:
		
							parent
							
								
									eac918e317
								
							
						
					
					
						commit
						34a4582791
					
				@ -2,16 +2,23 @@ import os, sys, time, shutil, subprocess, signal, json, pathlib, re, datetime
 | 
			
		||||
from typing import Tuple
 | 
			
		||||
 | 
			
		||||
# ---------- Config (env) ----------
 | 
			
		||||
REPO_URL           = os.getenv("REPO_URL", "").strip()  # e.g. https://git.rolfsvaag.no/frarol96/shaiwatcher
 | 
			
		||||
REPO_BRANCH        = os.getenv("REPO_BRANCH", "main").strip()
 | 
			
		||||
REPO_TOKEN         = os.getenv("REPO_TOKEN", "").strip()  # optional (for private), not used if empty
 | 
			
		||||
RECHECK_UTC        = os.getenv("RECHECK_UTC", "03:00").strip()  # HH:MM (UTC)
 | 
			
		||||
PIP_INSTALL        = os.getenv("PIP_INSTALL_REQUIREMENTS", "1").strip() == "1"
 | 
			
		||||
REPO_URL    = os.getenv("REPO_URL", "").strip()
 | 
			
		||||
REPO_BRANCH = os.getenv("REPO_BRANCH", "main").strip()
 | 
			
		||||
REPO_TOKEN  = os.getenv("REPO_TOKEN", "").strip()  # optional
 | 
			
		||||
 | 
			
		||||
# prefer CHECK_TIME_UTC; fall back to old RECHECK_UTC
 | 
			
		||||
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)
 | 
			
		||||
IGNORE_TEST_LEVEL = os.getenv("IGNORE_TEST_LEVEL", "1").strip() == "1"
 | 
			
		||||
 | 
			
		||||
PIP_INSTALL = os.getenv("PIP_INSTALL_REQUIREMENTS", "1").strip() == "1"
 | 
			
		||||
 | 
			
		||||
CACHE_DIR = pathlib.Path("/cache/app")
 | 
			
		||||
TMP_DIR   = pathlib.Path("/cache/tmp")
 | 
			
		||||
PREV_DIR  = pathlib.Path("/cache/prev")
 | 
			
		||||
DATA_DIR  = pathlib.Path("/data")
 | 
			
		||||
 | 
			
		||||
CACHE_DIR   = pathlib.Path("/cache/app")      # current code
 | 
			
		||||
TMP_DIR     = pathlib.Path("/cache/tmp")      # temp checkout
 | 
			
		||||
PREV_DIR    = pathlib.Path("/cache/prev")     # rollback
 | 
			
		||||
DATA_DIR    = pathlib.Path("/data")           # persistent data volume
 | 
			
		||||
RUN_TIMEOUT = int(os.getenv("WRAPPER_STOP_TIMEOUT", "25"))
 | 
			
		||||
ROLLBACK_MAX_FAILS = 3
 | 
			
		||||
 | 
			
		||||
@ -67,8 +74,8 @@ def should_update(old: str, new: str) -> bool:
 | 
			
		||||
    nM,nE,nN,nP,nt = parse_version(new)
 | 
			
		||||
    if (oM,oE,oN,oP) != (nM,nE,nN,nP):
 | 
			
		||||
        return True
 | 
			
		||||
    # numeric same -> only test part differs → do NOT update
 | 
			
		||||
    return False
 | 
			
		||||
    # numeric parts same → only test suffix changed
 | 
			
		||||
    return not IGNORE_TEST_LEVEL and (ot != nt)
 | 
			
		||||
 | 
			
		||||
def clone_or_fetch(target: pathlib.Path):
 | 
			
		||||
    if target.exists() and (target / ".git").exists():
 | 
			
		||||
@ -198,8 +205,8 @@ def run_loop():
 | 
			
		||||
    consecutive_failures = 0
 | 
			
		||||
 | 
			
		||||
    while True:
 | 
			
		||||
        # sleep until next 03:00 UTC
 | 
			
		||||
        delay = next_utc(RECHECK_UTC)
 | 
			
		||||
        # 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")
 | 
			
		||||
        time.sleep(delay)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user