summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2018-10-26 10:09:51 +0000
committerBenjamin Schubert <ben.c.schubert@gmail.com>2018-10-26 10:09:51 +0000
commitf131c40712225f530dc99a908b6ffd699196bf15 (patch)
treea8ff565ecbf288691b78b2ef161a1ee6f8fb1476
parent494d7018ec16f90bb917b3fe0cbbc4d8893febec (diff)
parent80762ecbfd61f85dfb43b1a25c060d78fd28f261 (diff)
downloadbuildstream-f131c40712225f530dc99a908b6ffd699196bf15.tar.gz
Merge branch 'bschubert/fix-command-sandbox' into 'master'
Check is command is a str and replace by list before checking existence Closes #728 See merge request BuildStream/buildstream!898
-rw-r--r--buildstream/sandbox/_sandboxbwrap.py8
-rw-r--r--buildstream/sandbox/_sandboxchroot.py8
-rw-r--r--buildstream/sandbox/_sandboxdummy.py4
3 files changed, 12 insertions, 8 deletions
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index fe429abe8..066932f5c 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -66,15 +66,15 @@ class SandboxBwrap(Sandbox):
cwd = self._get_work_directory(cwd=cwd)
env = self._get_environment(cwd=cwd, env=env)
+ # Convert single-string argument to a list
+ if isinstance(command, str):
+ command = [command]
+
if not self._has_command(command[0], env):
raise SandboxError("Staged artifacts do not provide command "
"'{}'".format(command[0]),
reason='missing-command')
- # We want command args as a list of strings
- if isinstance(command, str):
- command = [command]
-
# Create the mount map, this will tell us where
# each mount point needs to be mounted from and to
mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)
diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py
index aeba25137..e63a4f237 100644
--- a/buildstream/sandbox/_sandboxchroot.py
+++ b/buildstream/sandbox/_sandboxchroot.py
@@ -57,15 +57,15 @@ class SandboxChroot(Sandbox):
cwd = self._get_work_directory(cwd=cwd)
env = self._get_environment(cwd=cwd, env=env)
+ # Convert single-string argument to a list
+ if isinstance(command, str):
+ command = [command]
+
if not self._has_command(command[0], env):
raise SandboxError("Staged artifacts do not provide command "
"'{}'".format(command[0]),
reason='missing-command')
- # Command must be a list
- if isinstance(command, str):
- command = [command]
-
stdout, stderr = self._get_output()
# Create the mount map, this will tell us where
diff --git a/buildstream/sandbox/_sandboxdummy.py b/buildstream/sandbox/_sandboxdummy.py
index 29ff4bf69..c0a86a0bb 100644
--- a/buildstream/sandbox/_sandboxdummy.py
+++ b/buildstream/sandbox/_sandboxdummy.py
@@ -33,6 +33,10 @@ class SandboxDummy(Sandbox):
cwd = self._get_work_directory(cwd=cwd)
env = self._get_environment(cwd=cwd, env=env)
+ # Convert single-string argument to a list
+ if isinstance(command, str):
+ command = [command]
+
if not self._has_command(command[0], env):
raise SandboxError("Staged artifacts do not provide command "
"'{}'".format(command[0]),