aboutsummaryrefslogtreecommitdiff
path: root/linaro-media-create
diff options
context:
space:
mode:
authorMilo Casagrande <milo@ubuntu.com>2012-10-19 14:37:48 +0200
committerMilo Casagrande <milo@ubuntu.com>2012-10-19 14:37:48 +0200
commitb21d6e2ac0a693009abca7ecff545572156f3fe1 (patch)
treea1312030b0ec32a06c7a2d6c3df350d3a752cc8f /linaro-media-create
parent24176a36645aa060206c7bb7c5f44b9a3b214d4a (diff)
parent1594ab37db5d5368233a8d9dc11c778cc300dcab (diff)
Use common logging infrastructure, add --debug option to linaro-media-create.
Diffstat (limited to 'linaro-media-create')
-rwxr-xr-xlinaro-media-create39
1 files changed, 17 insertions, 22 deletions
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)