📣 An issue occured with the embedded container registry on October 25 2021, between 10:30 and 12:10 (UTC+2). Any persisting issues should be reported to CC-IN2P3 Support. 🐛

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

Merge branch 'master' into 'production'

Release 1.0.1

See merge request !47
parents 62d993bf 0ca6d35d
......@@ -16,8 +16,10 @@
import json
import os
from gluon.tools import PluginManager
API = """
Dbui.csvUrl = "/%s/plugin_dbui/csv";
Dbui.config = %s;
......@@ -32,10 +34,13 @@ Dbui.REMOTE_API = {
def about():
fn = os.path.join("applications",
request.application,
PluginManager("dbui").dbui.app_about)
return open(fn, "rb").read()
from pathlib import Path
path = Path("applications",
request.application,
PluginManager("dbui").dbui.app_about)
return path.read_text()
def call():
......@@ -171,40 +176,45 @@ def documentations_table():
configuration for the documentation and for the source code.
"""
from plugin_dbui import get_reference_paths, Store
from pathlib import Path
from plugin_dbui import Store
def path_exists(x):
return x and os.path.exists(os.path.join(apath, x))
def f(x):
return x.replace("static/", "")
# alias
a = '<a href="{}" target="_blank">{}</a>'
application = request.application
plugin = PluginManager("dbui").dbui
# alias
a = '<a href="%s" target="_blank">%s</a>'
trDb = T("Data base scheme")
trDev = T("Documentation for developers")
trJS = T("Javascript API")
trPy = T("Python API")
apath, lpath = get_reference_paths()
# main paths
apath = Path("applications", application)
static = apath / "static"
# documentation of the application
userdoc = ""
path_db_schema = plugin.app_db_schema
if path_exists(path_db_schema):
userdoc = a % (URL("static", f(path_db_schema)), T("Data base scheme"))
if plugin.app_db_schema is not None:
path_db_schema = apath / plugin.app_db_schema
if path_db_schema.exists():
fpath = str(path_db_schema.relative_to(static))
userdoc = a.format(URL("static", fpath), trDb)
pydoc = ""
path_html_api = plugin.app_html_api
if path_exists(path_html_api):
pydoc = a % (URL("static", f(path_html_api)), trPy)
if plugin.app_html_api is not None:
path_html_api = apath / plugin.app_html_api
if path_html_api.exists():
fpath = str(path_html_api.relative_to(static))
pydoc = a.format(URL("static", fpath), trPy)
jsdoc = ""
path_html_jsduck = plugin.app_html_jsduck
if path_exists(path_html_jsduck):
jsdoc = a % (URL("static", f(path_html_jsduck)), trJS)
if plugin.app_html_jsduck is not None:
path_html_jsduck = apath / plugin.app_html_jsduck
if path_html_jsduck.exists():
fpath = str(path_html_jsduck.relative_to(static))
jsdoc = a.format(URL("static", fpath), trJS)
# configuration of the Ext.data.Store for the documentation
cfg = Store()
......@@ -222,39 +232,42 @@ def documentations_table():
javascript=jsdoc)
r2 = dict(
code=a % ("https://marprod.in2p3.fr/plugin_dbui_book", "plugin_dbui"),
code=a.format(
"https://marprod.in2p3.fr/plugin_dbui_book", "plugin_dbui"),
developer=a %
(URL("static", "plugin_dbui/docs/reference/index.html"), trDev),
developer=a.format(
URL("static", "plugin_dbui/docs/reference/index.html"), trDev),
python=a % (URL("static", "plugin_dbui/docs/api/index.html"), trPy),
python=a.format(
URL("static", "plugin_dbui/docs/api/index.html"), trPy),
javascript=a %
(URL("static", "plugin_dbui/docs/jsduck/index.html"), trJS))
javascript=a.format(
URL("static", "plugin_dbui/docs/jsduck/index.html"), trJS))
r3 = dict(
code=a % ("http://web2py.com/", "Web2py"),
developer=a % ("http://web2py.com/book", trDev),
python=a % ("http://web2py.readthedocs.org/en/latest/", trPy),
code=a.format("http://web2py.com/", "Web2py"),
developer=a.format("http://web2py.com/book", trDev),
python=a.format("http://web2py.readthedocs.org/en/latest/", trPy),
javascript="")
r4 = dict(
code=a % ("http://www.sencha.com/products/extjs/", "Ext JS"),
code=a.format("http://www.sencha.com/products/extjs/", "Ext JS"),
developer="",
python="",
javascript=a % ("http://docs.sencha.com/extjs/6.0.1-classic/", trJS))
javascript=a.format(
"http://docs.sencha.com/extjs/6.0.1-classic/", trJS))
r5 = dict(
code=a % ("http://www.mathjax.org/", "MathJax"),
code=a.format("http://www.mathjax.org/", "MathJax"),
developer="",
python="",
javascript=a % ("http://docs.mathjax.org/", trJS))
javascript=a.format("http://docs.mathjax.org/", trJS))
r6 = dict(
code=a % ("http://ace.c9.io/#nav=about", "Ace"),
code=a.format("http://ace.c9.io/#nav=about", "Ace"),
developer="",
python="",
javascript=a % ("http://ace.c9.io/#nav=api", trJS))
javascript=a.format("http://ace.c9.io/#nav=api", trJS))
cfg.data = [r1, r2, r3, r4, r5, r6]
......@@ -268,7 +281,7 @@ def documentations_table():
src = ""
if plugin.app_git:
src = "<em>git clone %s</em>" % plugin.app_git
src = f"<em>git clone {plugin.app_git}</em>"
r1 = dict(code=request.application, source=src)
......@@ -285,7 +298,7 @@ def documentations_table():
code="Ext JS",
source="<em>Download from the Ext JS web site. </em><br>"
"<em>It is also available in the local directory: "
"%s/static/plugin_extjs/src</em>" % request.application)
f"{request.application}/static/plugin_extjs/src</em>")
r5 = dict(
code="MathJax",
......
""" a series of helper functions
"""
import os
import re
import subprocess
from .constant import INLINE_ALERT
......@@ -294,33 +292,37 @@ def get_file_paths(path, ext=None, alpha=True):
alpha (bool): sort the paths in alphabetic order
Returns:
list:
local paths for all selected files.
list or string:
* paths for all selected files,
* absolute path with respect to application
* for example: /myapp/static/myapp-min.js
"""
li = []
if path is None:
return li
return []
server_path, client_path = get_reference_paths()
lst = []
application = current.request.application
app_path = Path("applications", application)
for el in as_list(path):
p = os.path.join(server_path, el)
p = app_path / el
if os.path.isfile(p):
if ext and (not el.endswith(ext)):
if p.is_file():
if (ext is not None) and (p.suffix != ext):
continue
li.append(os.path.join(client_path, el))
lst.append(Path("/", application, el))
elif os.path.isdir(p):
for filename in os.listdir(p):
pfile = os.path.join(el, filename)
li.extend(get_file_paths(pfile, ext, alpha))
elif p.is_dir():
for pfile in p.iterdir():
new_path = str(pfile.relative_to(app_path))
lst.extend(get_file_paths(new_path, ext, alpha))
lst = [str(el) for el in lst]
if alpha:
li.sort()
lst.sort()
return li
return lst
def get_foreign_field(field):
......@@ -449,18 +451,20 @@ def get_plugin_path(plugin_name):
Returns:
str:
* the path of the first directory starting with ``plugin_name``.
* the local path is relative to the application directory.
* absolute path with respect to application
* for example: /myapp/static/plugin_foo
* ``None`` if the plugin is not found.
"""
server_path, client_path = get_reference_paths()
application = current.request.application
app_path = Path("applications", application)
# look for the full name of the plugin directory
p_static = os.path.join(server_path, "static")
for el in os.listdir(p_static):
if os.path.isdir(os.path.join(p_static, el)):
if el.startswith(plugin_name):
return os.path.join(client_path, "static", el)
p_static = app_path / "static"
for el in p_static.iterdir():
if el.is_dir():
if el.name == plugin_name:
return str(Path("/", application, "static", plugin_name))
# Nothing found
return None
......@@ -479,10 +483,12 @@ def get_reference_paths():
``("applications/myapp", "/myapp")``
"""
server_path = os.path.join("applications", current.request.application)
client_path = os.path.join(os.path.sep, current.request.application)
application = current.request.application
return (server_path, client_path)
server_path = Path("applications", application)
client_path = Path("/", application)
return (str(server_path), str(client_path))
def get_set_field(field):
......@@ -535,32 +541,32 @@ def get_script_path(plugin):
Returns:
str:
the local path of the script file relative to the
application directory.
* absolute path with respect to the application
* for example /myapp/blabla.
"""
server_path, client_path = get_reference_paths()
application = current.request.application
app_path = Path("applications", application)
# script name specifies in the URL
if "script" in current.request.vars:
script = current.request.vars.script
if not script.endswith(".js"):
script = "%s.js" % script
pdir = os.path.join(server_path, plugin.app_script_dir)
script = f"{script}.js"
if script not in os.listdir(pdir):
raise HTTP(500, 'Request script "%s" does not exist !!!' % script)
pscript = app_path / plugin.app_script_dir / script
if not pscript.exists():
raise HTTP(500, f"Request script '{script}' does not exist !!!")
return os.path.join(client_path, plugin.app_script_dir, script)
return str(Path("/", application, plugin.app_script_dir, script))
# default script for the application
if plugin.app_script:
return os.path.join(client_path, plugin.app_script)
return str(Path("/", application, plugin.app_script))
# default script for the plugin
return os.path.join(client_path, plugin.dbui_script)
return str(Path("/", application, plugin.dbui_script))
def get_store_id(name):
......@@ -586,94 +592,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)
if path.exists():
dbui = path.read_text()
# ........................................................................
#
# plugin(s)
#
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
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):
......
......@@ -2,7 +2,7 @@
HEAD
1.0 (Dec 2019)
1.0.1 (Dec 2019)
- Require python 3.7
- Requires web2py 2.18.3, matplotlib 3.1.1, pandas 0.25.2 or above.
- Migration to building tool w2pext/utilities release 1.0.
......
1.0
\ No newline at end of file
1.0.1
\ No newline at end of file
{{
import os
from plugin_dbui import get_reference_paths
# alias
apath, lpath = get_reference_paths()
myapp = request.application
path_exists = lambda x: x and os.path.exists(os.path.join(apath, x))
f = lambda x: x.replace("static/", "")
rwrite = response.write
}}
<h2 class="dbui-h2 dbui-small-cap">{{=T("Documentations")}}</h2>
<p class="dbui-p dbui-small-cap" style="margin-top: 5ex">
......@@ -19,6 +5,14 @@
</p>
<ul>
{{
from pathlib import Path
myapp = request.application
apath = Path("applications", myapp)
static = apath / "static"
rwrite = response.write
#.....................................................................
#
# user guide
......@@ -26,19 +20,21 @@
a1, a2 = None, None
path_html_user = plugin.app_html_user
if path_exists(path_html_user):
a1 = A("html",
callback=URL("static", f(path_html_user)),
_target="_blank")
if path_html_user is not None:
path_html_user = apath / path_html_user
if path_html_user.exists():
fpath = str(path_html_user.relative_to(static))
a1 = A("html", callback=URL("static", fpath), _target="_blank")
pass
pass
path_pdf_user = plugin.app_pdf_user
if path_exists(path_pdf_user):
a2 = A("pdf",
callback=URL("static", f(path_pdf_user)),
_target="_blank")
if path_pdf_user is not None:
path_pdf_user = apath / path_pdf_user
if path_pdf_user.exists():
fpath = str(path_pdf_user.relative_to(static))
a2 = A("pdf", callback=URL("static", fpath), _target="_blank")
pass
pass
if a1 is not None and a2 is not None:
......@@ -53,13 +49,17 @@
# database schema
#
path_db_schema = plugin.app_db_schema
if path_exists(path_db_schema):
if path_db_schema is not None:
path_db_schema = apath / path_db_chema
if path_db_schema.exists():
a = A(T("Database schema"),
callback=URL("static", f(path_db_schema)),
_target="_blank")
fpath = str(path_db_schema.relative_to(static))
a = A(T("Database schema"),
callback=URL("static", fpath),
_target="_blank")
rwrite(LI(a, _class="dbui-p"))
rwrite(LI(a, _class="dbui-p"))
pass
pass
#.....................................................................
......@@ -67,13 +67,17 @@
# changelog
#
path_changelog = plugin.app_changelog
if path_exists(path_changelog):
if path_changelog is not None:
path_changelog = apath / path_changelog
if path_changelog.exists():
a = A("CHANGELOG",
callback=URL("static", f(path_changelog)),
_target="_blank")
fpath = str(path_changelog.relative_to(static))
a = A("CHANGELOG",
callback=URL("static", fpath),
_target="_blank")
rwrite(LI(a, _class="dbui-p"))
rwrite(LI(a, _class="dbui-p"))
pass
pass
}}
......@@ -89,13 +93,17 @@
# Python API
#
path_html_api = plugin.app_html_api
if path_exists(path_html_api):
if path_html_api is not None:
path_html_api = apath / path_html_api
if path_html_api.exists():
a = A("%s Python API" % myapp,
callback=URL("static", f(path_html_api)),
_target="_blank")
fpath = str(path_html_api.relative_to(static))
a = A("%s Python API" % myapp,
callback=URL("static", fpath),
_target="_blank")
rwrite(LI(a, _class="dbui-p"))
rwrite(LI(a, _class="dbui-p"))
pass
pass
#.....................................................................
......@@ -103,16 +111,20 @@