APmanageur Wi-Fi V1.0

This commit is contained in:
yoannmultigaming committed 2026-11-21 04:12:57 +01:00
1 parent ceeab6fa4a
commit 6ab15cecec
6 files changed
+119 -43

No files matched your search

+34 -9
View File
@@ -3476,10 +3476,37 @@ _update_cache = {
}
def get_current_commit():
"""Récupère le SHA du commit actuel (variable AP_GIT_COMMIT, version.json ou git)."""
"""Récupère le SHA du commit actuel (variable AP_GIT_COMMIT, git rev-parse ou version.json)."""
env_c = os.environ.get('AP_GIT_COMMIT', '').strip()
if env_c:
return env_c
# 1. Priorité au dépôt Git réel si disponible
try:
c = command('git', 'rev-parse', 'HEAD')
if c and len(c.strip()) >= 7:
git_sha = c.strip()
# Mettre à jour version.json s'il existe et est désynchronisé
for v_path in (
os.path.join(BASE_DIR, 'version.json'),
os.path.join(os.getcwd(), 'version.json'),
'version.json'
):
if os.path.isfile(v_path):
try:
with open(v_path, 'r', encoding='utf-8') as f:
vdata = json.load(f)
if vdata.get('commit') != git_sha:
vdata['commit'] = git_sha
with open(v_path, 'w', encoding='utf-8') as f:
json.dump(vdata, f, indent=2)
except Exception:
pass
return git_sha
except Exception:
pass
# 2. Sinon, lecture de version.json (conteneur Docker où .git n'est pas présent)
for path in (
os.path.join(BASE_DIR, 'version.json'),
'/app/version.json',
@@ -3496,12 +3523,6 @@ def get_current_commit():
return c
except Exception:
pass
try:
c = command('git', 'rev-parse', 'HEAD')
if c and len(c.strip()) >= 7:
return c.strip()
except Exception:
pass
return ''
def check_gitea_update(force_refresh=False):
@@ -3545,10 +3566,14 @@ def check_gitea_update(force_refresh=False):
date_str = (c_info.get('author') or {}).get('date', '')
html_url = first.get('html_url') or GITEA_REPO_URL
if current_sha and latest_sha:
c_low = current_sha.lower()
l_low = latest_sha.lower()
c_low = current_sha.lower().strip()
l_low = latest_sha.lower().strip()
if not l_low.startswith(c_low) and not c_low.startswith(l_low):
available = True
else:
available = False
else:
available = False
except Exception as e:
err_msg = str(e)