From 2bf4449dce069f5638978ff16d96a7cf9dcb870a Mon Sep 17 00:00:00 2001 From: viennet Date: Mon, 21 Dec 2020 18:42:02 +0100 Subject: [PATCH] Version display --- ZScoDoc.py | 7 +-- ZScolar.py | 6 +-- sco_dump_db.py | 3 +- sco_up_to_date.py | 111 +++++++++++++++++++++++----------------------- sco_utils.py | 12 ++--- 5 files changed, 66 insertions(+), 73 deletions(-) diff --git a/ZScoDoc.py b/ZScoDoc.py index 397f9f55..53dd44c1 100644 --- a/ZScoDoc.py +++ b/ZScoDoc.py @@ -66,6 +66,7 @@ try: except: import ZPsycopgDA.DA as ZopeDA # interp.py +import sco_utils from sco_utils import ( SCO_DEFAULT_SQL_USERS_CNX, SCO_ENCODING, @@ -75,7 +76,6 @@ from sco_utils import ( SCO_EXC_MAIL, SCO_DEV_MAIL, scodoc_html2txt, - get_svn_version, VERSION, SCODOC_CFG_DIR, ) @@ -795,8 +795,7 @@ ErrorType: %(error_type)s HTTP_USER_AGENT = "na" form = REQUEST.get("form", "") HTTP_X_FORWARDED_FOR = REQUEST.get("HTTP_X_FORWARDED_FOR", "") - svn_version = get_svn_version(self.file_path) - SCOVERSION = VERSION.SCOVERSION + SCOVERSION = sco_utils.get_scodoc_version() or VERSION.SCOVERSION txt = ( """ @@ -810,8 +809,6 @@ REFERER: %(REFERER)s Form: %(form)s Origin: %(HTTP_X_FORWARDED_FOR)s Agent: %(HTTP_USER_AGENT)s - -subversion: %(svn_version)s """ % vars() ) diff --git a/ZScolar.py b/ZScolar.py index d47a3060..e660b1e2 100644 --- a/ZScolar.py +++ b/ZScolar.py @@ -52,7 +52,7 @@ log("restarting...") log("ZScolar home=%s" % file_path) - +import sco_utils from sco_utils import * import notesdb from notesdb import * @@ -405,9 +405,9 @@ UE11 Découverte métiers (code UCOD46, 16 ECTS, Apo Système de gestion scolarité

© Emmanuel Viennet 1997-2020

-

Version %s (subversion %s)

+

Version %s

