yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00516
[Merge] lp:~bac/charms/oneiric/buildbot-slave/bbs-pst into lp:~yellow/charms/oneiric/buildbot-slave/trunk
Brad Crittenden has proposed merging lp:~bac/charms/oneiric/buildbot-slave/bbs-pst into lp:~yellow/charms/oneiric/buildbot-slave/trunk.
Requested reviews:
Launchpad Yellow Squad (yellow): code
For more details, see:
https://code.launchpad.net/~bac/charms/oneiric/buildbot-slave/bbs-pst/+merge/95280
Update the slave to account for methods migrating from helpers to shelltoolbox.
The install hook must now add the apt repository for the PPA, install the package, and ensure local and helpers are not imported until that is done since they depend on shelltoolbox. The other hooks can just import and use shelltoolbox normally since we can assume the install hook did its job.
--
https://code.launchpad.net/~bac/charms/oneiric/buildbot-slave/bbs-pst/+merge/95280
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~bac/charms/oneiric/buildbot-slave/bbs-pst into lp:~yellow/charms/oneiric/buildbot-slave/trunk.
=== modified file 'hooks/buildbot-relation-joined'
--- hooks/buildbot-relation-joined 2012-02-08 15:22:40 +0000
+++ hooks/buildbot-relation-joined 2012-02-29 22:51:22 +0000
@@ -21,8 +21,8 @@
config = get_config()
builders = config.get('builders')
if builders:
- # This is the first step of the handshake.
- send_builders(builders)
+ # This is the first step of the handshake.
+ send_builders(builders)
if __name__ == '__main__':
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2012-02-08 15:22:40 +0000
+++ hooks/config-changed 2012-02-29 22:51:22 +0000
@@ -3,11 +3,15 @@
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-from helpers import (
+from shelltoolbox import (
apt_get_install,
DictDiffer,
+ install_extra_repositories,
+ )
+import subprocess
+
+from helpers import (
get_config,
- install_extra_repository,
log,
log_entry,
log_exit,
@@ -32,7 +36,12 @@
buildbot_dir = config.get('installdir')
if extra_repo and 'extra-repository' in diff.added_or_changed:
- install_extra_repository(extra_repo)
+ try:
+ install_extra_repositories(extra_repo)
+ except subprocess.CalledProcessError as e:
+ log('Error adding repository: ' + extra_repo)
+ log(e)
+ raise
if buildbot_pkg and 'buildbot-pkg' in diff.added_or_changed:
log('Installing ' + buildbot_pkg)
=== removed symlink 'hooks/helpers.py'
=== target was u'../../buildbot-master/hooks/helpers.py'
=== modified file 'hooks/install'
--- hooks/install 2012-02-10 20:08:16 +0000
+++ hooks/install 2012-02-29 22:51:22 +0000
@@ -3,26 +3,85 @@
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
+import os
+import shlex
+import subprocess
+import sys
+import tempfile
+
+
+def run(*args):
+ """Run the command with the given arguments.
+
+ The first argument is the path to the command to run, subsequent arguments
+ are command-line arguments to be passed.
+ """
+ process = subprocess.Popen(args, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=True)
+ stdout, stderr = process.communicate()
+ if process.returncode:
+ raise subprocess.CalledProcessError(
+ process.returncode, repr(args), output=stdout+stderr)
+ return stdout
+
+
+def command(*base_args):
+ """Return a callable that will run the given command with any arguments.
+
+ The first argument is the path to the command to run, subsequent arguments
+ are command-line arguments to "bake into" the returned callable.
+
+ The callable runs the given executable and also takes arguments that will
+ be appeneded to the "baked in" arguments.
+
+ For example, this code will list a file named "foo" (if it exists):
+
+ ls_foo = command('/bin/ls', 'foo')
+ ls_foo()
+
+ While this invocation will list "foo" and "bar" (assuming they exist):
+
+ ls_foo('bar')
+ """
+ def callable_command(*args):
+ all_args = base_args + args
+ return run(*all_args)
+
+ return callable_command
+
+
+log = command('juju-log')
+apt_get_install = command('apt-get', 'install', '-y', '--force-yes')
+
+
+def install_extra_repository(extra_repository):
+ try:
+ run('apt-add-repository', extra_repository)
+ run('apt-get', 'update')
+ except subprocess.CalledProcessError as e:
+ log('Error adding repository: ' + extra_repository)
+ log(e)
+ raise
+
+
+def install_packages():
+ install_extra_repository('ppa:yellow/ppa')
+ apt_get_install('python-shell-toolbox')
+
+
+install_packages()
+
+# helpers and local depend on shelltoolbox so they cannot be imported until
+# after the python-shell-toolbox package is installed.
from helpers import (
- apt_get_install,
- command,
get_config,
- install_extra_repository,
- log,
log_entry,
log_exit,
- run,
)
from local import (
config_json,
create_slave,
)
-import os
-import shlex
-import subprocess
-import sys
-import tempfile
-
bzr = command('bzr')
=== removed symlink 'hooks/local.py'
=== target was u'../../buildbot-master/hooks/local.py'
=== removed symlink 'hooks/tests.py'
=== target was u'../../buildbot-master/hooks/tests.py'
Follow ups