From 9a13470ff370b3016ccd2fe15c660959979aaa78 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 20 Mar 2022 23:12:30 +0100 Subject: [PATCH] use check_version --- app/scodoc/html_sco_header.py | 3 +++ app/scodoc/sco_formsemestre_status.py | 6 ++++-- app/scodoc/sco_up_to_date.py | 19 ++++++++++++------- app/scodoc/sco_utils.py | 2 +- app/static/css/scodoc.css | 2 +- app/static/js/scodoc.js | 7 ++++++- app/templates/sco_page.html | 1 + 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/scodoc/html_sco_header.py b/app/scodoc/html_sco_header.py index 8ce3d2cdd..6d128fd85 100644 --- a/app/scodoc/html_sco_header.py +++ b/app/scodoc/html_sco_header.py @@ -250,6 +250,9 @@ def sco_header( '' ) H.append('') + # H.append( + # '' + # ) # JS additionels for js in javascripts: H.append("""\n""" % js) diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 11e665d92..ae9ce543d 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -1170,8 +1170,10 @@ def formsemestre_tableau_modules( H.append('' % fontorange) H.append( - '%s' - % (modimpl["moduleimpl_id"], mod_descr, mod.code) + f"""{mod.code}""" ) H.append( '%s' diff --git a/app/scodoc/sco_up_to_date.py b/app/scodoc/sco_up_to_date.py index 152b05691..6404ef0ed 100644 --- a/app/scodoc/sco_up_to_date.py +++ b/app/scodoc/sco_up_to_date.py @@ -33,6 +33,8 @@ import json import requests import time from flask import current_app + +from app import log import app.scodoc.sco_utils as scu from sco_version import SCOVERSION, SCONAME @@ -43,7 +45,7 @@ def is_up_to_date() -> str: """ diag = "" try: - response = requests.get(scu.SCO_UP2DATE) + response = requests.get(scu.SCO_UP2DATE + "/" + SCOVERSION) except requests.exceptions.ConnectionError: current_app.logger.debug("is_up_to_date: %s", diag) return f"""
Attention: installation de {SCONAME} non fonctionnelle.
@@ -60,7 +62,6 @@ def is_up_to_date() -> str: voir la documentation. """ - if response.status_code != 200: current_app.logger.debug( f"is_up_to_date: invalid response code ({response.status_code})" @@ -75,12 +76,16 @@ def is_up_to_date() -> str: return f"""
Attention: réponse invalide de {scu.SCO_WEBSITE}
(erreur json).
""" - # nb: si de nouveaux paquets sont publiés chaque jour, le décalage ne sera jamais signalé. - # mais en régime "normal", on aura une alerte après 24h sans mise à jour. - days_since_last_package = (time.time() - infos["publication_time"]) / (24 * 60 * 60) - if (infos["version"] != SCOVERSION) and (days_since_last_package > 1.0): + if infos["status"] != "ok": + # problème coté serveur, ignore discrètement + log(f"is_up_to_date: server {infos['status']}") + return "" + if (SCOVERSION != infos["last_version"]) and ( + (time.time() - infos["last_version_date"]) > (24 * 60 * 60) + ): + # nouvelle version publiée depuis plus de 24h ! return f"""
Attention: {SCONAME} version ({SCOVERSION}) non à jour - ({infos["version"]} disponible).
+ ({infos["last_version"]} disponible).
Contacter votre administrateur système (documentation).
diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 03e02cbf6..6df7ed6eb 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -361,7 +361,7 @@ SCO_DEV_MAIL = "emmanuel.viennet@gmail.com" # SVP ne pas changer # Adresse pour l'envoi des dumps (pour assistance technnique): # ne pas changer (ou vous perdez le support) SCO_DUMP_UP_URL = "https://scodoc.org/scodoc-installmgr/upload-dump" -SCO_UP2DATE = "https://scodoc.org/scodoc-installmgr/last_stable_version" +SCO_UP2DATE = "https://scodoc.org/scodoc-installmgr/check_version" CSV_FIELDSEP = ";" CSV_LINESEP = "\n" CSV_MIMETYPE = "text/comma-separated-values" diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index d8a7249c4..6c0b06b8f 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -2884,7 +2884,7 @@ div.othersemlist input { div#update_warning { - /* display: none; */ + display: none; border: 1px solid red; background-color: rgb(250,220,220); margin: 3ex; diff --git a/app/static/js/scodoc.js b/app/static/js/scodoc.js index b1c15017e..7cb5bb626 100644 --- a/app/static/js/scodoc.js +++ b/app/static/js/scodoc.js @@ -58,7 +58,12 @@ $(function () { if (update_div) { fetch('install_info').then( response => response.text() - ).then(text => update_div.innerHTML = text); + ).then(text => { + update_div.innerHTML = text; + if (text) { + update_div.style.display = "block"; + } + }); } }); diff --git a/app/templates/sco_page.html b/app/templates/sco_page.html index e1aa9e3c5..f1590302a 100644 --- a/app/templates/sco_page.html +++ b/app/templates/sco_page.html @@ -9,6 +9,7 @@ +{# #} {% endblock %}