summaryrefslogtreecommitdiffstats
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:53:08 +0100
commit68e6adf2df70c3f83d67dc869b3ce989a6902b80 (patch)
treea650dc42d1ae3db2bd7cf3219a252306376d34e5 /scripts/lib/mic/utils/oe/misc.py
parent963604605c0eff8c5b6ca6614b6c5fba8ae4dd15 (diff)
downloadpoky-68e6adf2df70c3f83d67dc869b3ce989a6902b80.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. (From OE-Core rev: a10bbd39eee29cc49d258bf08aaec279c3115c66) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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 @@
28from mic import msger 28from mic import msger
29from mic.utils import runner 29from mic.utils import runner
30 30
31def exec_cmd(cmd_and_args, as_shell = False, catch = 3): 31def __exec_cmd(cmd_and_args, as_shell = False, catch = 3):
32 """ 32 """
33 Execute command, catching stderr, stdout 33 Execute command, catching stderr, stdout
34 34
35 Need to execute as_shell if the command uses wildcards 35 Need to execute as_shell if the command uses wildcards
36 """ 36 """
37 msger.debug("exec_cmd: %s" % cmd_and_args) 37 msger.debug("__exec_cmd: %s" % cmd_and_args)
38 args = cmd_and_args.split() 38 args = cmd_and_args.split()
39 msger.debug(args) 39 msger.debug(args)
40 40
@@ -43,24 +43,31 @@ def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
43 else: 43 else:
44 rc, out = runner.runtool(args, catch) 44 rc, out = runner.runtool(args, catch)
45 out = out.strip() 45 out = out.strip()
46 msger.debug("exec_cmd: output for %s (rc = %d): %s" % \ 46 msger.debug("__exec_cmd: output for %s (rc = %d): %s" % \
47 (cmd_and_args, rc, out)) 47 (cmd_and_args, rc, out))
48
49 return (rc, out)
50
51
52def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
53 """
54 Execute command, catching stderr, stdout
55
56 Exits if rc non-zero
57 """
58 rc, out = __exec_cmd(cmd_and_args, as_shell, catch)
48 59
49 if rc != 0: 60 if rc != 0:
50 # We don't throw exception when return code is not 0, because 61 msger.error("exec_cmd: %s returned '%s' instead of 0" % (cmd_and_args, rc))
51 # parted always fails to reload part table with loop devices. This
52 # prevents us from distinguishing real errors based on return
53 # code.
54 msger.warning("WARNING: %s returned '%s' instead of 0" % (cmd_and_args, rc))
55 62
56 return (rc, out) 63 return out
57 64
58 65
59def exec_cmd_quiet(cmd_and_args, as_shell = False): 66def exec_cmd_quiet(cmd_and_args, as_shell = False):
60 """ 67 """
61 Execute command, catching nothing in the output 68 Execute command, catching nothing in the output
62 69
63 Need to execute as_shell if the command uses wildcards 70 Exits if rc non-zero
64 """ 71 """
65 return exec_cmd(cmd_and_args, as_shell, 0) 72 return exec_cmd(cmd_and_args, as_shell, 0)
66 73
@@ -82,7 +89,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch = 3):
82 args = cmd_and_args.split() 89 args = cmd_and_args.split()
83 msger.debug(args) 90 msger.debug(args)
84 91
85 rc, out = exec_cmd(native_cmd_and_args, True, catch) 92 rc, out = __exec_cmd(native_cmd_and_args, True, catch)
86 93
87 if rc == 127: # shell command-not-found 94 if rc == 127: # shell command-not-found
88 msger.error("A native (host) program required to build the image " 95 msger.error("A native (host) program required to build the image "
@@ -135,7 +142,7 @@ def find_bitbake_env_lines(image_name):
135 bitbake_env_cmd = "bitbake -e %s" % image_name 142 bitbake_env_cmd = "bitbake -e %s" % image_name
136 else: 143 else:
137 bitbake_env_cmd = "bitbake -e" 144 bitbake_env_cmd = "bitbake -e"
138 rc, bitbake_env_lines = exec_cmd(bitbake_env_cmd) 145 rc, bitbake_env_lines = __exec_cmd(bitbake_env_cmd)
139 if rc != 0: 146 if rc != 0:
140 print "Couldn't get '%s' output." % bitbake_env_cmd 147 print "Couldn't get '%s' output." % bitbake_env_cmd
141 return None 148 return None