""" - % (SCOVERSION, get_svn_version(file_path)) + % (sco_utils.get_scodoc_version()) ] H.append( '

Logiciel libre écrit en Python.

Utilise ReportLab pour générer les documents PDF, et pyExcelerator pour le traitement des documents Excel.

' diff --git a/sco_dump_db.py b/sco_dump_db.py index 54f2a230..0c7d9210 100644 --- a/sco_dump_db.py +++ b/sco_dump_db.py @@ -56,6 +56,7 @@ from email.mime.base import MIMEBase from email.header import Header from notesdb import * +import sco_utils from sco_utils import * from notes_log import log @@ -191,7 +192,7 @@ def _send_db(context, REQUEST, ano_db_name): "nomcomplet" ], "sco_version": SCOVERSION, - "sco_subversion": get_svn_version(SCO_TOOLS_DIR), + "sco_fullversion": sco_utils.get_scodoc_version(), }, ) return r diff --git a/sco_up_to_date.py b/sco_up_to_date.py index 29a7b280..9eb8f45f 100644 --- a/sco_up_to_date.py +++ b/sco_up_to_date.py @@ -29,7 +29,7 @@ """ Verification version logiciel vs version "stable" sur serveur N'effectue pas la mise à jour automatiquement, mais permet un affichage d'avertissement. """ - +import sco_utils from sco_utils import * # Appel renvoyant la subversion "stable" @@ -66,65 +66,66 @@ def is_up_to_date(context): """True if up_to_date Returns status, message """ - global _LAST_UP_TO_DATE_REQUEST, _UP_TO_DATE, _UP_TO_DATE_MSG - if _LAST_UP_TO_DATE_REQUEST and ( - datetime.datetime.now() - _LAST_UP_TO_DATE_REQUEST - ) < datetime.timedelta(1): - # requete deja effectuee aujourd'hui: - return _UP_TO_DATE, _UP_TO_DATE_MSG + log("Warning: is_up_to_date not implemented for ScoDoc8") + return True, "unimplemented" + # global _LAST_UP_TO_DATE_REQUEST, _UP_TO_DATE, _UP_TO_DATE_MSG + # if _LAST_UP_TO_DATE_REQUEST and ( + # datetime.datetime.now() - _LAST_UP_TO_DATE_REQUEST + # ) < datetime.timedelta(1): + # # requete deja effectuee aujourd'hui: + # return _UP_TO_DATE, _UP_TO_DATE_MSG - last_stable_ver = get_last_stable_version() - cur_ver = get_svn_version(context.file_path) # in sco_utils - cur_ver2 = cur_ver - cur_ver_num = -1 - # Convert versions to integers: - try: - # cur_ver can be "1234" or "1234M' or '1234:1245M'... - fs = cur_ver.split(":", 1) - if len(fs) > 1: - cur_ver2 = fs[-1] - m = re.match(r"([0-9]*)", cur_ver2) - if not m: - raise ValueError( - "invalid svn version" - ) # should never occur, regexp always (maybe empty) match - cur_ver_num = int(m.group(1)) - except: - log('Warning: no numeric subversion ! (cur_ver="%s")' % cur_ver) - return _UP_TO_DATE, _UP_TO_DATE_MSG # silently ignore misconfiguration ? - try: - last_stable_ver_num = int(last_stable_ver) - except: - log("Warning: last_stable_version returned by server is invalid !") - return ( - _UP_TO_DATE, - _UP_TO_DATE_MSG, - ) # should ignore this error (maybe server is unreachable) - # - if cur_ver_num < last_stable_ver_num: - _UP_TO_DATE = False - _UP_TO_DATE_MSG = "Version %s disponible (version %s installée)" % ( - last_stable_ver, - cur_ver_num, - ) - log( - "Warning: ScoDoc installation is not up-to-date, should upgrade\n%s" - % _UP_TO_DATE_MSG - ) - else: - _UP_TO_DATE = True - _UP_TO_DATE_MSG = "" - log( - "ScoDoc is up-to-date (cur_ver: %s, using %s=%s)" - % (cur_ver, cur_ver2, cur_ver_num) - ) + # last_stable_ver = get_last_stable_version() + # cur_ver = sco_utils.get_scodoc_version() + # cur_ver2 = cur_ver + # cur_ver_num = -1 + # # Convert versions to integers: + # try: + # # cur_ver can be "1234" or "1234M' or '1234:1245M'... + # fs = cur_ver.split(":", 1) + # if len(fs) > 1: + # cur_ver2 = fs[-1] + # m = re.match(r"([0-9]*)", cur_ver2) + # if not m: + # raise ValueError( + # "invalid svn version" + # ) # should never occur, regexp always (maybe empty) match + # cur_ver_num = int(m.group(1)) + # except: + # log('Warning: no numeric subversion ! (cur_ver="%s")' % cur_ver) + # return _UP_TO_DATE, _UP_TO_DATE_MSG # silently ignore misconfiguration ? + # try: + # last_stable_ver_num = int(last_stable_ver) + # except: + # log("Warning: last_stable_version returned by server is invalid !") + # return ( + # _UP_TO_DATE, + # _UP_TO_DATE_MSG, + # ) # should ignore this error (maybe server is unreachable) + # # + # if cur_ver_num < last_stable_ver_num: + # _UP_TO_DATE = False + # _UP_TO_DATE_MSG = "Version %s disponible (version %s installée)" % ( + # last_stable_ver, + # cur_ver_num, + # ) + # log( + # "Warning: ScoDoc installation is not up-to-date, should upgrade\n%s" + # % _UP_TO_DATE_MSG + # ) + # else: + # _UP_TO_DATE = True + # _UP_TO_DATE_MSG = "" + # log( + # "ScoDoc is up-to-date (cur_ver: %s, using %s=%s)" + # % (cur_ver, cur_ver2, cur_ver_num) + # ) - return _UP_TO_DATE, _UP_TO_DATE_MSG + # return _UP_TO_DATE, _UP_TO_DATE_MSG def html_up_to_date_box(context): - """ - """ + """""" status, msg = is_up_to_date(context) if status: return "" diff --git a/sco_utils.py b/sco_utils.py index 90f78564..a8f5b984 100644 --- a/sco_utils.py +++ b/sco_utils.py @@ -597,15 +597,9 @@ def sendResult(REQUEST, data, name=None, format=None, force_outer_xml_tag=True): raise ValueError("invalid format: %s" % format) -# Get SVN version -def get_svn_version(path): - if os.path.exists("/usr/bin/svnversion"): - try: - return os.popen("svnversion " + path).read().strip() - except: - return "non disponible (erreur de lecture)" - else: - return "non disponible" +def get_scodoc_version(): + "return a string identifying ScoDoc version" + return os.popen("cd %s; ./get_scodoc_version.sh -s" % SCO_TOOLS_DIR).read().strip() # Simple string manipulations