Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

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

Merge branch 'master' into 'production'

Release 0.9.8.2

See merge request !40
parents 36b5645d 52e753b8
......@@ -119,11 +119,11 @@ def commit_release():
call(["git", "checkout", "master"], stdout=fi, stderr=fi)
# Commit modified files
print '\n\tgit add', DBUIJS, CHANGELOG, VERSION
print "\n\tgit add", DBUIJS, CHANGELOG, VERSION
call(["git", "add", DBUIJS, CHANGELOG, VERSION])
msg = "Start release candidate %s" % get_version()
print '\tgit commit:', msg
print "\tgit commit:", msg
call(["git", "commit", "-m", msg])
......@@ -158,12 +158,12 @@ def get_plugin_version(plugin):
elif plugin == "extjs":
fn = os.path.join('static', 'plugin_extjs', 'version.properties')
fn = os.path.join("static", "plugin_extjs", "version.properties")
if not os.path.exists(fn):
error("\n\tNo version file for the plugin extjs !")
sys.exit(1)
with open(fn, 'rb') as fi:
with open(fn, "rb") as fi:
s = fi.read()
match = re.search(r"version.release=(\d+(\.\d+)*)", s)
......@@ -174,14 +174,14 @@ def get_plugin_version(plugin):
release = match.group(1)
# shrink the release identifier 4.2.1 or 4.2.1.883 -> 421
li = release.split('.')
release = ''.join(li) if len(li) < 4 else ''.join(li[:-1])
li = release.split(".")
release = "".join(li) if len(li) < 4 else "".join(li[:-1])
elif plugin == "mathjax":
filename = os.path.join('static', 'plugin_mathjax', 'MathJax.js')
filename = os.path.join("static", "plugin_mathjax", "MathJax.js")
with open(filename, 'rb') as tmpfile:
with open(filename, "rb") as tmpfile:
text = tmpfile.read()
match = re.match(r'.+MathJax.version="(\d+(\.\d+)*)";', text, re.DOTALL)
......@@ -228,52 +228,52 @@ def set_version(version):
print "\n\tRelease %s already exit in git" % version
sys.exit(1)
print '\tSet release', version, 'in', DBUIJS
print "\tSet release", version, "in", DBUIJS
with open(DBUIJS) as fi:
txt = fi.read()
# look for a pattern Dbui.version = '0.8.3'; in appbase.js
# look for a pattern Dbui.version = "0.8.3"; in appbase.js
# split the the string in 3 parts (pre, version, post)
match = re.match(r"(.+ version: ')([\w._-]*)('.+)", txt, re.DOTALL)
match = re.match(r'(.+ version: ")([\w._-]*)(".+)', txt, re.DOTALL)
if match.group(2) == version:
msg = '\n\tVersion "%s" already exists in the Dbui.js file !'
msg = "\n\tVersion '%s' already exists in the Dbui.js file !"
print msg % version
rep = raw_input('\tDo you want to continue [n]? ')
if rep not in ('y', 'yes'):
rep = raw_input("\tDo you want to continue [n]? ")
if rep not in ("y", "yes"):
sys.exit(1)
# update the version and write a new file
txt = match.group(1) + version + match.group(3)
with open(DBUIJS, 'w') as fi:
with open(DBUIJS, "w") as fi:
fi.write(txt)
# look for a pattern HEAD in the CHANGELOG
# split the the string in 2 parts (pre HEAD, post HEAD)
print '\tSet release', version, 'in', CHANGELOG
print "\tSet release", version, "in", CHANGELOG
with open(CHANGELOG) as fi:
txt = fi.read()
match = re.match("(.+HEAD\n)(.*)", txt, re.DOTALL)
if match is None:
print '\n\tNo HEAD tag in the CHANGELOG!\n'
rep = raw_input('\tDo you want to continue [n]?')
if rep not in ('y', 'yes'):
print "\n\tNo HEAD tag in the CHANGELOG!\n"
rep = raw_input("\tDo you want to continue [n]?")
if rep not in ("y", "yes"):
sys.exit(1)
# update the version and edit the CHANGELOG
tpl = (match.group(1), version, NOW.strftime('%b %Y'), match.group(2))
txt = '%s\n%s (%s)\n%s' % tpl
tpl = (match.group(1), version, NOW.strftime("%b %Y"), match.group(2))
txt = "%s\n%s (%s)\n%s" % tpl
with open(CHANGELOG, 'w') as fi:
with open(CHANGELOG, "w") as fi:
fi.write(txt)
call(["vim", CHANGELOG])
# update VERSION
print '\tSet release', version, 'in', VERSION
with open(VERSION, 'w') as fi:
print "\tSet release", version, "in", VERSION
with open(VERSION, "w") as fi:
fi.write(version)
# cleaning
......
""" """
import os
import re
def index():
"""Main Controller to run the application.
"""
url = URL('plugin_dbui', 'index', args=request.args, vars=request.vars)
url = URL("plugin_dbui", "index", args=request.args, vars=request.vars)
return redirect(url)
def user():
return 'hello you hit the default/user controller'
\ No newline at end of file
return "hello you hit the default/user controller"
......@@ -15,22 +15,19 @@
"""
import json
import os
import plugin_dbui as dbui
from gluon.tools import PluginManager
API = """
Dbui.csvUrl = '/%s/plugin_dbui/csv';
Dbui.csvUrl = "/%s/plugin_dbui/csv";
Dbui.config = %s;
Dbui.debug = %s;
Dbui.latex2pdfUrl = '/%s/plugin_dbui/latex2pdf.pdf';
Dbui.name = '%s';
Dbui.latex2pdfUrl = "/%s/plugin_dbui/latex2pdf.pdf";
Dbui.name = "%s";
Dbui.REMOTE_API = {
'url': '/%s/plugin_dbui/call',
'type': 'remoting',
'actions': %s
"url": "/%s/plugin_dbui/call",
"type": "remoting",
"actions": %s
};"""
......@@ -38,7 +35,7 @@ def about():
fn = os.path.join("applications",
request.application,
PluginManager("dbui").dbui.app_about)
return open(fn, 'rb').read()
return open(fn, "rb").read()
def call():
......@@ -59,10 +56,11 @@ def csv():
is_foreign_field,
is_table_with_foreign_fields)
tablename = request.vars['tableName']
tablename = request.vars["tableName"]
response.headers['Content-Type'] = contenttype('.csv')
response.headers['Content-Disposition'] = 'attachment; filename=%s.csv;' % tablename
headers = response.headers
headers["Content-Type"] = contenttype(".csv")
headers["Content-Disposition"] = "attachment; filename=%s.csv;" % tablename
table = db[tablename]
query = table.id > 0
......@@ -95,9 +93,9 @@ def dbui_conf():
the plugin dbui: application name, store definition,...
"""
from gluon.contrib import simplejson as json
from plugin_dbui import (DBUI,
get_all_tables,
JSONEncoder,
to_jsonstore,
to_model,
to_treeNodes,
......@@ -108,7 +106,7 @@ def dbui_conf():
# build the dictionary required by Ext.direct
# containing the definition of the remote procedure
for (k, f) in directSvc.procedures.iteritems():
action, method = k.split('.')
action, method = k.split(".")
if action == DBUI:
nargs = f.func_code.co_argcount
......@@ -118,42 +116,42 @@ def dbui_conf():
if action not in di:
di[action] = []
di[action].append({'name': method, 'len': nargs})
di[action].append({"name": method, "len": nargs})
# the definition of the models
config = {'models': {},
'stores': {},
'treeNodes': [],
'viewport': None}
config = {"models": {},
"stores": {},
"treeNodes": [],
"viewport": None}
for table in get_all_tables(db):
config['models'][table._tablename] = to_model(table)
config["models"][table._tablename] = to_model(table)
# the stores configuration (static, for each table,...)
# NOTE: the interface require a store for all tables including alias.
# The only way to extract them is to scan the attributes list of
# the DAL since the method db.tables() or any variant return
# tables but not the alias one
config['stores'].update(PluginManager("dbui").dbui.static_stores)
config["stores"].update(PluginManager("dbui").dbui.static_stores)
for table in get_all_tables(db):
cfg = to_jsonstore(table)
config['stores'][cfg['storeId']] = cfg
config["stores"][cfg["storeId"]] = cfg
# the tree nodes configuration for the TreeStore
config['treeNodes'] = to_treeNodes()
config["treeNodes"] = to_treeNodes()
# the viewport configuration
config['viewport'] = to_viewport()
config["viewport"] = to_viewport()
# debug mode
debug = 'false'
if 'debug' in request.vars:
debug = 'true'
debug = "false"
if "debug" in request.vars:
debug = "true"
# fill the javascript template
app = request.application
script = API % (app,
json.dumps(config, cls=dbui.JSONEncoder),
json.dumps(config, cls=JSONEncoder),
debug,
app,
app,
......@@ -161,7 +159,7 @@ def dbui_conf():
json.dumps(di))
# return the response as a javascript
response.headers['Content-Type'] = 'text/javascript'
response.headers["Content-Type"] = "text/javascript"
return script
......@@ -175,6 +173,12 @@ def documentations_table():
"""
from plugin_dbui import get_reference_paths, Store
def path_exists(x):
return x and os.path.exists(os.path.join(apath, x))
def f(x):
return x.replace("static/", "")
plugin = PluginManager("dbui").dbui
# alias
......@@ -186,62 +190,71 @@ def documentations_table():
apath, lpath = get_reference_paths()
path_exists = lambda x: x and os.path.exists(os.path.join(apath, x))
f = lambda x: x.replace("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"))
userdoc = a % (URL("static", f(path_db_schema)), T("Data base scheme"))
pydoc = ""
path_html_api = plugin.app_html_api
if path_exists(path_html_api):
pydoc = a % (URL('static', f(path_html_api)), trPy)
pydoc = a % (URL("static", f(path_html_api)), trPy)
jsdoc = ""
path_html_jsduck = plugin.app_html_jsduck
if path_exists(path_html_jsduck):
jsdoc = a % (URL('static', f(path_html_jsduck)), trJS)
jsdoc = a % (URL("static", f(path_html_jsduck)), trJS)
# configuration of the Ext.data.Store for the documentation
cfg = Store()
cfg.fields = [dict(name='code', type='string'),
dict(name='developer', type='string'),
dict(name='python', type='string'),
dict(name='javascript', type='string')]
r1 = dict(code=request.application,
developer=userdoc,
python=pydoc,
javascript=jsdoc)
r2 = dict(code=a % ("https://marprod.in2p3.fr/plugin_dbui_book", "plugin_dbui"),
developer=a % (URL('static', 'plugin_dbui/docs/reference/index.html'), trDev),
python=a % (URL('static', 'plugin_dbui/docs/api/index.html'), trPy),
javascript=a % (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),
javascript="")
r4 = dict(code=a % ("http://www.sencha.com/products/extjs/", "Ext JS"),
developer="",
python="",
javascript=a % ("http://docs.sencha.com/extjs/6.0.1-classic/", trJS))
r5 = dict(code=a % ("http://www.mathjax.org/", "MathJax"),
developer="",
python="",
javascript=a % ("http://docs.mathjax.org/", trJS))
r6 = dict(code=a % ("http://ace.c9.io/#nav=about", "Ace"),
developer="",
python="",
javascript=a % ("http://ace.c9.io/#nav=api", trJS))
cfg.fields = [
dict(name="code", type="string"),
dict(name="developer", type="string"),
dict(name="python", type="string"),
dict(name="javascript", type="string")]
r1 = dict(
code=request.application,
developer=userdoc,
python=pydoc,
javascript=jsdoc)
r2 = dict(
code=a % ("https://marprod.in2p3.fr/plugin_dbui_book", "plugin_dbui"),
developer=a %
(URL("static", "plugin_dbui/docs/reference/index.html"), trDev),
python=a % (URL("static", "plugin_dbui/docs/api/index.html"), trPy),
javascript=a %
(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),
javascript="")
r4 = dict(
code=a % ("http://www.sencha.com/products/extjs/", "Ext JS"),
developer="",
python="",
javascript=a % ("http://docs.sencha.com/extjs/6.0.1-classic/", trJS))
r5 = dict(
code=a % ("http://www.mathjax.org/", "MathJax"),
developer="",
python="",
javascript=a % ("http://docs.mathjax.org/", trJS))
r6 = dict(
code=a % ("http://ace.c9.io/#nav=about", "Ace"),
developer="",
python="",
javascript=a % ("http://ace.c9.io/#nav=api", trJS))
cfg.data = [r1, r2, r3, r4, r5, r6]
......@@ -249,33 +262,38 @@ def documentations_table():
# configuration of the Ext.data.Store for the source code
cfg = Store()
cfg.fields = [dict(name='code', type='string'),
dict(name='source', type='string')]
cfg.fields = [
dict(name="code", type="string"),
dict(name="source", type="string")]
src = ""
if plugin.app_git:
src = "<em>git clone %s</em>" % plugin.app_git
r1 = dict(code=request.application,
source=src)
r1 = dict(code=request.application, source=src)
r2 = dict(code="plugin_dbui",
source="<em>git clone https://gitlab.in2p3.fr/w2pext/"
"plugin_dbui.git</em>")
r2 = dict(
code="plugin_dbui",
source="<em>git clone https://gitlab.in2p3.fr/w2pext/"
"plugin_dbui.git</em>")
r3 = dict(code="Web2py",
source="<em>git clone https://github.com/web2py/web2py.git</em>")
r3 = dict(
code="Web2py",
source="<em>git clone https://github.com/web2py/web2py.git</em>")
r4 = dict(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)
r4 = dict(
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)
r5 = dict(code="MathJax",
source="<em>git clone http://github.com/mathjax/MathJax</em>")
r5 = dict(
code="MathJax",
source="<em>git clone http://github.com/mathjax/MathJax</em>")
r6 = dict(code="Ace",
source="<em>git clone git://github.com/ajaxorg/ace.git</em>")
r6 = dict(
code="Ace",
source="<em>git clone git://github.com/ajaxorg/ace.git</em>")
cfg.data = [r1, r2, r3, r4, r5, r6]
......@@ -340,34 +358,34 @@ def index():
# css
for plg in plugins_paths:
path =plugins_paths[plg]["css"]
if path is not None:
lst.extend(get_file_paths(path, ext='.css'))
path = plugins_paths[plg]["css"]
if path is not None:
lst.extend(get_file_paths(path, ext=".css"))
lst.extend(get_file_paths(plugin.app_css, ext='.css'))
lst.extend(get_file_paths(plugin.app_css, ext=".css"))
# javascript libraries
# depend on the debug mode either minified or full version
key = ("debug" if is_debug else "libmin")
for plg in plugins_paths:
path =plugins_paths[plg][key]
if path is not None:
path = plugins_paths[plg][key]
if path is not None:
if plg == "extjs":
lst.extend(get_file_paths(path, ext='.js', alpha=False))
lst.extend(get_file_paths(path, ext=".js", alpha=False))
else:
lst.extend(get_file_paths(path, ext='.js'))
lst.extend(get_file_paths(path, ext=".js"))
path = (plugin.app_debug if is_debug else plugin.app_libmin)
lst.extend(get_file_paths(path, ext='.js'))
lst.extend(get_file_paths(path, ext=".js"))
# language
for plg in plugins_paths:
path =plugins_paths[plg]["lg"]
if path is not None:
lst.extend(get_file_paths(path, ext='.js'))
path = plugins_paths[plg]["lg"]
if path is not None:
lst.extend(get_file_paths(path, ext=".js"))
lst.extend(get_file_paths(plugin.app_lg, ext='.js'))
lst.extend(get_file_paths(plugin.app_lg, ext=".js"))
# URL for dbui configuration script
path = (plugin.dbui_conf_debug if is_debug else plugin.dbui_conf)
......@@ -388,7 +406,7 @@ def index():
'<link rel="stylesheet" type="text/css" href="%s"/>\n\t\t' % el
else:
fwlib += \
'<script type="text/javascript" src="%s"></script>\n\t\t' %el
'<script type="text/javascript" src="%s"></script>\n\t\t' % el
return dict(fwlib=fwlib)
......@@ -406,32 +424,32 @@ def latex2pdf():
# create the latex file in the private directory
cwd = os.getcwd()
os.chdir(os.path.join(request.folder, 'private'))
os.chdir(os.path.join(request.folder, "private"))
fn = str(uuid4())
fi = open('%s.tex' % fn, 'wb')
fi = open("%s.tex" % fn, "wb")
fi.write(latex_string)
fi.close()
# convert the latex file into pdf
# run latex twice for longtable, ...
cmd = ['pdflatex', '-interaction', 'nonstopmode', '%s.tex' % fn]
cmd = ["pdflatex", "-interaction", "nonstopmode", "%s.tex" % fn]
call(cmd, stdout=TemporaryFile())
call(cmd, stdout=TemporaryFile())
# clean latex processing
for ext in ('aux', 'log', 'tex'):
f = '%s.%s' % (fn, ext)
for ext in ("aux", "log", "tex"):
f = "%s.%s" % (fn, ext)
if os.path.exists(f):
os.remove(f)
# dummy pdf if latex processing failed
pdf = '%s.pdf' % fn
pdf = "%s.pdf" % fn
if not os.path.exists(pdf):
return 'Empty PDF file since LaTeX processing failed.'
return "Empty PDF file since LaTeX processing failed."
# copy the pdf file into a string an clean
fi = open(pdf, 'rb')
fi = open(pdf, "rb")
pdf_string = fi.read()
fi.close()
......@@ -451,14 +469,14 @@ def versions():
"""Return the versions of the different part of the code.
"""
from plugin_dbui import get_versions, Store
from plugin_dbui import get_versions, JSONEncoder, Store
# the configuration for the Ext.data.Store
cfg = Store()
cfg.fields = [dict(name='code', type='string'),
dict(name='version', type='string')]
cfg.fields = [dict(name="code", type="string"),
dict(name="version", type="string")]
cfg.data = get_versions()
return dict(cfg_store=json.dumps(cfg, cls=dbui.JSONEncoder))
return dict(cfg_store=json.dumps(cfg, cls=JSONEncoder))
......@@ -8,7 +8,7 @@ def index():
"""Main Controller handling report.
"""
return 'Report section'
return "Report section"
def report_1():
......@@ -38,7 +38,7 @@ def report_3():
"""
selector = Selector(virtdb.harvester_selector)
response.view = 'reports/report_2.html'
response.view = "reports/report_2.html"
return dict(test=selector.as_dict())
......@@ -53,13 +53,13 @@ def report_4():
cfg = Store()
cfg.fields = [dict(name='controller', type='string'),
dict(name='host', type='string'),
dict(name='collections', type='string'),
dict(name='ratio', type='number')]
cfg.fields = [dict(name="controller", type="string"),
dict(name="host", type="string"),
dict(name="collections", type="string"),
dict(name="ratio", type="number")]
if selector.grouping or selector.grouping_summary:
cfg.groupField = 'controller'
cfg.groupField = "controller"
cfg.data = []