From 3e5e0dcce647877ffb63bc598e2f30508644ad5f Mon Sep 17 00:00:00 2001 From: Milo Casagrande Date: Thu, 4 Oct 2012 16:21:31 +0200 Subject: Use new logger method. --- linaro-media-create | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'linaro-media-create') diff --git a/linaro-media-create b/linaro-media-create index 62a7068..81a83f8 100755 --- a/linaro-media-create +++ b/linaro-media-create @@ -22,7 +22,6 @@ import atexit import os import sys import tempfile -import logging from linaro_image_tools import cmd_runner @@ -57,6 +56,7 @@ from linaro_image_tools.utils import ( MissingRequiredOption, path_in_tarfile_exists, prep_media_path, + get_logger, ) # Just define the global variables @@ -106,35 +106,29 @@ if __name__ == '__main__': parser = get_args_parser() args = parser.parse_args() - ch = logging.StreamHandler() - ch.setLevel(logging.INFO) - formatter = logging.Formatter("%(message)s") - ch.setFormatter(formatter) - logger = logging.getLogger("linaro_image_tools") - logger.setLevel(logging.INFO) - logger.addHandler(ch) + logger = get_logger(debug=args.debug) try: additional_option_checks(args) except IncompatibleOptions as e: parser.print_help() - print >> sys.stderr, "\nError:", e.value + logger.error(e.value) sys.exit(1) if args.readhwpack: try: reader = HwpackReader(args.hwpacks) - print reader.get_supported_boards() + logger.info(reader.get_supported_boards()) sys.exit(0) except HwpackReaderError as e: - print >> sys.stderr, "\nError:", e.value + logger.error(e.value) sys.exit(1) try: check_required_args(args) except MissingRequiredOption as e: parser.print_help() - print >> sys.stderr, "\nError:", e.value + logger.error(e.value) sys.exit(1) board_config = board_configs[args.dev] @@ -147,16 +141,16 @@ if __name__ == '__main__': if media.is_block_device: if not board_config.supports_writing_to_mmc: - print ("The board '%s' does not support the --mmc option. " - "Please use --image_file to create an image file for this " - "board." % args.dev) + logger.error("The board '%s' does not support the --mmc option. " + "Please use --image_file to create an image file for " + "this board." % args.dev) sys.exit(1) if not confirm_device_selection_and_ensure_it_is_ready( args.device, args.nocheck_mmc): sys.exit(1) elif not args.should_format_rootfs or not args.should_format_bootfs: - print ("Do not use --no-boot or --no-part in conjunction with " - "--image_file.") + logger.error("Do not use --no-boot or --no-part in conjunction with " + "--image_file.") sys.exit(1) else: # All good, move on. @@ -170,6 +164,7 @@ if __name__ == '__main__': BIN_DIR = os.path.join(TMP_DIR, 'rootfs') os.mkdir(BIN_DIR) + logger.info('Searching correct rootfs path') # Identify the correct path for the rootfs filesystem_dir = '' if path_in_tarfile_exists('binary/etc', args.binary): @@ -212,12 +207,12 @@ if __name__ == '__main__': if args.rootfs == 'btrfs': if not extract_kpkgs: - print ("Desired rootfs type is 'btrfs', trying to auto-install " - "the 'btrfs-tools' package") + logger.info("Desired rootfs type is 'btrfs', trying to " + "auto-install the 'btrfs-tools' package") install_packages(ROOTFS_DIR, TMP_DIR, "btrfs-tools") else: - print ("Desired rootfs type is 'btrfs', please make sure the " - "rootfs also includes 'btrfs-tools'") + logger.info("Desired rootfs type is 'btrfs', please make sure the " + "rootfs also includes 'btrfs-tools'") boot_partition, root_partition = setup_partitions( board_config, media, args.image_size, args.boot_label, args.rfs_label, @@ -248,4 +243,4 @@ if __name__ == '__main__': board_config.mmc_device_id, board_config.mmc_part_offset, board_config) - print "Done creating Linaro image on %s" % media.path + logger.info("Done creating Linaro image on %s" % media.path) -- cgit v1.2.3