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
...@@ -573,40 +573,43 @@ def get_versions(): ...@@ -573,40 +573,43 @@ def get_versions():
and its version identifier. The keys are ``code`` and ``version`` 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() server_path, client_path = get_reference_paths()
T = current.T
# matplotlib library # matplotlib library
try: try:
import matplotlib import matplotlib
mpl = matplotlib.__version__ mpl = matplotlib.__version__
except ImportError: except ImportError:
mpl = current.T('not install') mpl = T('not install')
# pandas library # pandas library
try: try:
import pandas import pandas
pnd = pandas.__version__ pnd = pandas.__version__
except ImportError: except ImportError:
pnd = current.T('not install') pnd = T('not install')
# plugin ace # plugin ace
ace = current.T('plugin not install') ace = T('not install')
path = os.path.join(server_path, 'static', 'plugin_ace') path = opj(server_path, 'static', 'plugin_ace')
if os.path.exists(path): if ope(path):
ace = current.T('install') ace = T('install')
# plugin dbui # 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: with open(fn, 'rb') as fi:
s = fi.read() s = fi.read()
m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL) m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL)
dbui = m.group(2) dbui = m.group(2)
# plugin Ext JS # plugin Ext JS
extjs = current.T('plugin not install') extjs = T('not install')
path = os.path.join(server_path, 'static', 'plugin_extjs') path = opj(server_path, 'static', 'plugin_extjs')
if os.path.exists(path): if ope(path):
fn = os.path.join(path, 'version.properties') fn = opj(path, 'version.properties')
with open(fn, 'rb') as fi: with open(fn, 'rb') as fi:
s = fi.read() s = fi.read()
...@@ -615,13 +618,13 @@ def get_versions(): ...@@ -615,13 +618,13 @@ def get_versions():
extjs = m.group(1) extjs = m.group(1)
# plugin mathjax # plugin mathjax
mathjax = current.T('plugin not install') mathjax = T('not install')
path = os.path.join(server_path, 'static', 'plugin_mathjax') path = opj(server_path, 'static', 'plugin_mathjax')
if os.path.exists(path): if ope(path):
fn = os.path.join(server_path, fn = opj(server_path,
'static', 'static',
'plugin_mathjax', 'plugin_mathjax',
'MathJax.js') 'MathJax.js')
with open(fn, 'rb') as fi: with open(fn, 'rb') as fi:
s = fi.read() s = fi.read()
...@@ -629,6 +632,19 @@ def get_versions(): ...@@ -629,6 +632,19 @@ def get_versions():
if m: if m:
mathjax = m.group(1) 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
web2py = '' web2py = ''
val = current.request.env.web2py_version val = current.request.env.web2py_version
...@@ -638,17 +654,17 @@ def get_versions(): ...@@ -638,17 +654,17 @@ def get_versions():
web2py = m.group() web2py = m.group()
elif isinstance(val, (tuple, list)): 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) web2py = '.'.join(li)
# version of the application # version of the application
myapp = current.T("unknown") myapp = T("unknown")
if os.path.exists(VERSION): if ope(VERSION):
with open(os.path.join(server_path, VERSION)) as fi: with open(opj(server_path, VERSION)) as fi:
myapp = fi.read() myapp = fi.read()
elif os.path.exists(GIT): elif ope(GIT):
ref_path = os.getcwd() ref_path = os.getcwd()
os.chdir(server_path) os.chdir(server_path)
...@@ -659,14 +675,17 @@ def get_versions(): ...@@ -659,14 +675,17 @@ def get_versions():
# prepare the output # prepare the output
li = [dict(code="web2py", version=web2py), li = [dict(code="web2py", version=web2py),
dict(code="dbui", version=dbui), dict(code="plugin_dbui", version=dbui),
dict(code="extjs", version=extjs), dict(code="plugin_extjs", version=extjs),
dict(code="mathjax", version=mathjax), dict(code="plugin_mathjax", version=mathjax),
dict(code="ace", version=ace), dict(code="plugin_ace", version=ace),
dict(code="matplotlib", version=mpl), dict(code="matplotlib", version=mpl),
dict(code="pandas", version=pnd), dict(code="pandas", version=pnd),
dict(code=current.request.application, version=myapp)] dict(code=current.request.application, version=myapp)]
li.extend(plugins)
li.sort()
return li 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