Merge lp:~frankban/charms/oneiric/buildbot-master/add-repositories into lp:~yellow/charms/oneiric/buildbot-master/trunk

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 39
Proposed branch: lp:~frankban/charms/oneiric/buildbot-master/add-repositories
Merge into: lp:~yellow/charms/oneiric/buildbot-master/trunk
Diff against target: 47 lines (+18/-7)
1 file modified
hooks/install (+18/-7)
To merge this branch: bzr merge lp:~frankban/charms/oneiric/buildbot-master/add-repositories
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+95613@code.launchpad.net

Description of the change

== Changes ==

- Fixed install_extra_repository
- Using the version of `run` helper (ported from python-shell-toolbox)

To post a comment you must log in.
40. By Francesco Banconi

Fixed comment.

Revision history for this message
Benji York (benji) wrote :

Looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/install'
--- hooks/install 2012-03-02 10:59:48 +0000
+++ hooks/install 2012-03-02 17:10:23 +0000
@@ -8,14 +8,21 @@
8import subprocess8import subprocess
99
1010
11def run(*args):11def run(*args, **kwargs):
12 """Run the command with the given arguments.12 """Run the command with the given arguments.
1313
14 The first argument is the path to the command to run, subsequent arguments14 The first argument is the path to the command to run.
15 are command-line arguments to be passed.15 Subsequent arguments are command-line arguments to be passed.
16
17 This function accepts all optional keyword arguments accepted by
18 `subprocess.Popen`.
16 """19 """
17 process = subprocess.Popen(args, stdout=subprocess.PIPE,20 args = [i for i in args if i is not None]
18 stderr=subprocess.PIPE, close_fds=True)21 pipe = subprocess.PIPE
22 process = subprocess.Popen(
23 args, stdout=kwargs.pop('stdout', pipe),
24 stderr=kwargs.pop('stderr', pipe),
25 close_fds=kwargs.pop('close_fds', True), **kwargs)
19 stdout, stderr = process.communicate()26 stdout, stderr = process.communicate()
20 if process.returncode:27 if process.returncode:
21 raise subprocess.CalledProcessError(28 raise subprocess.CalledProcessError(
@@ -52,12 +59,16 @@
5259
5360
54def install_extra_repository(extra_repository):61def install_extra_repository(extra_repository):
62 distribution = run('lsb_release', '-cs').strip()
63 # Starting from Oneiric, `apt-add-repository` is interactive by
64 # default, and requires a "-y" flag to be set.
65 assume_yes = None if distribution == 'lucid' else '-y'
55 try:66 try:
56 run('apt-add-repository', extra_repository)67 run('apt-add-repository', assume_yes, extra_repository)
57 run('apt-get', 'update')68 run('apt-get', 'update')
58 except subprocess.CalledProcessError as e:69 except subprocess.CalledProcessError as e:
59 log('Error adding repository: ' + extra_repository)70 log('Error adding repository: ' + extra_repository)
60 log(e)71 log(str(e))
61 raise72 raise
6273
6374

Subscribers

People subscribed via source and target branches