diff options
Diffstat (limited to 'scripts/lib/mic/utils')
-rw-r--r-- | scripts/lib/mic/utils/fs_related.py | 2 | ||||
-rw-r--r-- | scripts/lib/mic/utils/oe/misc.py | 33 | ||||
-rw-r--r-- | scripts/lib/mic/utils/partitionedfs.py | 2 |
3 files changed, 22 insertions, 15 deletions
diff --git a/scripts/lib/mic/utils/fs_related.py b/scripts/lib/mic/utils/fs_related.py index dd420e88dc..182171ffd3 100644 --- a/scripts/lib/mic/utils/fs_related.py +++ b/scripts/lib/mic/utils/fs_related.py @@ -306,7 +306,7 @@ class DiskImage(Disk): # create disk image dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=1" % \ (self.image_file, blocks) - rc, out = exec_cmd(dd_cmd) + exec_cmd(dd_cmd) self.device = self.image_file 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 diff --git a/scripts/lib/mic/utils/partitionedfs.py b/scripts/lib/mic/utils/partitionedfs.py index 593cf1f317..83ce869860 100644 --- a/scripts/lib/mic/utils/partitionedfs.py +++ b/scripts/lib/mic/utils/partitionedfs.py @@ -744,7 +744,7 @@ class PartitionedMount(Mount): dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \ (source_file, self.image_file, self.sector_size, start, size) - rc, out = exec_cmd(dd_cmd) + exec_cmd(dd_cmd) def install(self, image_file): |