Skip to content
Snippets Groups Projects
Commit 36314324 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update helper.get_versions in order to handle all plugins.

parent d17c105c
No related branches found
No related tags found
1 merge request!36Release 0.9.7
......@@ -573,40 +573,43 @@ def get_versions():
and its version identifier. The keys are ``code`` and ``version``
"""
ope = os.path.exists
opj = os.path.join
server_path, client_path = get_reference_paths()
T = current.T
# matplotlib library
try:
import matplotlib
mpl = matplotlib.__version__
except ImportError:
mpl = current.T('not install')
mpl = T('not install')
# pandas library
try:
import pandas
pnd = pandas.__version__
except ImportError:
pnd = current.T('not install')
pnd = T('not install')
# plugin ace
ace = current.T('plugin not install')
path = os.path.join(server_path, 'static', 'plugin_ace')
if os.path.exists(path):
ace = current.T('install')
ace = T('not install')
path = opj(server_path, 'static', 'plugin_ace')
if ope(path):
ace = T('install')
# plugin dbui
fn = os.path.join(server_path, 'static', 'plugin_dbui', 'src', 'Dbui.js')
fn = opj(server_path, 'static', 'plugin_dbui', 'src', 'Dbui.js')
with open(fn, 'rb') as fi:
s = fi.read()
m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL)
dbui = m.group(2)
# plugin Ext JS
extjs = current.T('plugin not install')
path = os.path.join(server_path, 'static', 'plugin_extjs')
if os.path.exists(path):
fn = os.path.join(path, 'version.properties')
extjs = T('not install')
path = opj(server_path, 'static', 'plugin_extjs')
if ope(path):
fn = opj(path, 'version.properties')
with open(fn, 'rb') as fi:
s = fi.read()
......@@ -615,13 +618,13 @@ def get_versions():
extjs = m.group(1)
# plugin mathjax
mathjax = current.T('plugin not install')
path = os.path.join(server_path, 'static', 'plugin_mathjax')
if os.path.exists(path):
fn = os.path.join(server_path,
'static',
'plugin_mathjax',
'MathJax.js')
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, 'rb') as fi:
s = fi.read()
......@@ -629,6 +632,19 @@ def get_versions():
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')))
# web2py
web2py = ''
val = current.request.env.web2py_version
......@@ -638,17 +654,17 @@ def get_versions():
web2py = m.group()
elif isinstance(val, (tuple, list)):
li = [str(el) for el in val if isinstance(el, int)]
li = [str(plg) for plg in val if isinstance(plg, int)]
web2py = '.'.join(li)
# version of the application
myapp = current.T("unknown")
myapp = T("unknown")
if os.path.exists(VERSION):
with open(os.path.join(server_path, VERSION)) as fi:
if ope(VERSION):
with open(opj(server_path, VERSION)) as fi:
myapp = fi.read()
elif os.path.exists(GIT):
elif ope(GIT):
ref_path = os.getcwd()
os.chdir(server_path)
......@@ -659,14 +675,17 @@ def get_versions():
# prepare the output
li = [dict(code="web2py", version=web2py),
dict(code="dbui", version=dbui),
dict(code="extjs", version=extjs),
dict(code="mathjax", version=mathjax),
dict(code="ace", version=ace),
dict(code="plugin_dbui", version=dbui),
dict(code="plugin_extjs", version=extjs),
dict(code="plugin_mathjax", version=mathjax),
dict(code="plugin_ace", version=ace),
dict(code="matplotlib", version=mpl),
dict(code="pandas", version=pnd),
dict(code=current.request.application, version=myapp)]
li.extend(plugins)
li.sort()
return li
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment