Commit b5eeed51 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update helper to improve get_version.

parent 5c7bede4
......@@ -586,94 +586,96 @@ 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
app_path = Path("applications", current.request.application)
lst, T = [], current.T
not_install = T("not install")
# ........................................................................
#
# Python third parties matplotlib, pandas, ...
#
try:
import matplotlib
mpl = matplotlib.__version__
ver = matplotlib.__version__
except ImportError:
mpl = T("not install")
ver = not_install
lst.append(dict(code="matplotlib", version=ver))
# pandas library
try:
import pandas
pnd = pandas.__version__
ver = pandas.__version__
except ImportError:
pnd = T("not install")
ver = not_install
# plugin ace
ace = T("not install")
path = Path(server_path, "static", "plugin_ace")
if path.exists():
ace = T("install")
lst.append(dict(code="pandas", version=ver))
# plugin dbui
path = Path(server_path, "static", "plugin_dbui", VERSION)
# ........................................................................
#
# plugin(s)
#
for plg in ("plugin_ace", "plugin_dbui", "plugin_event"):
ver = not_install
path = app_path / "static" / plg / VERSION
if path.exists():
dbui = path.read_text()
ver = path.read_text()
elif Path(app_path, "static", plg).exists():
ver = T("install")
lst.append(dict(code=plg, version=ver))
# plugin Ext JS
extjs = T("not install")
path = Path(server_path, "static", "plugin_extjs", "version.properties")
ver = not_install
path = app_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)
ver = mtch.group(1)
lst.append(dict(code="plugin_extjs", version=ver))
# plugin mathjax
mathjax = T("not install")
path = Path(server_path, "static", "plugin_mathjax", "MathJax.js")
ver = not_install
path = app_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)
ver = mtch.group(1)
lst.append(dict(code="plugin_mathjax", version=ver))
# ........................................................................
#
# web2py
web2py = ""
val = current.request.env.web2py_version
#
ver, val = "", current.request.env.web2py_version
if isinstance(val, str):
mtch = re.match("\d+\.\d+\.\d+", val)
if mtch:
web2py = mtch.group()
ver = mtch.group()
elif isinstance(val, (tuple, list)):
li = [str(plg) for plg in val if isinstance(plg, int)]
web2py = ".".join(li)
# version of the application
myapp = T("unknown")
path = Path(server_path, VERSION)
if path.exists():
myapp = path.read_text()
ver = ".".join(li)
elif Path(GIT).exists():
ref_path = os.getcwd()
os.chdir(server_path)
lst.append(dict(code="web2py", version=ver))
myapp = subprocess.check_output(["git", "describe", "--tags"])
myapp = myapp.strip("\n")
# ........................................................................
#
# application
ver = T("unknown")
path = app_path / VERSION
if path.exists():
ver = path.read_text()
os.chdir(ref_path)
lst.append(dict(code=current.request.application, version=ver))
# prepare the output
li = [dict(code="web2py", version=web2py),
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.sort(key=lambda dct: dct["code"])
return li
lst.sort(key=lambda dct: dct["code"])
return lst
def get_where_query(table):
......
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