Version display

This commit is contained in:
viennet 2020-12-21 18:42:02 +01:00
parent bdc0ad488a
commit 2bf4449dce
5 changed files with 66 additions and 73 deletions

View File

@ -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()
)

View File

@ -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 <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
H = [
"""<h2>Système de gestion scolarité</h2>
<p>&copy; Emmanuel Viennet 1997-2020</p>
<p>Version %s (subversion %s)</p>
<p>Version %s</p>
"""
% (SCOVERSION, get_svn_version(file_path))
% (sco_utils.get_scodoc_version())
]
H.append(
'<p>Logiciel libre écrit en <a href="http://www.python.org">Python</a>.</p><p>Utilise <a href="http://www.reportlab.org/">ReportLab</a> pour générer les documents PDF, et <a href="http://sourceforge.net/projects/pyexcelerator">pyExcelerator</a> pour le traitement des documents Excel.</p>'

View File

@ -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

View File

@ -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 ""

View File

@ -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