Commit 299d622e authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Revisit the buildVersion script.

parent 57694854
......@@ -17,4 +17,5 @@ private/
*plugin_extjs*
*plugin_mathjax*
sessions/
static/track_lhcbfrance-min.js
uploads/
......@@ -46,61 +46,101 @@ import urllib
# constants
APP = os.path.basename(os.getcwd())
CHANGELOG = 'static/CHANGELOG'
JSLIBDEBUG = 'static/track-lhcbfrance-debug.js'
JSLIBMIN = 'static/track-lhcbfrance-min.js'
DBUIJSSRC = 'static/plugin_dbui/src'
EXTJSSRC = 'static/plugin_extjs/src'
JSDOC = 'static/docs/jsduck'
JSLIBMIN = 'static/%s-min.js' % APP
JSLIBSRC = 'static/src'
HTMLDOC = 'static/docs/epydoc'
LYXDOC = 'static/docs/lyx'
PYDOC = 'static/docs/epydoc'
NOW = datetime.datetime.now()
# basic commands
JSDUCK = os.path.expandvars("$HOME/bin/jsduck")
GIT = '/usr/bin/git'
YUICOMPRESSOR = os.path.expandvars("$HOME/lib/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar")
LYX = '/usr/bin/lyx'
SENCHA = os.path.expandvars("$HOME/bin/sencha")
# message
MSG_VERSION = 'Enter the new version: '
def clean():
"""Clean the previous build.
def compile():
"""compile the javascript code and generate the minified version
of the application library.
The compiler verify that the code complied with the class model
and order the file in the proper way.
The minified library can be build in several ways, including
the Ext JS class required by the applications. In the
current version, the library contains only the application classes and
the Ext JS ones have to be loaded separately.
Several compressor can be used yui, closure compiler, ....
In the current version, the default yui compressor is used?
This operation relies on the Sencha Cmd:
http://www.sencha.com/products/sencha-cmd/download
The details documantation can be found:
http://docs.sencha.com/extjs/4.2.2/#!/guide/command
"""
for el in (JSLIBDEBUG, JSLIBMIN):
if os.path.exists(el):
os.remove(el)
print 'file', el, 'is removed.'
if not os.path.exists(SENCHA):
print '\n\tThe application sencha is missing !'
print '\tSee: http://www.sencha.com/products/sencha-cmd/download'
print '\tSkip this step.\n'
return
# clean previous build
if os.path.exists(JSLIBMIN):
os.remove(JSLIBMIN)
# Minified version of the javascript library
print '\nMinified version of the javascript library', JSLIBMIN
cwd = os.getcwd()
cmd = ["sencha", "-sdk", os.path.join(cwd, EXTJSSRC),
"compile", "-class", os.path.join(cwd, JSLIBSRC),
"exclude", "--namespace", "Ext",
"and", "concat", "--yui", os.path.join(cwd, JSLIBMIN)]
subprocess.call(cmd)
def epydoc():
"""Generate the epydoc documentation
The HTML files are located in static/docs/epydoc/
The HTML files are located in static/plugin_dbui/docs/epydoc
"""
# create the directory
if not os.path.exists(HTMLDOC):
os.makedirs(HTMLDOC)
if not os.path.exists(GIT):
print '\n\tThe application epydoc is missing !'
print '\tSkip this step.\n'
return
# inhibit the __init__.py files
# to avoid long modules path in the documentation
os.rename("__init__.py", "__init__.py.ref")
os.rename("modules/__init__.py", "modules/__init__.py.ref")
# create the directory
if not os.path.exists(PYDOC):
os.makedirs(PYDOC)
# clean the directory
for el in os.listdir(HTMLDOC):
os.remove(os.path.join(HTMLDOC, el))
cmd = ["rm", "-rf", PYDOC]
subprocess.call(cmd)
# run epydoc
cmd = ["epydoc", "--docformat", "epytext",
"--html",
"--name", "plugin_dbui",
"-o", HTMLDOC,
"--name", APP,
"-o", PYDOC,
"--parse-only",
"-v",
"modules/*.py"]
subprocess.call(cmd)
# restore the __init__.py files
os.rename("__init__.py.ref", "__init__.py")
os.rename("modules/__init__.py.ref", "modules/__init__.py")
print "HTML documentation in", HTMLDOC
print "HTML documentation in", PYDOC
def get_version():
......@@ -117,19 +157,23 @@ def git():
"""Commit and tag the current release.
"""
if not os.path.exists(GIT):
print '\n\tThe application git is missing !'
print '\tSkip this step.\n'
return
version = get_version()
# check tag in git
fi = tempfile.TemporaryFile()
subprocess.call(["git", "tag"], stdout=fi)
fi.seek(0)
if opt.git in fi.read():
print "\n\ttag %s already exit in git" % opt.git
if version in fi.read():
print "\n\ttag %s already exit in git" % version
sys.exit(1)
# modify the CHANGELOG
set_version(opt.git)
# release message
m = "Release version %s" % opt.git
m = "Release version %s" % version
# Commit the new release in git an tag it
print 'git add', CHANGELOG
......@@ -141,11 +185,76 @@ def git():
subprocess.call(cmd)
# annotated tag
print 'git tag', opt.git
cmd = ["git", "tag", "-a", opt.git, "-m", m]
print 'git tag', version
cmd = ["git", "tag", "-a", version, "-m", m]
subprocess.call(cmd)
def jsduck():
"""Generate the JavaScript documentation.
The HTML files are located in static/docs/jsduck
"""
if not os.path.exists(JSDUCK):
print '\n\tThe application jsduck is missing !'
print '\tSkip this step.\n'
return
# create the directory
if not os.path.exists(JSDOC):
os.makedirs(JSDOC)
# clean the directory
cmd = ["rm", "-rf", JSDOC]
subprocess.call(cmd)
# run JsDuck
cmd = ["jsduck", EXTJSSRC, DBUIJSSRC, JSLIBSRC, \
"--output", JSDOC, \
"--title", "%s %s" % (APP, get_version()), \
"--warnings=-all:"+EXTJSSRC]
subprocess.call(cmd)
print "JavaScript documentation in", JSDOC
def lyx():
"""Generate the Lyxdocumentation.
"""
if not os.path.exists(LYX):
print '\n\tThe application lyx is missing !'
print '\tSkip this step.\n'
return
# protection
if not os.path.exists(LYXDOC):
return
# clean previous version
for path in os.listdir(LYXDOC):
if path.endswith('.pdf'):
os.remove(os.path.join(LYXDOC, path))
# run LyX
for path in os.listdir(LYXDOC):
root, ext = os.path.splitext(path)
if ext == '.lyx':
lyx_path = os.path.join(LYXDOC, path)
pdf_path = os.path.join(LYXDOC, "%s.pdf" % root)
cmd = ["lyx",
"--export-to", "pdflatex", pdf_path,
lyx_path]
subprocess.call(cmd)
print "Lyx documentation in", LYXDOC
def set_version(version):
"""Set version identifier in CHANGELOG
......@@ -174,28 +283,9 @@ def set_version(version):
os.remove("%s~" % CHANGELOG )
def yuicompressor():
"""Compresssed and minified the javascript library.
"""
# debug version of the javascript library
print 'Debug version of the javascript library', JSLIBDEBUG
subprocess.call('cat %s/*.js > %s' % (JSLIBSRC, JSLIBDEBUG), shell=True)
# Minified version of the javascript library
print 'Minified version of the javascript library', JSLIBMIN
cmd = ["java", "-jar", YUICOMPRESSOR, "-o", JSLIBMIN, JSLIBDEBUG]
subprocess.call(cmd)
if __name__ == '__main__':
# check that basic commands are there
for cmd in (GIT, YUICOMPRESSOR):
if not os.path.exists(cmd):
print '\n\t%s application is missing !' % cmd
sys.exit(1)
# define script options
ops = optparse.OptionParser()
......@@ -204,10 +294,10 @@ if __name__ == '__main__':
dest= "all",
help= "run all steps.")
ops.add_option("-c", "--clean",
ops.add_option("-c", "--compile",
action="store_true",
dest= "clean",
help= "clean build files and exit.")
dest="compile",
help="compile the javascript library using sencha command.")
ops.add_option("-e", "--epydoc",
action="store_true",
......@@ -215,57 +305,83 @@ if __name__ == '__main__':
help= "generate the epydoc documentation.")
ops.add_option("-g", "--git",
action="store_true",
dest= "git",
help= "commit and tag the current release.")
ops.add_option("-j", "--jsduck",
action="store_true",
dest= "jsduck",
help= "generate the JavaScript documentation.")
ops.add_option("-l", "--lyx",
action="store_true",
dest= "lyx",
help= "generate the lyx documentation (guides).")
ops.add_option("-r", "--release",
action="store_true",
dest= "get",
help= "get the tag of the current release and exit.")
ops.add_option("-y", "--yuicompressor",
ops.add_option("-s", "--set_version",
action="store_true",
dest= "yuicompressor",
help= "compressed and minified the javascript libraries.")
dest= "set",
help= "set the version.")
ops.set_defaults(all=False,
clean=False,
compile=False,
epydoc=False,
get=False,
git=None,
yuicompressor=False)
git=False,
jsduck=False,
lyx=False,
set=False)
(opt, args) = ops.parse_args()
# the version of the current release
print '\nStart buildVersion'
# standalone action
if opt.get:
version = get_version()
print "\nThe version of the current release is %s\n" % version
sys.exit(0)
# run all steps
if opt.all:
opt.clean = True
opt.epydoc = True
opt.git = True
opt.yuicompressor = True
# process
print '\nStart buildVersion'
if opt.clean:
clean()
sys.exit(0)
if opt.set:
version = (args[0] if args else raw_input(MSG_VERSION))
set_version(version)
if opt.git:
git()
if opt.epydoc:
epydoc()
if opt.jsduck:
jsduck()
if opt.lyx:
lyx()
if opt.yuicompressor:
yuicompressor()
if opt.git:
if opt.compile:
compile()
# run all steps
if opt.all:
version = get_version()
print "\nThe version of the current release is %s\n" % version
version = (args[0] if args else raw_input(MSG_VERSION))
set_version(version)
git()
epydoc()
jsduck()
lyx()
compile()
print 'Exit buidVersion\n'
sys.exit(0)
\ No newline at end of file
......@@ -18,7 +18,7 @@ from my_validators import IS_IN_USET
plugins = PluginManager()
plugins.dbui.app_css = 'static/my.css'
plugins.dbui.app_debug = 'static/src'
plugins.dbui.app_libmin = plugins.dbui.app_debug
plugins.dbui.app_libmin = 'static/%s-min.js' % request.application
plugins.dbui.app_lg = 'static/local/myapp-lang-fr.js'
plugins.dbui.app_script = 'static/app.js'
# plugins.dbui.app_script_dir = None
......
......@@ -235,7 +235,7 @@ class Report(SelectorActiveItems):
- the sum of fte for the items in the group
- the average age for the items in the group
@type grouby: str
@type groupby: str
@param groupby: database field encoded as C{tablename.fieldname}
@rtype: list of dictionary
......@@ -287,7 +287,7 @@ class Report(SelectorActiveItems):
- the sum of fte for the items in the group
- the average age for the items in the group
@type grouby: str
@type groupby: str
@param groupby: database field encoded as C{tablename.fieldname}.
@type metric: str
......
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