yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00549
[Merge] lp:~frankban/charms/oneiric/buildbot-master/add-repositories into lp:~yellow/charms/oneiric/buildbot-master/trunk
Francesco Banconi has proposed merging lp:~frankban/charms/oneiric/buildbot-master/add-repositories into lp:~yellow/charms/oneiric/buildbot-master/trunk.
Requested reviews:
Launchpad Yellow Squad (yellow)
For more details, see:
https://code.launchpad.net/~frankban/charms/oneiric/buildbot-master/add-repositories/+merge/95613
== Changes ==
- Fixed install_extra_repository
- Using the version of `run` helper (ported from python-shell-toolbox)
--
https://code.launchpad.net/~frankban/charms/oneiric/buildbot-master/add-repositories/+merge/95613
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~frankban/charms/oneiric/buildbot-master/add-repositories into lp:~yellow/charms/oneiric/buildbot-master/trunk.
=== modified file 'hooks/install'
--- hooks/install 2012-03-02 10:59:48 +0000
+++ hooks/install 2012-03-02 16:37:21 +0000
@@ -8,14 +8,21 @@
import subprocess
-def run(*args):
+def run(*args, **kwargs):
"""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.
+ The first argument is the path to the command to run.
+ Subsequent arguments are command-line arguments to be passed.
+
+ This function accepts all optional keyword arguments accepted by
+ `subprocess.Popen`.
"""
- process = subprocess.Popen(args, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, close_fds=True)
+ args = [i for i in args if i is not None]
+ pipe = subprocess.PIPE
+ process = subprocess.Popen(
+ args, stdout=kwargs.pop('stdout', pipe),
+ stderr=kwargs.pop('stderr', pipe),
+ close_fds=kwargs.pop('close_fds', True), **kwargs)
stdout, stderr = process.communicate()
if process.returncode:
raise subprocess.CalledProcessError(
@@ -52,12 +59,16 @@
def install_extra_repository(extra_repository):
+ distribution = run('lsb_release', '-cs').strip()
+ # Starting from Oneiric, the `apt-add-repository` is interactive by
+ # default, and requires a "-y" flag to be set.
+ assume_yes = None if distribution == 'lucid' else '-y'
try:
- run('apt-add-repository', extra_repository)
+ run('apt-add-repository', assume_yes, extra_repository)
run('apt-get', 'update')
except subprocess.CalledProcessError as e:
log('Error adding repository: ' + extra_repository)
- log(e)
+ log(str(e))
raise
Follow ups