summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-08-22 12:07:04 +0100
committerRichard Wall <richard@aziz>2010-08-22 12:07:04 +0100
commita6d2d76abf5b5e601fc5512929ef5d7efb217641 (patch)
tree41d139081b8a56030d144180a048f6e222c3dfa9
parent5c9261912a5d3f66d0edec02b1fb003b5d20629b (diff)
Fix a log error and correct import in stub script
-rwxr-xr-xbin/build-apidocs2
-rw-r--r--jarmonbuild/__init__.py0
-rw-r--r--jarmonbuild/commands.py27
3 files changed, 23 insertions, 6 deletions
diff --git a/bin/build-apidocs b/bin/build-apidocs
index a4ff988..37a6bd2 100755
--- a/bin/build-apidocs
+++ b/bin/build-apidocs
@@ -5,6 +5,6 @@ import sys
# Add the current branch to the python path
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
-from jarmonbuild import BuildApidocsCommand
+from jarmonbuild.commands import BuildApidocsCommand
raise SystemExit(BuildApidocsCommand().main())
diff --git a/jarmonbuild/__init__.py b/jarmonbuild/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/jarmonbuild/__init__.py
diff --git a/jarmonbuild/commands.py b/jarmonbuild/commands.py
index e78a78e..2c43caa 100644
--- a/jarmonbuild/commands.py
+++ b/jarmonbuild/commands.py
@@ -1,9 +1,9 @@
import hashlib
import os
+import shutil
import sys
from subprocess import check_call
-from tempfile import gettempdir
from urllib2 import urlopen
from zipfile import ZipFile
@@ -11,6 +11,9 @@ from zipfile import ZipFile
YUIDOC_URL = 'http://yuilibrary.com/downloads/yuidoc/yuidoc_1.0.0b1.zip'
YUIDOC_MD5 = 'cd5545d2dec8f7afe3d18e793538162c'
+class BuildError(Exception):
+ pass
+
class BuildApidocsCommand(object):
def __init__(self, stdout=sys.stdout, stderr=sys.stderr):
self.stdout = stdout
@@ -20,10 +23,15 @@ class BuildApidocsCommand(object):
self.stderr.write(''.join((message, newline)))
def main(self, argv=sys.argv):
+ workingbranch_dir = os.path.join(os.path.dirname(__file__), '..')
+
# setup working dir
- tmpdir = os.path.join(gettempdir(), 'jarmonbuild')
+ tmpdir = os.path.join(workingbranch_dir, 'build')
if not os.path.isdir(tmpdir):
+ self.log('Creating working dir: %s' % (workingbranch_dir,))
os.mkdir(tmpdir)
+ else:
+ self.log('Using working dir: %s' % (workingbranch_dir,))
# download and cache yuidoc
yuizip_path = os.path.join(tmpdir, os.path.basename(YUIDOC_URL))
@@ -50,16 +58,22 @@ class BuildApidocsCommand(object):
for bytes in producer():
checksum.update(bytes)
- if checksum.hexdigest() != YUIDOC_MD5:
- sys.log('checksum mismatch')
+ actual_md5 = checksum.hexdigest()
+ if actual_md5 != YUIDOC_MD5:
+ raise BuildError(
+ 'YUI Doc checksum error. '
+ 'Expected: %s, Got: %s' % (YUIDOC_MD5, actual_md5))
+ else:
+ self.log('YUI Doc checksum verified')
# extract yuidoc folder from the downloaded zip file
zip = ZipFile(yuizip_path)
+ self.log('Extracting YUI Doc')
zip.extractall(
tmpdir, (m for m in zip.namelist() if m.startswith('yuidoc')))
- workingbranch_dir = os.path.join(os.path.dirname(__file__), '..')
# Use the yuidoc script that we just extracted to generate new docs
+ self.log('Running YUI Doc')
check_call((
sys.executable,
os.path.join(tmpdir, 'yuidoc', 'bin', 'yuidoc.py'),
@@ -73,3 +87,6 @@ class BuildApidocsCommand(object):
'--project=Jarmon',
'--projecturl=http://www.launchpad.net/jarmon'
))
+
+ self.log('Removing working dir: %s' % (tmpdir,))
+ shutil.rmtree(tmpdir)