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: except:
import ZPsycopgDA.DA as ZopeDA # interp.py import ZPsycopgDA.DA as ZopeDA # interp.py
import sco_utils
from sco_utils import ( from sco_utils import (
SCO_DEFAULT_SQL_USERS_CNX, SCO_DEFAULT_SQL_USERS_CNX,
SCO_ENCODING, SCO_ENCODING,
@ -75,7 +76,6 @@ from sco_utils import (
SCO_EXC_MAIL, SCO_EXC_MAIL,
SCO_DEV_MAIL, SCO_DEV_MAIL,
scodoc_html2txt, scodoc_html2txt,
get_svn_version,
VERSION, VERSION,
SCODOC_CFG_DIR, SCODOC_CFG_DIR,
) )
@ -795,8 +795,7 @@ ErrorType: %(error_type)s
HTTP_USER_AGENT = "na" HTTP_USER_AGENT = "na"
form = REQUEST.get("form", "") form = REQUEST.get("form", "")
HTTP_X_FORWARDED_FOR = REQUEST.get("HTTP_X_FORWARDED_FOR", "") HTTP_X_FORWARDED_FOR = REQUEST.get("HTTP_X_FORWARDED_FOR", "")
svn_version = get_svn_version(self.file_path) SCOVERSION = sco_utils.get_scodoc_version() or VERSION.SCOVERSION
SCOVERSION = VERSION.SCOVERSION
txt = ( txt = (
""" """
@ -810,8 +809,6 @@ REFERER: %(REFERER)s
Form: %(form)s Form: %(form)s
Origin: %(HTTP_X_FORWARDED_FOR)s Origin: %(HTTP_X_FORWARDED_FOR)s
Agent: %(HTTP_USER_AGENT)s Agent: %(HTTP_USER_AGENT)s
subversion: %(svn_version)s
""" """
% vars() % vars()
) )

View File

@ -52,7 +52,7 @@ log("restarting...")
log("ZScolar home=%s" % file_path) log("ZScolar home=%s" % file_path)
import sco_utils
from sco_utils import * from sco_utils import *
import notesdb import notesdb
from notesdb import * from notesdb import *
@ -405,9 +405,9 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
H = [ H = [
"""<h2>Système de gestion scolarité</h2> """<h2>Système de gestion scolarité</h2>
<p>&copy; Emmanuel Viennet 1997-2020</p> <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( 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>' '<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 email.header import Header
from notesdb import * from notesdb import *
import sco_utils
from sco_utils import * from sco_utils import *
from notes_log import log from notes_log import log
@ -191,7 +192,7 @@ def _send_db(context, REQUEST, ano_db_name):
"nomcomplet" "nomcomplet"
], ],
"sco_version": SCOVERSION, "sco_version": SCOVERSION,
"sco_subversion": get_svn_version(SCO_TOOLS_DIR), "sco_fullversion": sco_utils.get_scodoc_version(),
}, },
) )
return r return r

View File

