From 1dd8cca63102b1718609c5e2903e1ea468c4c469 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Tue, 14 Feb 2017 20:13:46 +0200 Subject: wic: use wic logger in wic source plugins Replaced msger with wic logger in wic source plugins. (From OE-Core rev: 19a868e9ad12fb27a7f713685d12f3d310fd6961) Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- .../lib/wic/plugins/source/rootfs_pcbios_ext.py | 56 ++++++++++++---------- 1 file changed, 32 insertions(+), 24 deletions(-) (limited to 'scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py') diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py index 9e79a139da..ed5fbdfa9c 100644 --- a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py +++ b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py @@ -18,15 +18,18 @@ # Adrian Freihofer # +import logging import os import re +import sys -from wic import msger from wic.utils import runner from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd from wic.utils.errors import ImageError from wic.pluginbase import SourcePlugin +logger = logging.getLogger('wic') + def serial_console_form_kargs(kernel_args): """ Create SERIAL... line from kernel parameters @@ -48,16 +51,16 @@ def serial_console_form_kargs(kernel_args): syslinux_conf += " " + param_match.group(2) # parity if param_match.group(3) and param_match.group(3) != 'n': - msger.warning("syslinux does not support parity for console. {} is ignored." - .format(param_match.group(3))) + logger.warning("syslinux does not support parity for console. " + "%s is ignored.", param_match.group(3)) # number of bits if param_match.group(4) and param_match.group(4) != '8': - msger.warning("syslinux supports 8 bit console configuration only. {} is ignored." - .format(param_match.group(4))) + logger.warning("syslinux supports 8 bit console configuration " + "only. %s is ignored.", param_match.group(4)) # flow control if param_match.group(5) and param_match.group(5) != '': - msger.warning("syslinux console flowcontrol configuration. {} is ignored." - .format(param_match.group(5))) + logger.warning("syslinux console flowcontrol configuration. " + "%s is ignored.", param_match.group(5)) break return syslinux_conf @@ -96,10 +99,10 @@ class RootfsPlugin(SourcePlugin): image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) if not os.path.isdir(image_rootfs_dir): - msg = "No valid artifact IMAGE_ROOTFS from image named" - msg += " %s has been found at %s, exiting.\n" % \ - (rootfs_dir, image_rootfs_dir) - msger.error(msg) + logger.error("No valid artifact IMAGE_ROOTFS from image named %s " + "has been found at %s, exiting.\n", + rootfs_dir, image_rootfs_dir) + sys.exit(1) return image_rootfs_dir @@ -132,7 +135,7 @@ class RootfsPlugin(SourcePlugin): (image_creator.rootdev, bootloader.append) syslinux_cfg = os.path.join(image_creator.rootfs_dir['ROOTFS_DIR'], "boot", "syslinux.cfg") - msger.debug("Writing syslinux config %s" % syslinux_cfg) + logger.debug("Writing syslinux config %s", syslinux_cfg) with open(syslinux_cfg, "w") as cfg: cfg.write(syslinux_conf) @@ -154,15 +157,17 @@ class RootfsPlugin(SourcePlugin): # Make sure syslinux-nomtools is available in native sysroot or fail native_syslinux_nomtools = os.path.join(native_sysroot, "usr/bin/syslinux-nomtools") if not is_exe(native_syslinux_nomtools): - msger.info("building syslinux-native...") + logger.info("building syslinux-native...") exec_cmd("bitbake syslinux-native") if not is_exe(native_syslinux_nomtools): - msger.error("Couldn't find syslinux-nomtools (%s), exiting\n" % - native_syslinux_nomtools) + logger.error("Couldn't find syslinux-nomtools (%s), exiting\n", + native_syslinux_nomtools) + sys.exit(1) if part.rootfs is None: if 'ROOTFS_DIR' not in krootfs_dir: - msger.error("Couldn't find --rootfs-dir, exiting") + logger.error("Couldn't find --rootfs-dir, exiting") + sys.exit(1) rootfs_dir = krootfs_dir['ROOTFS_DIR'] else: if part.rootfs in krootfs_dir: @@ -170,9 +175,9 @@ class RootfsPlugin(SourcePlugin): elif part.rootfs: rootfs_dir = part.rootfs else: - msg = "Couldn't find --rootfs-dir=%s connection" - msg += " or it is not a valid path, exiting" - msger.error(msg % part.rootfs) + logger.error("Couldn't find --rootfs-dir=%s connection or " + "it is not a valid path, exiting", part.rootfs) + sys.exit(1) real_rootfs_dir = cls._get_rootfs_dir(rootfs_dir) @@ -198,15 +203,18 @@ class RootfsPlugin(SourcePlugin): elif image_creator.ptable_format == 'gpt': mbrfile += "gptmbr.bin" else: - msger.error("Unsupported partition table: %s" % \ - image_creator.ptable_format) + logger.error("Unsupported partition table: %s", + image_creator.ptable_format) + sys.exit(1) if not os.path.exists(mbrfile): - msger.error("Couldn't find %s. Has syslinux-native been baked?" % mbrfile) + logger.error("Couldn't find %s. Has syslinux-native been baked?", + mbrfile) + sys.exit(1) full_path = disk.path - msger.debug("Installing MBR on disk %s as %s with size %s bytes" \ - % (disk_name, full_path, disk.min_size)) + logger.debug("Installing MBR on disk %s as %s with size %s bytes", + disk_name, full_path, disk.min_size) ret_code = runner.show(['dd', 'if=%s' % mbrfile, 'of=%s' % full_path, 'conv=notrunc']) if ret_code != 0: -- cgit v1.2.3-54-g00ecf