Merge lp:~bloodearnest/juju-deployer/run-build-cmds-in-shell into lp:juju-deployer

Proposed by Simon Davy
Status: Merged
Merged at revision: 129
Proposed branch: lp:~bloodearnest/juju-deployer/run-build-cmds-in-shell
Merge into: lp:juju-deployer
Diff against target: 51 lines (+10/-2)
3 files modified
deployer/charm.py (+1/-1)
deployer/tests/test_utils.py (+7/-0)
deployer/utils.py (+2/-1)
To merge this branch: bzr merge lp:~bloodearnest/juju-deployer/run-build-cmds-in-shell
Reviewer Review Type Date Requested Status
juju-deployers Pending
Review via email: mp+236596@code.launchpad.net

Commit message

Make a charm's build commands run in shell, rather that straight exec

Description of the change

Make a charm's build commands run in shell, rather that straight exec. This allows use of Makefiles, or parameterized scripts.

To post a comment you must log in.
128. By Simon Davy

add correct exception

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

lgtm, thanks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer/charm.py'
2--- deployer/charm.py 2014-09-29 14:36:34 +0000
3+++ deployer/charm.py 2014-09-30 19:33:11 +0000
4@@ -117,7 +117,7 @@
5 self.log.debug("Building charm %s with %s", self.path, self._build)
6 _check_call([self._build], self.log,
7 "Charm build failed %s @ %s", self._build, self.path,
8- cwd=self.path)
9+ cwd=self.path, shell=True)
10
11 def fetch(self):
12 if self._charm_url:
13
14=== modified file 'deployer/tests/test_utils.py'
15--- deployer/tests/test_utils.py 2014-09-03 13:17:33 +0000
16+++ deployer/tests/test_utils.py 2014-09-30 19:33:11 +0000
17@@ -68,6 +68,13 @@
18 # 1 failure + 3 retries
19 self.assertEquals(len(check_output.call_args_list), 3)
20
21+ def test_check_call_uses_shell(self):
22+ cmd = 'echo "foo"'
23+ self.assertRaises(
24+ OSError, _check_call, params=[cmd], log=MagicMock())
25+ output = _check_call(params=[cmd], log=MagicMock(), shell=True)
26+ self.assertEqual(output, "foo\n")
27+
28
29 class TestMkdir(Base):
30
31
32=== modified file 'deployer/utils.py'
33--- deployer/utils.py 2014-09-03 13:17:33 +0000
34+++ deployer/utils.py 2014-09-30 19:33:11 +0000
35@@ -242,6 +242,7 @@
36 def _check_call(params, log, *args, **kw):
37 max_retry = kw.get('max_retry', None)
38 cur = kw.get('cur_try', 1)
39+ shell = kw.get('shell', False)
40 try:
41 cwd = abspath(".")
42 if 'cwd' in kw:
43@@ -250,7 +251,7 @@
44 if 'stderr' in kw:
45 stderr = kw['stderr']
46 output = subprocess.check_output(
47- params, cwd=cwd, stderr=stderr, env=os.environ)
48+ params, cwd=cwd, stderr=stderr, env=os.environ, shell=shell)
49 except subprocess.CalledProcessError, e:
50 if 'ignoreerr' in kw:
51 return

Subscribers

People subscribed via source and target branches