diff options
| author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-02-14 18:54:32 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-04 23:18:16 +0000 |
| commit | fe2d6022409248063403eed2f2de97f438dc7f03 (patch) | |
| tree | acf85ab9205c2ac8e73c20bf7d823c0a452b87a2 /scripts/lib/wic/utils/misc.py | |
| parent | 58ff06f1e7a19bef5199cc938c910af1f599373a (diff) | |
| download | poky-fe2d6022409248063403eed2f2de97f438dc7f03.tar.gz | |
wic: use wic logger in core modules
Replaced msger with wic logger in the core wic modules.
(From OE-Core rev: cdd6675951b74075c9b9159f7465a88f83775bac)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/utils/misc.py')
| -rw-r--r-- | scripts/lib/wic/utils/misc.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/scripts/lib/wic/utils/misc.py b/scripts/lib/wic/utils/misc.py index edb9c5b484..b7b835afbb 100644 --- a/scripts/lib/wic/utils/misc.py +++ b/scripts/lib/wic/utils/misc.py | |||
| @@ -26,14 +26,17 @@ | |||
| 26 | # | 26 | # |
| 27 | """Miscellaneous functions.""" | 27 | """Miscellaneous functions.""" |
| 28 | 28 | ||
| 29 | import logging | ||
| 29 | import os | 30 | import os |
| 30 | import re | 31 | import re |
| 32 | |||
| 31 | from collections import defaultdict | 33 | from collections import defaultdict |
| 32 | from distutils import spawn | 34 | from distutils import spawn |
| 33 | 35 | ||
| 34 | from wic import msger | ||
| 35 | from wic.utils import runner | 36 | from wic.utils import runner |
| 36 | 37 | ||
| 38 | logger = logging.getLogger('wic') | ||
| 39 | |||
| 37 | # executable -> recipe pairs for exec_native_cmd | 40 | # executable -> recipe pairs for exec_native_cmd |
| 38 | NATIVE_RECIPES = {"bmaptool": "bmap-tools", | 41 | NATIVE_RECIPES = {"bmaptool": "bmap-tools", |
| 39 | "grub-mkimage": "grub-efi", | 42 | "grub-mkimage": "grub-efi", |
| @@ -61,9 +64,9 @@ def _exec_cmd(cmd_and_args, as_shell=False, catch=3): | |||
| 61 | 64 | ||
| 62 | Need to execute as_shell if the command uses wildcards | 65 | Need to execute as_shell if the command uses wildcards |
| 63 | """ | 66 | """ |
| 64 | msger.debug("_exec_cmd: %s" % cmd_and_args) | 67 | logger.debug("_exec_cmd: %s", cmd_and_args) |
| 65 | args = cmd_and_args.split() | 68 | args = cmd_and_args.split() |
| 66 | msger.debug(args) | 69 | logger.debug(args) |
| 67 | 70 | ||
| 68 | if as_shell: | 71 | if as_shell: |
| 69 | ret, out = runner.runtool(cmd_and_args, catch) | 72 | ret, out = runner.runtool(cmd_and_args, catch) |
| @@ -71,11 +74,12 @@ def _exec_cmd(cmd_and_args, as_shell=False, catch=3): | |||
| 71 | ret, out = runner.runtool(args, catch) | 74 | ret, out = runner.runtool(args, catch) |
| 72 | out = out.strip() | 75 | out = out.strip() |
| 73 | if ret != 0: | 76 | if ret != 0: |
| 74 | msger.error("_exec_cmd: %s returned '%s' instead of 0\noutput: %s" % \ | 77 | logger.error("_exec_cmd: %s returned '%s' instead of 0\noutput: %s" % \ |
| 75 | (cmd_and_args, ret, out)) | 78 | (cmd_and_args, ret, out)) |
| 79 | sys.exit(1) | ||
| 76 | 80 | ||
| 77 | msger.debug("_exec_cmd: output for %s (rc = %d): %s" % \ | 81 | logger.debug("_exec_cmd: output for %s (rc = %d): %s", |
| 78 | (cmd_and_args, ret, out)) | 82 | cmd_and_args, ret, out) |
| 79 | 83 | ||
| 80 | return ret, out | 84 | return ret, out |
| 81 | 85 | ||
| @@ -97,7 +101,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""): | |||
| 97 | """ | 101 | """ |
| 98 | # The reason -1 is used is because there may be "export" commands. | 102 | # The reason -1 is used is because there may be "export" commands. |
| 99 | args = cmd_and_args.split(';')[-1].split() | 103 | args = cmd_and_args.split(';')[-1].split() |
| 100 | msger.debug(args) | 104 | logger.debug(args) |
| 101 | 105 | ||
| 102 | if pseudo: | 106 | if pseudo: |
| 103 | cmd_and_args = pseudo + cmd_and_args | 107 | cmd_and_args = pseudo + cmd_and_args |
| @@ -106,7 +110,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""): | |||
| 106 | (native_sysroot, native_sysroot, native_sysroot) | 110 | (native_sysroot, native_sysroot, native_sysroot) |
| 107 | native_cmd_and_args = "export PATH=%s:$PATH;%s" % \ | 111 | native_cmd_and_args = "export PATH=%s:$PATH;%s" % \ |
| 108 | (native_paths, cmd_and_args) | 112 | (native_paths, cmd_and_args) |
| 109 | msger.debug("exec_native_cmd: %s" % cmd_and_args) | 113 | logger.debug("exec_native_cmd: %s", cmd_and_args) |
| 110 | 114 | ||
| 111 | # If the command isn't in the native sysroot say we failed. | 115 | # If the command isn't in the native sysroot say we failed. |
| 112 | if spawn.find_executable(args[0], native_paths): | 116 | if spawn.find_executable(args[0], native_paths): |
| @@ -127,7 +131,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""): | |||
| 127 | else: | 131 | else: |
| 128 | msg += "Wic failed to find a recipe to build native %s. Please "\ | 132 | msg += "Wic failed to find a recipe to build native %s. Please "\ |
| 129 | "file a bug against wic.\n" % prog | 133 | "file a bug against wic.\n" % prog |
| 130 | msger.error(msg) | 134 | logger.error(msg) |
| 131 | 135 | ||
| 132 | return ret, out | 136 | return ret, out |
| 133 | 137 | ||
| @@ -184,14 +188,14 @@ class BitbakeVars(defaultdict): | |||
| 184 | if image: | 188 | if image: |
| 185 | cmd += " %s" % image | 189 | cmd += " %s" % image |
| 186 | 190 | ||
| 187 | log_level = msger.get_loglevel() | 191 | log_level = logger.getEffectiveLevel() |
| 188 | msger.set_loglevel('normal') | 192 | logger.setLevel(logging.INFO) |
| 189 | ret, lines = _exec_cmd(cmd) | 193 | ret, lines = _exec_cmd(cmd) |
| 190 | msger.set_loglevel(log_level) | 194 | logger.setLevel(log_level) |
| 191 | 195 | ||
| 192 | if ret: | 196 | if ret: |
| 193 | print("Couldn't get '%s' output." % cmd) | 197 | logger.error("Couldn't get '%s' output.", cmd) |
| 194 | print("Bitbake failed with error:\n%s\n" % lines) | 198 | logger.error("Bitbake failed with error:\n%s\n", lines) |
| 195 | return | 199 | return |
| 196 | 200 | ||
| 197 | # Parse bitbake -e output | 201 | # Parse bitbake -e output |
