summaryrefslogtreecommitdiff
path: root/jarmonbuild/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'jarmonbuild/commands.py')
-rw-r--r--jarmonbuild/commands.py150
1 files changed, 40 insertions, 110 deletions
diff --git a/jarmonbuild/commands.py b/jarmonbuild/commands.py
index d60615a..617976f 100644
--- a/jarmonbuild/commands.py
+++ b/jarmonbuild/commands.py
@@ -4,7 +4,6 @@
Functions and Classes for automating the release of Jarmon
"""
-import hashlib
import logging
import os
import shutil
@@ -15,21 +14,10 @@ import urllib
from datetime import datetime
from optparse import OptionParser
from subprocess import check_call, PIPE
-from tempfile import gettempdir
-from urllib2 import urlopen
from zipfile import ZipFile, ZIP_DEFLATED
import pkg_resources
-
-JARMON_PROJECT_TITLE = 'Jarmon'
-JARMON_PROJECT_URL = 'http://www.launchpad.net/jarmon'
-
-YUIDOC_URL = 'http://yui.zenfs.com/releases/yuidoc/yuidoc_1.0.0b1.zip'
-YUIDOC_MD5 = 'cd5545d2dec8f7afe3d18e793538162c'
-YUIDOC_DEPENDENCIES = ['setuptools', 'pygments', 'cheetah']
-
-
class BuildError(Exception):
"""
A base Exception for errors in the build system
@@ -57,7 +45,7 @@ class BuildCommand(object):
class BuildApidocsCommand(BuildCommand):
"""
- Download YUI Doc and use it to generate apidocs for jarmon
+ Generate apidocs for jarmon
"""
command_name = 'apidocs'
@@ -70,94 +58,32 @@ class BuildApidocsCommand(BuildCommand):
"""
parser = OptionParser(
- usage='build [options] %s VERSION' % (self.command_name,))
+ usage='build [options] %s VERSION [DIRECTORY]' % (self.command_name,))
parser.disable_interspersed_args()
options, args = parser.parse_args(argv)
- if len(args) != 1:
+ if len(args) != 1 and len(args) != 2:
parser.error('Wrong number of arguments. This command expects a '
- 'version number only.')
+ 'version number, and optionally a directory.')
buildversion = args[0]
- tmpdir = gettempdir()
workingbranch_dir = self.workingbranch_dir
build_dir = self.build_dir
-
- # Check for yuidoc dependencies
- for r in pkg_resources.parse_requirements(YUIDOC_DEPENDENCIES):
- if not pkg_resources.working_set.find(r):
- raise BuildError('Unsatisfied yuidoc dependency: %r' % (r,))
-
- # download and cache yuidoc
- yuizip_path = os.path.join(tmpdir, os.path.basename(YUIDOC_URL))
- if os.path.exists(yuizip_path):
- self.log.debug('Using cached YUI doc')
-
- def producer_local():
- yield open(yuizip_path).read()
-
- producer = producer_local
- else:
- self.log.debug('Downloading YUI Doc')
-
- def producer_remote():
- with open(yuizip_path, 'w') as yuizip:
- download = urlopen(YUIDOC_URL)
- while True:
- bytes = download.read(1024 * 10)
- if not bytes:
- break
- else:
- yuizip.write(bytes)
- yield bytes
-
- producer = producer_remote
-
- checksum = hashlib.md5()
- for bytes in producer():
- checksum.update(bytes)
-
- actual_md5 = checksum.hexdigest()
- if actual_md5 != YUIDOC_MD5:
- raise BuildError(
- 'YUI Doc checksum error. File: %s, '
- 'Expected: %s, '
- 'Got: %s' % (yuizip_path, YUIDOC_MD5, actual_md5))
- else:
- self.log.debug('YUI Doc checksum verified')
+ apidocs_dir = os.path.join(args[1] if len(args) == 2 else build_dir, 'docs', 'apidocs')
# Remove any existing apidocs so that we can track removed files
- shutil.rmtree(os.path.join(build_dir, 'docs', 'apidocs'), True)
-
- yuidoc_dir = os.path.join(build_dir, 'yuidoc')
-
- # extract yuidoc folder from the downloaded zip file
- self.log.debug(
- 'Extracting YUI Doc from %s to %s' % (yuizip_path, yuidoc_dir))
- zip = ZipFile(yuizip_path)
- zip.extractall(
- build_dir, (m for m in zip.namelist() if m.startswith('yuidoc')))
+ shutil.rmtree(apidocs_dir, True)
# Use the yuidoc script that we just extracted to generate new docs
- self.log.debug('Running YUI Doc')
+ self.log.debug('Running JSDoc')
check_call((
- sys.executable,
- os.path.join(yuidoc_dir, 'bin', 'yuidoc.py'),
+ 'jsdoc',
+ '-c', os.path.join(workingbranch_dir, 'jarmonbuild', 'jsdoc.json'),
+ '-r', os.path.join(workingbranch_dir, 'README'),
+ '-d', apidocs_dir,
os.path.join(workingbranch_dir, 'jarmon'),
- '--parseroutdir=%s' % (
- os.path.join(build_dir, 'docs', 'apidocs'),),
- '--outputdir=%s' % (
- os.path.join(build_dir, 'docs', 'apidocs'),),
- '--template=%s' % (
- os.path.join(
- workingbranch_dir, 'jarmonbuild', 'yuidoc_template'),),
- '--version=%s' % (buildversion,),
- '--project=%s' % (JARMON_PROJECT_TITLE,),
- '--projecturl=%s' % (JARMON_PROJECT_URL,),
- ), stdout=PIPE, stderr=PIPE,)
-
- shutil.rmtree(yuidoc_dir)
+ ),)
class BuildReleaseCommand(BuildCommand):
@@ -184,26 +110,21 @@ class BuildReleaseCommand(BuildCommand):
workingbranch_dir = self.workingbranch_dir
build_dir = self.build_dir
- self.log.debug('Export versioned files to a build folder')
- from bzrlib.commands import main as bzr_main
- status = bzr_main(['bzr', 'export', build_dir, workingbranch_dir])
- if status != 0:
- raise BuildError('bzr export failure. Status: %r' % (status,))
+ self.log.debug('Clean the build folder')
+ shutil.rmtree(build_dir, True)
+ os.mkdir(build_dir)
- self.log.debug('Record the branch version')
- from bzrlib.branch import Branch
- from bzrlib.version_info_formats import format_python
- v = format_python.PythonVersionInfoBuilder(
- Branch.open(workingbranch_dir))
+ self.log.debug('Export versioned files to a build folder')
+ check_call(('git', '--work-tree=%s' % (build_dir,), 'checkout', '-f'))
- versionfile_path = os.path.join(
- build_dir, 'jarmonbuild', '_version.py')
+ self.log.debug('Generate apidocs')
+ BuildApidocsCommand().main([buildversion, build_dir])
- with open(versionfile_path, 'w') as f:
- v.generate(f)
+ self.log.debug('Generate jsdeps')
+ BuildJavascriptDependenciesCommand().main([build_dir])
- self.log.debug('Generate apidocs')
- BuildApidocsCommand().main([buildversion])
+ self.log.debug('Generate testdata')
+ BuildTestDataCommand().main([build_dir])
self.log.debug('Generate archive')
archive_root = 'jarmon-%s' % (buildversion,)
@@ -236,7 +157,7 @@ class BuildTestDataCommand(BuildCommand):
start = int(datetime(1980, 1, 1, 0, 0).strftime('%s'))
dss = []
rras = []
- filename = os.path.join(self.build_dir, 'test.rrd')
+ filename = os.path.join(argv[0] if len(argv) > 0 else self.build_dir, 'test.rrd')
rows = 12
step = 10
@@ -276,16 +197,25 @@ class BuildJavascriptDependenciesCommand(BuildCommand):
self.log.debug('Compiling javascript dependencies')
depjs_path = os.path.join(
- self.workingbranch_dir,
+ argv[0] if len(argv) > 0 else self.workingbranch_dir,
'docs/examples/assets/js/dependencies.js')
# Get the closure params from the original file
- params = []
- for line in open(depjs_path):
- line = line.strip()
- if line.startswith('// @'):
- key, val = line.lstrip('/ @').strip().split(None, 1)
- params.append((key.strip(), val.strip()))
+ params = [
+ ('code_url', 'http://code.jquery.com/jquery-1.6.3.js'),
+ ('code_url', 'https://raw.githubusercontent.com/flot/flot/v0.7.0/excanvas.js'),
+ ('code_url', 'https://raw.githubusercontent.com/flot/flot/v0.7.0/jquery.flot.js'),
+ ('code_url', 'https://raw.githubusercontent.com/flot/flot/v0.7.0/jquery.flot.stack.js'),
+ ('code_url', 'https://raw.githubusercontent.com/flot/flot/v0.7.0/jquery.flot.selection.js'),
+ ('code_url', 'https://lukeshu.com/git/2git/javascriptrrd/plain/src/lib/rrdFile.js?id=v1.1.1'),
+ ('code_url', 'https://lukeshu.com/git/2git/javascriptrrd/plain/src/lib/binaryXHR.js?id=v1.1.1'),
+ ('code_url', 'https://raw.githubusercontent.com/jquerytools/jquerytools/8ac4636a01d3860f1c4726ba722190a531bf1068/src/tabs/tabs.js'),
+ ('code_url', 'https://raw.githubusercontent.com/jquerytools/jquerytools/8ac4636a01d3860f1c4726ba722190a531bf1068/src/toolbox/toolbox.history.js'),
+ ('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
+ ('formatting', 'print_input_delimiter'),
+ ('output_format', 'text'),
+ ('output_info', 'compiled_code'),
+ ]
# Always use the following value for the Content-type header.
headers = { "Content-type": "application/x-www-form-urlencoded" }