From 492d39933d576762d059030469b84060bbf9f01d Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 28 Jul 2016 14:11:37 -0700 Subject: [PATCH] livemedia-creator: Fix logging (#1361031) The cherry-pick for commit 0d28b9e09c4f1042be08f87402048f6b3a5ec1f0 dropped the patch into the middle of setup_logging and added a (unused) main() function so things would still run, but logging wasn't being setup properly. This removes the main() and moves the default_image_name() function after all of the logging setup code. Resolves: rhbz#1361031 --- src/sbin/livemedia-creator | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/sbin/livemedia-creator b/src/sbin/livemedia-creator index c0e0cc66..d436bbb3 100755 --- a/src/sbin/livemedia-creator +++ b/src/sbin/livemedia-creator @@ -964,22 +964,6 @@ def setup_logging(opts): log.setLevel(logging.DEBUG) pylorax_log.setLevel(logging.DEBUG) - -def default_image_name(compression, basename): - """ Return a default image name with the correct suffix for the compression type. - - :param str compression: Compression type - :param str basename: Base filename - :returns: basename with compression suffix - - If the compression is unknown it defaults to xz - """ - SUFFIXES = {"xz": ".xz", "gzip": ".gz", "bzip2": ".bz2", "lzma": ".lzma"} - return basename + SUFFIXES.get(compression, ".xz") - - -def main(): - sh = logging.StreamHandler() sh.setLevel(logging.INFO) fmt = logging.Formatter("%(asctime)s: %(message)s") @@ -1002,6 +986,19 @@ def main(): program_log.addHandler(fh) +def default_image_name(compression, basename): + """ Return a default image name with the correct suffix for the compression type. + + :param str compression: Compression type + :param str basename: Base filename + :returns: basename with compression suffix + + If the compression is unknown it defaults to xz + """ + SUFFIXES = {"xz": ".xz", "gzip": ".gz", "bzip2": ".bz2", "lzma": ".lzma"} + return basename + SUFFIXES.get(compression, ".xz") + + if __name__ == '__main__': parser = argparse.ArgumentParser( description="Create Live Install Media", fromfile_prefix_chars="@" )