Skip to content

Commit

Permalink
better error handling for update-js failure in create-master
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Nov 18, 2012
1 parent 02a5432 commit b090f7b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
4 changes: 3 additions & 1 deletion master/buildbot/scripts/create_master.py
Expand Up @@ -143,7 +143,9 @@ def createMaster(config):
makeSampleConfig(config)
makePublicHtml(config)
makeTemplatesDir(config)
yield updateJS(config)
if updateJS(config) != 0:
defer.returnValue(1)
return
yield createDB(config)

if not config['quiet']:
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/scripts/runner.py
Expand Up @@ -132,7 +132,7 @@ def postOptions(self):
" or None")

class UpdateJSOptions(base.BasedirMixin, base.SubcommandOptions):
subcommandFunction = "buildbot.scripts.update_js.updateJSFunc"
subcommandFunction = "buildbot.scripts.update_js.updateJS"
optFlags = [
["quiet", "q", "Do not emit the commands being run"],
["develop", "d", "link to buildbot dir rather than copy, and dont perform javascript optimization (only work on unix)"],
Expand Down
38 changes: 20 additions & 18 deletions master/buildbot/scripts/update_js.py
Expand Up @@ -13,6 +13,7 @@
#
# Copyright Buildbot Team Members

import sys
import os, shutil
import urllib2
import zipfile
Expand Down Expand Up @@ -130,24 +131,28 @@ def downloadJSDeps(config, workdir):
"""
def minifyJS(config, www, workdir):
skip_minify = False
if os.system("java -version"):
print "you need a working version of java for dojo build system to work"
if config['develop']:
skip_minify = True

if platform.system() != "Windows" and os.system("node -v"):
print "you need a working version of node.js in your path for dojo build system to work"
elif os.system("java -version"):
print "you need a working version of java for dojo build system to work"
skip_minify = True

if config['develop']:
elif platform.system() != "Windows" and os.system("node -v"):
print "you need a working version of node.js in your path for dojo build system to work"
skip_minify = True

# Todo: need to find out the best way to distribute minified code in buildbot's sdist.
# we'll sort this out once we have more code and requirements for the whole sdist picture
# Perhaps its even only needed for large scale buildbot where we can require installation of
# node and java in the master, and where people dont care about sdists.
if skip_minify:
dest = os.path.join(workdir, "js.built")
if not os.path.isdir(dest):
print "js.built does not exist; cannot proceed"
return False
os.symlink("js", os.path.join(workdir, "js.built"))
return
return True

# create the build.js config file that dojo build system is needing
o = open(os.path.join(workdir,"js","build.js"), "w")
Expand All @@ -159,17 +164,17 @@ def minifyJS(config, www, workdir):
os.chdir(os.path.join(workdir,"js"))

# Those scripts are part of the dojo tarball that we previously downloaded
if not config['quiet']:
print "optimizing the javascript UI for better performance in %s" % (config['basedir'],)
if platform.system() == "Windows":
os.system("util/buildscripts/build.bat --bin java -p build.js --release")
else:
os.system("sh util/buildscripts/build.sh --bin node -p build.js --release")
os.rename(os.path.join(workdir,"jsrelease", "dojo"),os.path.join(workdir,"js.built"))
shutil.rmtree(os.path.join(workdir,"jsrelease"))
if not config['quiet']:
print "optimizing the javascript UI for better performance in %s" % (config['basedir'],)
pass

@defer.inlineCallbacks
return True

def updateJS(config, master_cfg=None):
if not master_cfg:
from upgrade_master import loadConfig # avoid recursive import
Expand All @@ -181,17 +186,14 @@ def updateJS(config, master_cfg=None):
workdir = os.path.join(config['basedir'], "public_html", "static.new")
olddir = os.path.join(config['basedir'], "public_html", "static.old")
static = os.path.join(config['basedir'], "public_html", "static")
yield threads.deferToThread(lambda :syncStatic(config, www, workdir, olddir))
yield threads.deferToThread(lambda :downloadJSDeps(config, workdir))
yield threads.deferToThread(lambda :minifyJS(config, www, workdir))
syncStatic(config, www, workdir, olddir)
downloadJSDeps(config, workdir)
if not minifyJS(config, www, workdir):
return 1
if os.path.exists(static):
os.rename(static, olddir)
os.rename(workdir, static)
if not config['quiet']:
print "javascript UI configured in %s" % (config['basedir'],)

defer.returnValue(0)

@in_reactor
def updateJSFunc(config):
return updateJS(config)
return 0

0 comments on commit b090f7b

Please sign in to comment.