Commit 6cc06a90 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch 'master' into 'production'

Release 0.9.0

* Change the name space for the JavaScript code from `App` to `Dbui`.
* Fix the LaTeX conversion for special character.

See merge request !25
parents fe0ebd19 643f6e49
*~ *~
.directory
.project .project
*.pyc *.pyc
.pydevproject .pydevproject
......
...@@ -55,7 +55,7 @@ The packed version of the `plugin_dbui` and its friends can be obtained using ...@@ -55,7 +55,7 @@ The packed version of the `plugin_dbui` and its friends can be obtained using
the versioning tool [git](http://git-scm.com/): the versioning tool [git](http://git-scm.com/):
``` ```
git clone https://gitlab.in2p3.fr/legac/plugin_dbui_build.git git clone https://gitlab.in2p3.fr/w2pext/plugins.git
``` ```
* Install the `plugin_dbui` in your application using the `web2py` * Install the `plugin_dbui` in your application using the `web2py`
......
0.8.3 0.9.0
\ No newline at end of file \ No newline at end of file
...@@ -45,12 +45,14 @@ import urllib ...@@ -45,12 +45,14 @@ import urllib
from os.path import join as opj from os.path import join as opj
from subprocess import call, check_output, CalledProcessError from subprocess import call, check_output, CalledProcessError
from numexpr.version import release from tempfile import TemporaryFile
import cmd
# constants # constants
APP = os.path.basename(os.getcwd()) APP = os.path.basename(os.getcwd())
API = 'api' API = 'api'
BUILDDIR = '../plugin_dbui_build' BUILDDIR = '../plugins'
DOCSRC = 'docs' DOCSRC = 'docs'
LATEX = 'latex' LATEX = 'latex'
MSG_RELEASE = 'Enter the new release: ' MSG_RELEASE = 'Enter the new release: '
...@@ -70,7 +72,7 @@ CHANGELOG = opj(APP_STATIC, "plugin_dbui", "CHANGELOG") ...@@ -70,7 +72,7 @@ CHANGELOG = opj(APP_STATIC, "plugin_dbui", "CHANGELOG")
DOCS_DIR = opj(APP_STATIC, "plugin_dbui", "docs") DOCS_DIR = opj(APP_STATIC, "plugin_dbui", "docs")
DBUISRC = opj(APP_STATIC, "plugin_dbui", "src") DBUISRC = opj(APP_STATIC, "plugin_dbui", "src")
EXTJSSRC = opj(APP_STATIC, "plugin_extjs", "src") EXTJSSRC = opj(APP_STATIC, "plugin_extjs", "src")
JSBASE = opj(APP_STATIC, "plugin_dbui", "src", "App.js") JSBASE = opj(APP_STATIC, "plugin_dbui", "src", "Dbui.js")
JSDOC = opj(DOCS_DIR, "jsduck") JSDOC = opj(DOCS_DIR, "jsduck")
JSLIBDEBUG = opj(APP_STATIC, "plugin_dbui", "dbui-debug.js") JSLIBDEBUG = opj(APP_STATIC, "plugin_dbui", "dbui-debug.js")
JSLIBMIN = opj(APP_STATIC, "plugin_dbui", "dbui-min.js") JSLIBMIN = opj(APP_STATIC, "plugin_dbui", "dbui-min.js")
...@@ -169,8 +171,11 @@ def build(): ...@@ -169,8 +171,11 @@ def build():
""" """
compile_js() compile_js()
build_html()
if os.path.exists(DOCS_DIR):
call(["rm", "-rf", DOCS_DIR])
build_html()
for doc in (API, REFERENCE, USER): for doc in (API, REFERENCE, USER):
build_pdf(doc) build_pdf(doc)
...@@ -228,25 +233,29 @@ def build_pdf(doc): ...@@ -228,25 +233,29 @@ def build_pdf(doc):
filenames = [el for el in os.listdir('.') if el.endswith('.tex')] filenames = [el for el in os.listdir('.') if el.endswith('.tex')]
filename = (filenames[0] if len(filenames) == 1 else None) filename = (filenames[0] if len(filenames) == 1 else None)
fpdf = filename.replace('.tex', '.pdf')
if not filename: if not filename:
print "\n\tNo latex file !\n" print "\n\tNo latex file !\n"
os.chdir(cwd)
return return
try: try:
check_output(["pdflatex", "-interaction", "nonstopmode", filename]) check_output(["pdflatex", "-interaction", "nonstopmode", filename])
check_output(["pdflatex", filename])
except CalledProcessError: except CalledProcessError:
if os.path.exists(fpdf):
print "\n\tSome errors in the PDF file."
else:
print "\n\tFailled to generate PDF file !" print "\n\tFailled to generate PDF file !"
print "\tCheck LaTeX file in", latexdir, "\n" print "\tCheck LaTeX file in", latexdir, "\n"
os.chdir(cwd)
return return
check_output(["pdflatex", filename])
os.chdir(cwd) os.chdir(cwd)
# rename the pdf file as application_doctype.pdf # rename the pdf file as application_doctype.pdf
fpdf = filename.replace('.tex', '.pdf')
fout = "%s_%s.pdf" % (os.path.splitext(filename)[0], doc) fout = "%s_%s.pdf" % (os.path.splitext(filename)[0], doc)
os.rename(opj(latexdir, fpdf), opj(PDFDOC, fout)) os.rename(opj(latexdir, fpdf), opj(PDFDOC, fout))
...@@ -361,10 +370,10 @@ def build_plugin_mathjax(): ...@@ -361,10 +370,10 @@ def build_plugin_mathjax():
def commit_change_log(): def commit_change_log():
"""Commit CHANGELOG and App.js. """Commit CHANGELOG and Dbui.js.
""" """
print "Commit CHANGELOG and App.js..." print "Commit CHANGELOG and Dbui.js..."
if not which("git", localhost=True): if not which("git", localhost=True):
print '\n\tThe application git is missing !' print '\n\tThe application git is missing !'
print '\tSkip this step.\n' print '\tSkip this step.\n'
...@@ -447,11 +456,6 @@ def compile_js(): ...@@ -447,11 +456,6 @@ def compile_js():
JSLIBDEBUG_CNT, JSLIBDEBUG_CNT,
JSLIBMIN_CNT) JSLIBMIN_CNT)
cmd = ["docker", "exec", ARGS.docker_container,
"chown", get_perm(), JSLIBDEBUG_CNT, JSLIBMIN_CNT]
call(cmd)
print '\n\tDebug version of the js library', JSLIBDEBUG, 'is ready' print '\n\tDebug version of the js library', JSLIBDEBUG, 'is ready'
print '\tMinimised version of the js library', JSLIBMIN, 'is ready\n' print '\tMinimised version of the js library', JSLIBMIN, 'is ready\n'
...@@ -481,7 +485,7 @@ def get_plugin_version(plugin): ...@@ -481,7 +485,7 @@ def get_plugin_version(plugin):
os.chdir(cwd) os.chdir(cwd)
elif plugin == "dbui": elif plugin == "dbui":
filename = os.path.join('static', 'plugin_dbui', 'src', 'App.js') filename = os.path.join('static', 'plugin_dbui', 'src', 'Dbui.js')
tmpfile = open(filename, 'rb') tmpfile = open(filename, 'rb')
text = tmpfile.read() text = tmpfile.read()
...@@ -535,19 +539,6 @@ def get_plugin_version(plugin): ...@@ -535,19 +539,6 @@ def get_plugin_version(plugin):
return release return release
def get_perm():
""""Return the permission of the current user.
Returns:
str: permission encoded as uid:gid
"""
uid = check_output(["id", "-u"]).strip("\n")
gid = check_output(["id", "-g"]).strip("\n")
return "%s:%s" % (uid, gid)
def get_version(): def get_version():
"""Get the current version identifier. """Get the current version identifier.
...@@ -594,7 +585,7 @@ def is_plugin(plugin): ...@@ -594,7 +585,7 @@ def is_plugin(plugin):
bool: true when the plugin exist. bool: true when the plugin exist.
""" """
path = os.path.join('static', 'plugin_%s' % plugin) path = os.path.join("static", "plugin_%s" % plugin)
if not os.path.exists(path): if not os.path.exists(path):
print "\n\tNo source file for the plugin %s !" % plugin print "\n\tNo source file for the plugin %s !" % plugin
...@@ -621,9 +612,13 @@ def jsduck(): ...@@ -621,9 +612,13 @@ def jsduck():
return return
# clean # clean
if os.path.exists(JSDOC):
print "\n\tRemove old javascript documentation...\n" print "\n\tRemove old javascript documentation...\n"
call(["rm", "-rf", JSDOC]) call(["rm", "-rf", JSDOC])
if not os.path.exists(DOCS_DIR):
os.mkdir(DOCS_DIR)
# NOTE # NOTE
# the processing depend on the localisation of jsduck # the processing depend on the localisation of jsduck
# either on the localhost or behind a docker container # either on the localhost or behind a docker container
...@@ -652,20 +647,17 @@ def jsduck(): ...@@ -652,20 +647,17 @@ def jsduck():
call(cmd) call(cmd)
cnt = ARGS.docker_container
call(["docker", "exec", cnt, "chown", "-R", get_perm(), JSDOC_CNT])
print "\n\tJavaScript documentation in", JSDOC print "\n\tJavaScript documentation in", JSDOC
def set_version(version): def set_version(version):
"""Set release identifier in CHANGELOG and App.js """Set release identifier in CHANGELOG and Dbui.js
Args: Args:
version (str): release identifier version (str): release identifier
""" """
print "Update CHANGELOG and App.js files with the release", version, "..." print "Update CHANGELOG and Dbui.js files with the release", version, "..."
# check tag in git # check tag in git
if version in check_output(["git", "tag"]).split("\n"): if version in check_output(["git", "tag"]).split("\n"):
...@@ -676,7 +668,7 @@ def set_version(version): ...@@ -676,7 +668,7 @@ def set_version(version):
with open(JSBASE) as fi: with open(JSBASE) as fi:
txt = fi.read() txt = fi.read()
# look for a pattern App.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) # 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)
...@@ -789,17 +781,13 @@ def sphinx(builder, doc): ...@@ -789,17 +781,13 @@ def sphinx(builder, doc):
cmd.extend(["-b", builder, "-q", srcdir, outdir]) cmd.extend(["-b", builder, "-q", srcdir, outdir])
call(cmd) call(cmd)
if is_behind_cnt:
cnt = ARGS.docker_container
call(["docker", "exec", cnt, "chown", "-R", get_perm(), outdir])
print "\n\t%s documentation in" % builder.upper(), outdir print "\n\t%s documentation in" % builder.upper(), outdir
def start_release(): def start_release():
"""Start the release cycle. """Start the release cycle.
Set the new release number in the CHANGELOG and App.js files. Set the new release number in the CHANGELOG and Dbui.js files.
Commit then in the master branch. Commit then in the master branch.
""" """
...@@ -883,6 +871,11 @@ def which(cmd, localhost=False): ...@@ -883,6 +871,11 @@ def which(cmd, localhost=False):
"""Test if the command exists on the localhost or on a docker container. """Test if the command exists on the localhost or on a docker container.
Return the sequence to execute it. Priority is given to the localhost. Return the sequence to execute it. Priority is given to the localhost.
Note:
* The command is execute as the user me when running via a container
* The user me is the one running the scrip build_version and w2pcnt
* The user me is added when the container is created
Args: Args:
cmd (str): name of the command cmd (str): name of the command
localhost (bool): force the command to be on localhost even if localhost (bool): force the command to be on localhost even if
...@@ -893,10 +886,13 @@ def which(cmd, localhost=False): ...@@ -893,10 +886,13 @@ def which(cmd, localhost=False):
The list is empty when the command is not found. The list is empty when the command is not found.
""" """
container = OPT.docker_container
# local host # local host
if not ARGS.force_container or localhost: if not container or localhost:
try: try:
out = check_output(["which", cmd]) with TemporaryFile() as fi:
out = check_output(["which", cmd], stderr=fi)
print "\n\tCommand", cmd, "found on the localhost" print "\n\tCommand", cmd, "found on the localhost"
return [out.strip("\n")] return [out.strip("\n")]
...@@ -905,7 +901,6 @@ def which(cmd, localhost=False): ...@@ -905,7 +901,6 @@ def which(cmd, localhost=False):
return [] return []
# docker container is running ? # docker container is running ?
container = ARGS.docker_container
is_running = False is_running = False
for line in check_output(["docker", "ps"]).split("\n"): for line in check_output(["docker", "ps"]).split("\n"):
...@@ -916,16 +911,19 @@ def which(cmd, localhost=False): ...@@ -916,16 +911,19 @@ def which(cmd, localhost=False):
if not is_running: if not is_running:
print "\n\tDocker container", container, "is not running !" print "\n\tDocker container", container, "is not running !"
if ARGS.force_container: if OPT.force_container:
sys.exit(1) sys.exit(1)
return [] return []
# docker container # docker container
# command is executed as the user me
# the user me is the one running the script. It is created in the
# container when it is created
try: try:
out = check_output(["docker", "exec", container, "which", cmd]) out = check_output(["docker", "exec", container, "which", cmd])
path = out.strip("\n") path = out.strip("\n")
print "\n\tCommand", cmd, "found on the container", container print "\n\tCommand", cmd, "found on the container", container
return ["docker", "exec", container, path] return ["docker", "exec", "--user", "me", container, path]
except CalledProcessError: except CalledProcessError:
print "\n\tCommand", cmd, \ print "\n\tCommand", cmd, \
...@@ -953,6 +951,11 @@ if __name__ == '__main__': ...@@ -953,6 +951,11 @@ if __name__ == '__main__':
action="store_true", action="store_true",
help="build the API documentation in PDF.") help="build the API documentation in PDF.")
AGP.add_argument(
"-b", "--build",
action="store_true",
help="build javaScript libraries and documentation.")
AGP.add_argument( AGP.add_argument(
"-c", "--compile", "-c", "--compile",
action="store_true", action="store_true",
...@@ -961,7 +964,7 @@ if __name__ == '__main__': ...@@ -961,7 +964,7 @@ if __name__ == '__main__':
AGP.add_argument( AGP.add_argument(
"--commit-changelog", "--commit-changelog",
action="store_true", action="store_true",
help="commit CHANGELOG and App.js. " help="commit CHANGELOG and Dbui.js. "
"To be used with --write-release. " "To be used with --write-release. "
"Recommend to use --start-release.") "Recommend to use --start-release.")
...@@ -1016,7 +1019,7 @@ if __name__ == '__main__': ...@@ -1016,7 +1019,7 @@ if __name__ == '__main__':
"-s", "--start-release", "-s", "--start-release",
action="store_true", action="store_true",
help="start the release candidate by setting " help="start the release candidate by setting "
"release number in change log and App.js. " "release number in change log and Dbui.js. "
"Commit changes in the master branch. " "Commit changes in the master branch. "
"Equivalent to --write-release followed by " "Equivalent to --write-release followed by "
"--commit-changelog.") "--commit-changelog.")
...@@ -1054,67 +1057,70 @@ if __name__ == '__main__': ...@@ -1054,67 +1057,70 @@ if __name__ == '__main__':
AGP.add_argument( AGP.add_argument(
"--write-release", "--write-release",
action="store_true", action="store_true",
help="write the release number in CHANGELOG and App.js. " help="write the release number in CHANGELOG and Dbui.js. "
"To be used with --commit-changelog. " "To be used with --commit-changelog. "
"Recommend to use --start-release.") "Recommend to use --start-release.")
ARGS = AGP.parse_args() OPT = AGP.parse_args()
if ARGS.ace: if OPT.ace:
build_plugin_ace() build_plugin_ace()
if ARGS.api_doc: if OPT.api_doc:
sphinx("html", API) sphinx("html", API)
if ARGS.api_pdf: if OPT.api_pdf:
build_pdf(API) build_pdf(API)
if ARGS.compile: if OPT.build:
build()
if OPT.compile:
compile_js() compile_js()
if ARGS.commit_changelog: if OPT.commit_changelog:
commit_change_log() commit_change_log()
if ARGS.dbui: if OPT.dbui:
build() build()
build_plugin_dbui() build_plugin_dbui()
if ARGS.extjs: if OPT.extjs:
build_plugin_extjs() build_plugin_extjs()
if ARGS.jsduck: if OPT.jsduck:
jsduck() jsduck()
if ARGS.mathjax: if OPT.mathjax:
build_plugin_mathjax() build_plugin_mathjax()
if ARGS.reference_doc: if OPT.reference_doc:
sphinx("html", REFERENCE) sphinx("html", REFERENCE)
if ARGS.reference_pdf: if OPT.reference_pdf:
build_pdf(REFERENCE) build_pdf(REFERENCE)
if ARGS.start_release: if OPT.start_release:
start_release() start_release()
if ARGS.tag: if OPT.tag:
tag() tag()
if ARGS.user_doc: if OPT.user_doc:
sphinx("html", USER) sphinx("html", USER)
if ARGS.user_pdf: if OPT.user_pdf:
build_pdf(USER) build_pdf(USER)
if ARGS.version: if OPT.version:
print "\nThe current release is %s\n" % get_version() print "\nThe current release is %s\n" % get_version()
if ARGS.web2py: if OPT.web2py:
if ARGS.web2py == "dbui": if OPT.web2py == "dbui":
build() build()
web2py(ARGS.web2py) web2py(OPT.web2py)
if ARGS.write_release: if OPT.write_release:
set_version(raw_input(MSG_RELEASE)) set_version(raw_input(MSG_RELEASE))
sys.exit(0) sys.exit(0)
...@@ -15,12 +15,12 @@ import os ...@@ -15,12 +15,12 @@ import os
API = """ API = """
App.csvUrl = '/%s/plugin_dbui/csv'; Dbui.csvUrl = '/%s/plugin_dbui/csv';
App.config = %s; Dbui.config = %s;
App.debug = %s; Dbui.debug = %s;
App.latex2pdfUrl = '/%s/plugin_dbui/latex2pdf.pdf'; Dbui.latex2pdfUrl = '/%s/plugin_dbui/latex2pdf.pdf';
App.name = '%s'; Dbui.name = '%s';
App.REMOTE_API = { Dbui.REMOTE_API = {
'url': '/%s/plugin_dbui/call', 'url': '/%s/plugin_dbui/call',
'type': 'remoting', 'type': 'remoting',
'actions': %s 'actions': %s
...@@ -305,7 +305,7 @@ def documentations(): ...@@ -305,7 +305,7 @@ def documentations():
source=src) source=src)
r2 = dict(code="plugin_dbui", r2 = dict(code="plugin_dbui",
source="<em>git clone https://gitlab.in2p3.fr/legac/" source="<em>git clone https://gitlab.in2p3.fr/w2pext/"
"plugin_dbui.git</em>") "plugin_dbui.git</em>")
r3 = dict(code="Web2py", r3 = dict(code="Web2py",
......
...@@ -19,7 +19,7 @@ from datetime import datetime ...@@ -19,7 +19,7 @@ from datetime import datetime
def get_plugin_dbui_release(): def get_plugin_dbui_release():
JSBASE = '../../static/plugin_dbui/src/App.js' JSBASE = '../../static/plugin_dbui/src/Dbui.js'
s = open(JSBASE, 'rb').read() s = open(JSBASE, 'rb').read()
m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL) m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL)
return m.group(2) return m.group(2)
......
...@@ -10,17 +10,17 @@ ...@@ -10,17 +10,17 @@
.. _Ext.form.field.Checkbox: .. _Ext.form.field.Checkbox:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Checkbox http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Checkbox
.. _App.form.field.CombBox: .. _Dbui.form.field.CombBox:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.form.field.CombBox https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.CombBox