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