@ -29,7 +29,7 @@
""" Verification version logiciel vs version "stable" sur serveur """ Verification version logiciel vs version "stable" sur serveur
N'effectue pas la mise à jour automatiquement, mais permet un affichage d'avertissement. N'effectue pas la mise à jour automatiquement, mais permet un affichage d'avertissement.
""" """
import sco_utils
from sco_utils import * from sco_utils import *
# Appel renvoyant la subversion "stable" # Appel renvoyant la subversion "stable"
@ -66,65 +66,66 @@ def is_up_to_date(context):
"""True if up_to_date """True if up_to_date
Returns status, message Returns status, message
""" """
global _LAST_UP_TO_DATE_REQUEST, _UP_TO_DATE, _UP_TO_DATE_MSG log("Warning: is_up_to_date not implemented for ScoDoc8")
if _LAST_UP_TO_DATE_REQUEST and ( return True, "unimplemented"
datetime.datetime.now() - _LAST_UP_TO_DATE_REQUEST # global _LAST_UP_TO_DATE_REQUEST, _UP_TO_DATE, _UP_TO_DATE_MSG
) < datetime.timedelta(1): # if _LAST_UP_TO_DATE_REQUEST and (
# requete deja effectuee aujourd'hui: # datetime.datetime.now() - _LAST_UP_TO_DATE_REQUEST
return _UP_TO_DATE, _UP_TO_DATE_MSG # ) < datetime.timedelta(1):
# # requete deja effectuee aujourd'hui:
# return _UP_TO_DATE, _UP_TO_DATE_MSG
last_stable_ver = get_last_stable_version() # last_stable_ver = get_last_stable_version()
cur_ver = get_svn_version(context.file_path) # in sco_utils # cur_ver = sco_utils.get_scodoc_version()
cur_ver2 = cur_ver # cur_ver2 = cur_ver
cur_ver_num = -1 # cur_ver_num = -1
# Convert versions to integers: # # Convert versions to integers:
try: # try:
# cur_ver can be "1234" or "1234M' or '1234:1245M'... # # cur_ver can be "1234" or "1234M' or '1234:1245M'...
fs = cur_ver.split(":", 1) # fs = cur_ver.split(":", 1)
if len(fs) > 1: # if len(fs) > 1:
cur_ver2 = fs[-1] # cur_ver2 = fs[-1]
m = re.match(r"([0-9]*)", cur_ver2) # m = re.match(r"([0-9]*)", cur_ver2)
if not m: # if not m:
raise ValueError( # raise ValueError(
"invalid svn version" # "invalid svn version"
) # should never occur, regexp always (maybe empty) match # ) # should never occur, regexp always (maybe empty) match
cur_ver_num = int(m.group(1)) # cur_ver_num = int(m.group(1))
except: # except:
log('Warning: no numeric subversion ! (cur_ver="%s")' % cur_ver) # log('Warning: no numeric subversion ! (cur_ver="%s")' % cur_ver)
return _UP_TO_DATE, _UP_TO_DATE_MSG # silently ignore misconfiguration ? # return _UP_TO_DATE, _UP_TO_DATE_MSG # silently ignore misconfiguration ?
try: # try:
last_stable_ver_num = int(last_stable_ver) # last_stable_ver_num = int(last_stable_ver)
except: # except:
log("Warning: last_stable_version returned by server is invalid !") # log("Warning: last_stable_version returned by server is invalid !")
return ( # return (
_UP_TO_DATE, # _UP_TO_DATE,
_UP_TO_DATE_MSG, # _UP_TO_DATE_MSG,
) # should ignore this error (maybe server is unreachable) # ) # should ignore this error (maybe server is unreachable)
# # #
if cur_ver_num < last_stable_ver_num: # if cur_ver_num < last_stable_ver_num:
_UP_TO_DATE = False # _UP_TO_DATE = False
_UP_TO_DATE_MSG = "Version %s disponible (version %s installée)" % ( # _UP_TO_DATE_MSG = "Version %s disponible (version %s installée)" % (
last_stable_ver, # last_stable_ver,
cur_ver_num, # cur_ver_num,
) # )
log( # log(
"Warning: ScoDoc installation is not up-to-date, should upgrade\n%s" # "Warning: ScoDoc installation is not up-to-date, should upgrade\n%s"
% _UP_TO_DATE_MSG # % _UP_TO_DATE_MSG
) # )
else: # else:
_UP_TO_DATE = True # _UP_TO_DATE = True
_UP_TO_DATE_MSG = "" # _UP_TO_DATE_MSG = ""
log( # log(
"ScoDoc is up-to-date (cur_ver: %s, using %s=%s)" # "ScoDoc is up-to-date (cur_ver: %s, using %s=%s)"
% (cur_ver, cur_ver2, cur_ver_num) # % (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): def html_up_to_date_box(context):
""" """"""
"""
status, msg = is_up_to_date(context) status, msg = is_up_to_date(context)
if status: if status:
return "" 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) raise ValueError("invalid format: %s" % format)
# Get SVN version def get_scodoc_version():
def get_svn_version(path): "return a string identifying ScoDoc version"
if os.path.exists("/usr/bin/svnversion"): return os.popen("cd %s; ./get_scodoc_version.sh -s" % SCO_TOOLS_DIR).read().strip()
try:
return os.popen("svnversion " + path).read().strip()
except:
return "non disponible (erreur de lecture)"
else:
return "non disponible"
# Simple string manipulations # Simple string manipulations