summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/utils
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/mic/utils')
-rw-r--r--scripts/lib/mic/utils/fs_related.py2
-rw-r--r--scripts/lib/mic/utils/oe/misc.py33
-rw-r--r--scripts/lib/mic/utils/partitionedfs.py2
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):
306 # create disk image 306 # create disk image
307 dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=1" % \ 307 dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=1" % \
308 (self.image_file, blocks) 308 (self.image_file, blocks)
309 rc, out = exec_cmd(dd_cmd) 309 exec_cmd(dd_cmd)
310 310
311 self.device = self.image_file 311 self.device = self.image_file
312 312
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
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):
744 744
745 dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \ 745 dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \
746 (source_file, self.image_file, self.sector_size, start, size) 746 (source_file, self.image_file, self.sector_size, start, size)
747 rc, out = exec_cmd(dd_cmd) 747 exec_cmd(dd_cmd)
748 748
749 749
750 def install(self, image_file): 750 def install(self, image_file):