Commit 62d993bf authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch 'master' into 'production'

Release 1.0

See merge request !46
parents 72ed79ce 5c7bede4
# -*- coding: utf-8 -*-
"""
Configure the build process for the plugin dbui
"""
import datetime
import os
import re
import tempfile
from subprocess import call, check_output
from IPython.utils.io import stderr
NOW = datetime.datetime.now()
# ............................................................................
#
# JAVASCRIPT LIBRARY
# JavaScript source code and compile version
# paths are relative to the static directory
#
SENCHA_CLS = [
"plugin_extjs/packages/core/src",
"plugin_extjs/classic/classic/src",
"plugin_extjs/classic/classic/overrides",
"plugin_dbui/src"]
SENCHA_NS = "Ext"
JSLIBDEBUG = "plugin_dbui/dbui-debug.js"
JSLIBMIN = "plugin_dbui/dbui-min.js"
# ...........................................................................
#
# DOCUMENTATION
# output directories for documentation
# paths are relative to the static directory
#
DOCS_DIR = "plugin_dbui/docs"
JSDOC = "plugin_dbui/docs/jsduck"
LATEXDOC = "plugin_dbui/docs/latex"
PDFDOC = "plugin_dbui/docs/pdf"
# ...........................................................................
#
# PLUGINS
# ace, dbui, extjs and mathjax
# paths are relative to the application directory
#
PLUGINS_FILES = {}
PLUGINS_FILES["default"] = [
"controllers/plugin_%s.py",
"models/plugin_%s.py",
"modules/plugin_%s",
"private/plugin_%s",
"static/plugin_%s",
"views/plugin_%s"]
PLUGINS_FILES["ace"] = [
"static/plugin_ace/src-noconflict/",
"static/plugin_ace/src-min-noconflict/ace.js",
"static/plugin_ace/src-min-noconflict/mode-javascript.js",
"static/plugin_ace/src-min-noconflict/mode-json.js",
"static/plugin_ace/src-min-noconflict/mode-markdown.js",
"static/plugin_ace/src-min-noconflict/mode-python.js",
"static/plugin_ace/src-min-noconflict/mode-text.js",
"static/plugin_ace/src-min-noconflict/theme-crimson_editor.js",
"static/plugin_ace/src-min-noconflict/worker-javascript.js",
"static/plugin_ace/src-min-noconflict/worker-json.js",
"static/plugin_ace/src-min-noconflict/snippets/javascript.js",
"static/plugin_ace/src-min-noconflict/snippets/json.js",
"static/plugin_ace/src-min-noconflict/snippets/markdown.js",
"static/plugin_ace/src-min-noconflict/snippets/python.js",
"static/plugin_ace/src-min-noconflict/snippets/text.js"]
PLUGINS_FILES["dbui"] = [
"modules/plugin_dbui",
"controllers/plugin_dbui.py",
"static/plugin_dbui",
"views/plugin_dbui"]
PLUGINS_FILES["extjs"] = [
"static/plugin_extjs/build/classic/locale",
"static/plugin_extjs/build/classic/theme-classic",
"static/plugin_extjs/build/ext-all.js",
"static/plugin_extjs/build/ext-all-debug.js",
"static/plugin_extjs/classic/classic/src",
"static/plugin_extjs/classic/classic/overrides",
"static/plugin_extjs/packages/core/src",
"static/plugin_extjs/version.properties"]
PLUGINS_FILES["mathjax"] = [
"static/plugin_mathjax/fonts/HTML-CSS/TeX/woff",
"static/plugin_mathjax/jax",
"static/plugin_mathjax/extensions",
"static/plugin_mathjax/MathJax.js"]
# ............................................................................
#
# REFERENCE FILES
#
CHANGELOG = "static/plugin_dbui/CHANGELOG"
DBUIJS = "static/plugin_dbui/src/Dbui.js"
VERSION = "VERSION"
def commit_release():
"""Commit release CHANGELOG, VERSION and DBUIJS files
"""
print "\n", "."*79
print "\n\tCommit CHANGELOG, DBUIJS, VERSION, ..."
# move to the master branch
with tempfile.TemporaryFile() as fi:
print "\tMove to the master branch"
call(["git", "checkout", "master"], stdout=fi, stderr=fi)
# Commit modified files
print "\n\tgit add", DBUIJS, CHANGELOG, VERSION
call(["git", "add", DBUIJS, CHANGELOG, VERSION])
msg = "Start release candidate %s" % get_version()
print "\tgit commit:", msg
call(["git", "commit", "-m", msg])
def get_plugin_version(plugin):
"""
Args:
plugin (str): name of the plugin
Return:
str: the plugin version
"""
if plugin == "ace":
cwd = os.getcwd()
os.chdir("static/plugin_ace")
with tempfile.TemporaryFile() as tmpfile:
call(["git", "describe", "--tags"], stdout=tmpfile)
tmpfile.seek(0)
release = tmpfile.read()
release = release.replace("v", "").replace("\n", "")
os.chdir(cwd)
elif plugin == "dbui":
with open(VERSION, "rb") as tmpfile:
release = tmpfile.read()
elif plugin == "extjs":
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:
s = fi.read()
match = re.search(r"version.release=(\d+(\.\d+)*)", s)
if not match:
error("\n\tExt JS release number not defined !")
sys.exit(1)
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])
elif plugin == "mathjax":
filename = os.path.join("static", "plugin_mathjax", "MathJax.js")
with open(filename, "rb") as tmpfile:
text = tmpfile.read()
match = re.match(r'.+MathJax.version="(\d+(\.\d+)*)";', text, re.DOTALL)
if not match:
error("\n\tMathJax release number not defined !")
sys.exit(1)
release = match.group(1)
else:
error("\n\tUnknown plugin %" % plugin)
sys.exit(1)
release = release.replace(".", "")
if len(release) == 2:
release = "%s0" % release
return release
def get_version():
"""Get the current release identifier in VERSION.
Returns:
str: the version number
"""
with open(VERSION, "rb") as fi:
return fi.read()
def set_version(version):
"""Set release identifier in CHANGELOG, VERSION and Dbui.js
Args:
version (str): release identifier
"""
print "\n", "."*79
print "\tUpdate CHANGELOG and Dbui.js files with release", version, "..."
# check tag in git
if version in check_output(["git", "tag"]).split("\n"):
print "\n\tRelease %s already exit in git" % version
sys.exit(1)
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
# split the the string in 3 parts (pre, version, post)
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 !"
print msg % version
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:
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
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"):
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
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:
fi.write(version)
# cleaning
fn = "%s~" % CHANGELOG
if os.path.exists(fn):
os.remove(fn)
...@@ -105,13 +105,13 @@ def dbui_conf(): ...@@ -105,13 +105,13 @@ def dbui_conf():
# build the dictionary required by Ext.direct # build the dictionary required by Ext.direct
# containing the definition of the remote procedure # containing the definition of the remote procedure
for (k, f) in directSvc.procedures.iteritems(): for k, f in directSvc.procedures.items():
action, method = k.split(".") action, method = k.split(".")
if action == DBUI: if action == DBUI:
nargs = f.func_code.co_argcount nargs = f.__code__.co_argcount
else: else:
nargs = f.__func__.func_code.co_argcount - 1 nargs = f.__func__.__code__.co_argcount - 1
if action not in di: if action not in di:
di[action] = [] di[action] = []
...@@ -424,41 +424,36 @@ def latex2pdf(): ...@@ -424,41 +424,36 @@ def latex2pdf():
# create the latex file in the private directory # create the latex file in the private directory
cwd = os.getcwd() cwd = os.getcwd()
os.chdir(os.path.join(request.folder, "private")) os.chdir("/tmp")
fn = str(uuid4()) fn = str(uuid4())
fi = open("%s.tex" % fn, "wb") fi = open("%s.tex" % fn, "w")
fi.write(latex_string) fi.write(latex_string)
fi.close() fi.close()
# convert the latex file into pdf # convert the latex file into PDF
# run latex twice for longtable, ... # 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())
call(cmd, stdout=TemporaryFile()) call(cmd, stdout=TemporaryFile())
# clean latex processing # clean latex processing
for ext in ("aux", "log", "tex"): for ext in ("aux", "log", "out", "tex"):
f = "%s.%s" % (fn, ext) f = "%s.%s" % (fn, ext)
if os.path.exists(f): if os.path.exists(f):
os.remove(f) os.remove(f)
# dummy pdf if latex processing failed # inform user when latex processing failed
pdf = "%s.pdf" % fn pdf = "%s.pdf" % fn
if not os.path.exists(pdf): 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")
pdf_string = fi.read()
fi.close()
os.remove(pdf)
# go back to the web2py main directory # go back to the web2py main directory
os.chdir(cwd) os.chdir(cwd)
return dict(data=pdf_string) # download the PDF file
path_pdf = os.path.join("/tmp", pdf)
return response.stream(path_pdf)
def status(): def status():
......
plugin_dbui.validator.IS_IN_USET
================================
.. currentmodule:: plugin_dbui.validator
.. autoclass:: IS_IN_USET
:show-inheritance:
.. rubric:: Methods
# -*- coding: utf-8 -*-
# #
# plugin_dbui documentation build configuration file, created by # plugin_dbui documentation build configuration file, created by
# sphinx-quickstart on Sat Apr 11 11:17:03 2015. # sphinx-quickstart on Sat Apr 11 11:17:03 2015.
...@@ -16,28 +15,26 @@ import re ...@@ -16,28 +15,26 @@ import re
import sys import sys
from datetime import datetime from datetime import datetime
from pathlib import Path
def get_plugin_dbui_release():
JSBASE = "../../static/plugin_dbui/src/Dbui.js" def get_version():
s = open(JSBASE, "rb").read() return Path("../../../VERSION").read_text()
m = re.match('(.+ version: ")([\w._-]*)(".+)', s, re.DOTALL)
return m.group(2)
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath(".")) # sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("../../modules")) sys.path.insert(0, os.path.abspath("../../../modules"))
# docker image # web2py module from the my docker image running sphinx-build
if os.path.exists("/opt/web2py"): if os.path.exists("/opt/web2py"):
sys.path.insert(0, os.path.abspath("/opt/web2py")) sys.path.insert(0, os.path.abspath("/opt/web2py"))
# older running environment
else: else:
sys.path.insert(0, os.path.abspath("../../../web2py")) print("error: missing source code for web2py!!!")
sys.exit(1)
# -- General configuration ----------------------------------------------------- # -- General configuration -----------------------------------------------------
...@@ -55,10 +52,10 @@ extensions = ["sphinx.ext.autodoc", ...@@ -55,10 +52,10 @@ extensions = ["sphinx.ext.autodoc",
"sphinx.ext.viewcode"] "sphinx.ext.viewcode"]
# autosummary configuration # autosummary configuration
autosummary_generate = False autosummary_generate = True
# intersphinx configuration # intersphinx configuration
intersphinx_mapping = {"python": ("http://docs.python.org/2.7", None)} intersphinx_mapping = {"python": ("http://docs.python.org/3.7", None)}
# napoleon configuration # napoleon configuration
napoleon_user_rtype = False napoleon_user_rtype = False
...@@ -77,15 +74,15 @@ master_doc = "index" ...@@ -77,15 +74,15 @@ master_doc = "index"
# General information about the project. # General information about the project.
now = datetime.now() now = datetime.now()
project = u"plugin_dbui" project = "plugin_dbui"
copyright = u"2009-%s, R. Le Gac, licensed under CeCILL" % now.year copyright = "2009-%s, R. Le Gac, licensed under CeCILL" % now.year
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = get_plugin_dbui_release() release = get_version()
# The short X.Y version. # The short X.Y version.
version = release[:release.rfind(".")] version = release[:release.rfind(".")]
...@@ -221,8 +218,8 @@ latex_elements = { ...@@ -221,8 +218,8 @@ latex_elements = {
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]). # (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [ latex_documents = [
("index", "plugin_dbui.tex", u"plugin\\_dbui Documentation", ("index", "plugin_dbui_api.tex", r"plugin\_dbui API Guide",
u"R. Le Gac", "manual"), "R. Le Gac", "manual"),
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
...@@ -251,8 +248,8 @@ latex_documents = [ ...@@ -251,8 +248,8 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
("index", "plugin_dbui", u"plugin_dbui Documentation", ("index", "plugin_dbui_api", "plugin_dbui Documentation",
[u"R. Le Gac"], 1) ["R. Le Gac"], 1)
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
...@@ -265,8 +262,8 @@ man_pages = [ ...@@ -265,8 +262,8 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
("index", "plugin_dbui", u"plugin_dbui Documentation", ("index", "plugin_dbui_api", "plugin_dbui Documentation",
u"R. Le Gac", "plugin_dbui", "One line description of project.", "R. Le Gac", "plugin_dbui", "One line description of project.",
"Miscellaneous"), "Miscellaneous"),
] ]
......
...@@ -32,13 +32,3 @@ Filters ...@@ -32,13 +32,3 @@ Filters
CLEAN_COMMA CLEAN_COMMA
CLEAN_SPACES CLEAN_SPACES
Validators
^^^^^^^^^^
.. currentmodule:: plugin_dbui.validator
.. autosummary::
:toctree: generated/
IS_IN_USET
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
Links to the Ext JS classes Links to the Ext JS classes
.. _ExtJS: http://docs-origin.sencha.com/extjs/4.2.1/#!/api .. _ExtJS: https://docs.sencha.com/extjs/6.2.0/classic
.. _Ext.data.ArrayStore: .. _Ext.data.ArrayStore:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.ArrayStore https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.ArrayStore.html
.. _Ext.form.field.Checkbox: .. _Ext.form.field.Checkbox:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Checkbox https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Checkbox.html
.. _Dbui.form.field.CombBox: .. _Dbui.form.field.CombBox:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.CombBox https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.CombBox
...@@ -17,16 +17,16 @@ ...@@ -17,16 +17,16 @@
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.data.DirectStore https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.data.DirectStore
.. _Ext.form.field.Field: .. _Ext.form.field.Field:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Field https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Field.html
.. _Dbui.form.field.AceEditor: .. _Dbui.form.field.AceEditor:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.AceEditor https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.AceEditor
.. _Ext.form.FieldContainer: .. _Ext.form.FieldContainer:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.FieldContainer https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.FieldContainer.html
.. _Ext.form.field.Date: .. _Ext.form.field.Date:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Date https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Date.html
.. _Dbui.form.field.Dict: .. _Dbui.form.field.Dict:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.Dict https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.Dict
...@@ -35,28 +35,28 @@ ...@@ -35,28 +35,28 @@
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.List https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.List
.. _Ext.form.field.Number: .. _Ext.form.field.Number:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Number