Commit 93aaa20b authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update helper to improve get_version.

parent 7dea306f
......@@ -20,6 +20,8 @@ from gluon.validators import (IS_DATE_IN_RANGE,
IS_INT_IN_RANGE,
IS_MATCH,
IS_LENGTH)
from pathlib import Path
GIT = "/usr/bin/git"
REX_REFERENCE = re.compile("^reference (\w+)$")
......@@ -605,64 +607,40 @@ def get_versions():
# plugin ace
ace = T("not install")
path = opj(server_path, "static", "plugin_ace")
if ope(path):
path = Path(server_path, "static", "plugin_ace")
if path.exists():
ace = T("install")
# plugin dbui
fn = opj(server_path, "static", "plugin_dbui", "src", "Dbui.js")
with open(fn, "r") as fi:
s = fi.read()
m = re.search('(version: *")([\w\._-]*)(")', s)
dbui = m.group(2)
path = Path(server_path, "static", "plugin_dbui", VERSION)
if path.exists():
dbui = path.read_text()
# plugin Ext JS
extjs = T("not install")
path = opj(server_path, "static", "plugin_extjs")
if ope(path):
fn = opj(path, "version.properties")
with open(fn, "r") as fi:
s = fi.read()
m = re.search(r"version.release=(\d+(\.\d+)*)", s)
if m:
extjs = m.group(1)
path = Path(server_path, "static", "plugin_extjs", "version.properties")
if path.exists():
data = path.read_text()
mtch = re.search(r"version.release=(\d+(\.\d+)*)", data)
if mtch:
extjs = mtch.group(1)
# plugin mathjax
mathjax = T("not install")
path = opj(server_path, "static", "plugin_mathjax")
if ope(path):
fn = opj(server_path,
"static",
"plugin_mathjax",
"MathJax.js")
with open(fn, "r") as fi:
s = fi.read()
m = re.search(r'MathJax.version="(\d+(\.\d+)*)";', s)
if m:
mathjax = m.group(1)
# other plugins
plugins = []
stdplgs = ("plugin_ace", "plugin_dbui", "plugin_extjs", "plugin_mathjax")
for plg in os.listdir(opj(server_path, "static")):
if plg.startswith("plugin") and plg not in stdplgs:
path = opj(server_path, "static", plg, "VERSION")
if opj(path):
with open(opj(path)) as fi:
plugins.append(dict(code=plg, version=fi.read()))
else:
plugins.append(dict(code=plg, version=T("install")))
path = Path(server_path, "static", "plugin_mathjax", "MathJax.js")
if path.exists():
data = path.read_text()
mtch = re.search(r'MathJax.version="(\d+(\.\d+)*)";', data)
if mtch:
mathjax = mtch.group(1)
# web2py
web2py = ""
val = current.request.env.web2py_version
if isinstance(val, str):
m = re.match("\d+\.\d+\.\d+", val)
if m:
web2py = m.group()
mtch = re.match("\d+\.\d+\.\d+", val)
if mtch:
web2py = mtch.group()
elif isinstance(val, (tuple, list)):
li = [str(plg) for plg in val if isinstance(plg, int)]
......@@ -670,12 +648,11 @@ def get_versions():
# version of the application
myapp = T("unknown")
path = Path(server_path, VERSION)
if path.exists():
myapp = path.read_text()
if ope(VERSION):
with open(opj(server_path, VERSION)) as fi:
myapp = fi.read()
elif ope(GIT):
elif Path(GIT).exists():
ref_path = os.getcwd()
os.chdir(server_path)
......@@ -694,7 +671,6 @@ def get_versions():
dict(code="pandas", version=pnd),
dict(code=current.request.application, version=myapp)]
li.extend(plugins)
li.sort(key=lambda dct: dct["code"])
return li
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment