diff options
Diffstat (limited to 'scripts/lib/mic/utils/oe/misc.py')
| -rw-r--r-- | scripts/lib/mic/utils/oe/misc.py | 33 |
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 @@ | |||
| 28 | from mic import msger | 28 | from mic import msger |
| 29 | from mic.utils import runner | 29 | from mic.utils import runner |
| 30 | 30 | ||
| 31 | def exec_cmd(cmd_and_args, as_shell = False, catch = 3): | 31 | def __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 | |||
| 52 | def 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 | ||
| 59 | def exec_cmd_quiet(cmd_and_args, as_shell = False): | 66 | def 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 |
