Skip to content

Commit

Permalink
progress on linking buildbot and buildbot-www with pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Nov 29, 2012
1 parent 4ec9b92 commit fe695ef
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 285 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -79,7 +79,7 @@ It's OK to schedule a build on a builder that's not implemented by a running mas

* Remaining parts of buildbot-www package (after which much of this section is complete):

* Replace `update_js` with use of entry points to find buildbot-www package
* remove `extra_js` support (replaced by extra python packages)
* support multiple entry points for easy user extensions
* ensure tests run either from `built/` or `src/` of buildbot-www
* verify licensing on all bundled projects
Expand Down
4 changes: 0 additions & 4 deletions master/buildbot/scripts/create_master.py
Expand Up @@ -24,7 +24,6 @@
from buildbot.master import BuildMaster
from buildbot import config as config_module
from buildbot import monkeypatches
from buildbot.scripts.update_js import updateJS

def makeBasedir(config):
if os.path.exists(config['basedir']):
Expand Down Expand Up @@ -143,9 +142,6 @@ def createMaster(config):
makeSampleConfig(config)
makePublicHtml(config)
makeTemplatesDir(config)
if updateJS(config) != 0:
defer.returnValue(1)
return
yield createDB(config)

if not config['quiet']:
Expand Down
12 changes: 0 additions & 12 deletions master/buildbot/scripts/runner.py
Expand Up @@ -133,16 +133,6 @@ def postOptions(self):
raise usage.UsageError("log-count parameter needs to be an int "+
" or None")

class UpdateJSOptions(base.BasedirMixin, base.SubcommandOptions):
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, with no "
"JS optimization (UNIX only)"],
]
def getSynopsis(self):
return "Usage: buildbot update_js [<basedir>]"

class StopOptions(base.BasedirMixin, base.SubcommandOptions):
subcommandFunction = "buildbot.scripts.stop.stop"
optFlags = [
Expand Down Expand Up @@ -660,8 +650,6 @@ class Options(usage.Options):
"Create and populate a directory for a new buildmaster"],
['upgrade-master', None, UpgradeMasterOptions,
"Upgrade an existing buildmaster directory for the current version"],
['updatejs', None, UpdateJSOptions,
"update the js directory from buildbot sources, and minify the js"],
['start', None, StartOptions,
"Start a buildmaster"],
['stop', None, StopOptions,
Expand Down
205 changes: 0 additions & 205 deletions master/buildbot/scripts/update_js.py

This file was deleted.

2 changes: 0 additions & 2 deletions master/buildbot/scripts/upgrade_master.py
Expand Up @@ -26,7 +26,6 @@
from buildbot.master import BuildMaster
from buildbot.util import in_reactor
from buildbot.scripts import base
from buildbot.scripts.update_js import updateJS

def checkBasedir(config):
if not config['quiet']:
Expand Down Expand Up @@ -167,7 +166,6 @@ def upgradeMaster(config, _noMonkey=False):
return

upgradeFiles(config)
yield updateJS(config, master_cfg)
yield upgradeDatabase(config, master_cfg)

if not config['quiet']:
Expand Down
1 change: 0 additions & 1 deletion master/buildbot/test/unit/test_scripts_create_master.py
Expand Up @@ -25,7 +25,6 @@

def mkconfig(**kwargs):
config = dict(force=False, relocatable=False, config='master.cfg',
skip_updatejs = True,
db='sqlite:///state.sqlite', basedir=os.path.abspath('basedir'),
quiet=False, **{'no-logrotate':False, 'log-size':'10000000',
'log-count':'10'})
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/test/unit/test_scripts_upgrade_master.py
Expand Up @@ -25,7 +25,7 @@
from buildbot.test.util import dirs, misc, compat

def mkconfig(**kwargs):
config = dict(quiet=False, replace=False, basedir='test', skip_updatejs=True)
config = dict(quiet=False, replace=False, basedir='test')
config.update(kwargs)
return config

Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/test/unit/test_www_service.py
Expand Up @@ -81,8 +81,8 @@ def check(_):
self.assertEqual(self.svc.port, None)
return d

def test_setup_site(self):
self.svc.setup_site(self.makeConfig())
def test_setupSite(self):
self.svc.setupSite(self.makeConfig())
site = self.svc.site

# check that it has the right kind of resources attached to its
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/test/unit/test_www_ui.py
Expand Up @@ -20,7 +20,7 @@
class Test(www.WwwTestMixin, unittest.TestCase):
def test_render(self):
master = self.make_master(url='h:/a/b/')
rsrc = ui.UIResource(master, extra_routes=[])
rsrc = ui.UIResource(master, extra_routes=[], index_html='base_url:"h:/a/b/"')

d = self.render_resource(rsrc, [''])
@d.addCallback
Expand Down
8 changes: 0 additions & 8 deletions master/buildbot/www/__init__.py
@@ -1,8 +0,0 @@
try:
from buildbot_www import static_dir, index_html
except ImportError:
print "Please install the 'buildbot_www' package, either from pypi or from the buildbot source tree"
print "this package contains optimized javascript code for the buildbot ui"
import sys
sys.exit(1)
__all__ = [static_dir, index_html]
22 changes: 17 additions & 5 deletions master/buildbot/www/service.py
Expand Up @@ -14,11 +14,12 @@
# Copyright Buildbot Team Members

import os
import pkg_resources
from twisted.internet import defer
from twisted.application import strports, service
from twisted.web import server, static
from buildbot import config
from buildbot.www import ui, resource, rest, ws, static_dir
from buildbot.www import ui, resource, rest, ws

class WWWService(config.ReconfigurableServiceMixin, service.MultiService):

Expand All @@ -45,7 +46,7 @@ def reconfigService(self, new_config):
need_new_site = True

if need_new_site:
self.setup_site(new_config)
self.setupSite(new_config)

if www['port'] != self.port:
if self.port_service:
Expand All @@ -64,10 +65,21 @@ def reconfigService(self, new_config):
yield config.ReconfigurableServiceMixin.reconfigService(self,
new_config)

def setup_site(self, new_config):

def setupSite(self, new_config):
# use pkg_resources to find buildbot_www; this will eventually allow
# multiple entry points and join them together via some magic (TODO)
# TODO: run this at config time and detect the error there
entry_points = list(pkg_resources.iter_entry_points('buildbot.www'))
if len(entry_points) < 1:
raise RuntimeError("could not find buildbot-www; is it installed?")
elif len(entry_points) > 1:
raise RuntimeError("only one buildbot.www entry point is supported")
ep = entry_points[0].load()

public_html = self.site_public_html = new_config.www.get('public_html')
root = static.File(public_html)
static_node = static.File(static_dir)
static_node = static.File(ep.static_dir)
root.putChild('static', static_node)
extra_js = self.site_extra_js = new_config.www.get('extra_js', [])
extra_routes = []
Expand All @@ -85,7 +97,7 @@ def setup_site(self, new_config):
root.putChild('', resource.RedirectResource(self.master, 'ui/'))

# /ui
root.putChild('ui', ui.UIResource(self.master, extra_routes))
root.putChild('ui', ui.UIResource(self.master, extra_routes, ep.index_html))

# /api
root.putChild('api', rest.RestRootResource(self.master))
Expand Down

0 comments on commit fe695ef

Please sign in to comment.