aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/utils/oe/misc.py
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2014-07-31 13:55:24 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-11 10:52:14 +0100
commita10bbd39eee29cc49d258bf08aaec279c3115c66 (patch)
tree8b21d530659ab6672bab3a630c2a8b59d2836ef1 /scripts/lib/mic/utils/oe/misc.py
parent3ae32d0d6c7cf8294300f32d346da36748e05f3d (diff)
downloadopenembedded-core-contrib-a10bbd39eee29cc49d258bf08aaec279c3115c66.tar.gz
wic: Make exec_cmd() error out instead of warn
The reason exec_cmd() warns but doesn't error out (broken parted) doesn't really make sense, since the parted invocations don't even use exec_cmd(). It really should just fail since by not doing so it's actually enabling invalid images in some cases. Also, since the return code is now always zero, there's no point in having a return code, so remove it. This represents a change in the API, so we also need to update all callers. Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Diffstat (limited to 'scripts/lib/mic/utils/oe/misc.py')
-rw-r--r--scripts/lib/mic/utils/oe/misc.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/scripts/lib/mic/utils/oe/misc.py b/scripts/lib/mic/utils/oe/misc.py
index 16c250aa9f..bed275090d 100644
--- a/scripts/lib/mic/utils/oe/misc.py
+++ b/scripts/lib/mic/utils/oe/misc.py
@@ -28,13 +28,13 @@
from mic import msger
from mic.utils import runner
-def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
+def __exec_cmd(cmd_and_args, as_shell = False, catch = 3):
"""
Execute command, catching stderr, stdout
Need to execute as_shell if the command uses wildcards
"""
- msger.debug("exec_cmd: %s" % cmd_and_args)
+ msger.debug("__exec_cmd: %s" % cmd_and_args)
args = cmd_and_args.split()
msger.debug(args)
@@ -43,24 +43,31 @@ def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
else:
rc, out = runner.runtool(args, catch)
out = out.strip()
- msger.debug("exec_cmd: output for %s (rc = %d): %s" % \
- (cmd_and_args, rc, out))
+ msger.debug("__exec_cmd: output for %s (rc = %d): %s" % \
+ (cmd_and_args, rc, out))
+
+ return (rc, out)
+
+
+def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
+ """
+ Execute command, catching stderr, stdout
+
+ Exits if rc non-zero
+ """
+ rc, out = __exec_cmd(cmd_and_args, as_shell, catch)
if rc != 0:
- # We don't throw exception when return code is not 0, because
- # parted always fails to reload part table with loop devices. This
- # prevents us from distinguishing real errors based on return
- # code.
- msger.warning("WARNING: %s returned '%s' instead of 0" % (cmd_and_args, rc))
+ msger.error("exec_cmd: %s returned '%s' instead of 0" % (cmd_and_args, rc))
- return (rc, out)
+ return out
def exec_cmd_quiet(cmd_and_args, as_shell = False):
"""
Execute command, catching nothing in the output
- Need to execute as_shell if the command uses wildcards
+ Exits if rc non-zero
"""
return exec_cmd(cmd_and_args, as_shell, 0)
@@ -82,7 +89,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch = 3):
args = cmd_and_args.split()
msger.debug(args)
- rc, out = exec_cmd(native_cmd_and_args, True, catch)
+ rc, out = __exec_cmd(native_cmd_and_args, True, catch)
if rc == 127: # shell command-not-found
msger.error("A native (host) program required to build the image "
@@ -135,7 +142,7 @@ def find_bitbake_env_lines(image_name):
bitbake_env_cmd = "bitbake -e %s" % image_name
else:
bitbake_env_cmd = "bitbake -e"
- rc, bitbake_env_lines = exec_cmd(bitbake_env_cmd)
+ rc, bitbake_env_lines = __exec_cmd(bitbake_env_cmd)
if rc != 0:
print "Couldn't get '%s' output." % bitbake_env_cmd
return None