diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2017-03-20 14:51:03 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-22 11:35:22 +0000 |
commit | 07dd071bf667d5f0a729ec8f5e0d6a117d70596c (patch) | |
tree | 83d13482738f75981ce83b233a1b904214423326 /scripts | |
parent | 1e3ef54408da5625e3558602cae409663e03c8f7 (diff) | |
download | poky-07dd071bf667d5f0a729ec8f5e0d6a117d70596c.tar.gz |
scripts/yocto-compat-layer.py: Make output log argument optional
Only create a log file when --output-log option is specified, since
logger is dumping to stdout by default is better to let the user
decide if a log needs to be created.
[YOCTO #11160]
(From OE-Core rev: f91ccdeb8b0b3e4063ed2bf22215a25f8902cbd9)
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/yocto-compat-layer.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/scripts/yocto-compat-layer.py b/scripts/yocto-compat-layer.py index 8996fff799..b96f3ca0bf 100755 --- a/scripts/yocto-compat-layer.py +++ b/scripts/yocto-compat-layer.py | |||
@@ -26,9 +26,6 @@ from compatlayer import LayerType, detect_layers, add_layer, get_signatures | |||
26 | from oeqa.utils.commands import get_bb_vars | 26 | from oeqa.utils.commands import get_bb_vars |
27 | 27 | ||
28 | PROGNAME = 'yocto-compat-layer' | 28 | PROGNAME = 'yocto-compat-layer' |
29 | DEFAULT_OUTPUT_LOG = '%s-%s.log' % (PROGNAME, | ||
30 | time.strftime("%Y%m%d%H%M%S")) | ||
31 | OUTPUT_LOG_LINK = "%s.log" % PROGNAME | ||
32 | CASES_PATHS = [os.path.join(os.path.abspath(os.path.dirname(__file__)), | 29 | CASES_PATHS = [os.path.join(os.path.abspath(os.path.dirname(__file__)), |
33 | 'lib', 'compatlayer', 'cases')] | 30 | 'lib', 'compatlayer', 'cases')] |
34 | logger = scriptutils.logger_create(PROGNAME, stream=sys.stdout) | 31 | logger = scriptutils.logger_create(PROGNAME, stream=sys.stdout) |
@@ -49,9 +46,7 @@ def main(): | |||
49 | parser.add_argument('layers', metavar='LAYER_DIR', nargs='+', | 46 | parser.add_argument('layers', metavar='LAYER_DIR', nargs='+', |
50 | help='Layer to test compatibility with Yocto Project') | 47 | help='Layer to test compatibility with Yocto Project') |
51 | parser.add_argument('-o', '--output-log', | 48 | parser.add_argument('-o', '--output-log', |
52 | help='Output log default: %s' % DEFAULT_OUTPUT_LOG, | 49 | help='File to output log (optional)', action='store') |
53 | action='store', default=DEFAULT_OUTPUT_LOG) | ||
54 | |||
55 | parser.add_argument('-d', '--debug', help='Enable debug output', | 50 | parser.add_argument('-d', '--debug', help='Enable debug output', |
56 | action='store_true') | 51 | action='store_true') |
57 | parser.add_argument('-q', '--quiet', help='Print only errors', | 52 | parser.add_argument('-q', '--quiet', help='Print only errors', |
@@ -63,16 +58,14 @@ def main(): | |||
63 | 58 | ||
64 | args = parser.parse_args() | 59 | args = parser.parse_args() |
65 | 60 | ||
66 | fh = logging.FileHandler(args.output_log) | 61 | if args.output_log: |
67 | fh.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) | 62 | fh = logging.FileHandler(args.output_log) |
68 | logger.addHandler(fh) | 63 | fh.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) |
64 | logger.addHandler(fh) | ||
69 | if args.debug: | 65 | if args.debug: |
70 | logger.setLevel(logging.DEBUG) | 66 | logger.setLevel(logging.DEBUG) |
71 | elif args.quiet: | 67 | elif args.quiet: |
72 | logger.setLevel(logging.ERROR) | 68 | logger.setLevel(logging.ERROR) |
73 | if os.path.exists(OUTPUT_LOG_LINK): | ||
74 | os.unlink(OUTPUT_LOG_LINK) | ||
75 | os.symlink(args.output_log, OUTPUT_LOG_LINK) | ||
76 | 69 | ||
77 | if not 'BUILDDIR' in os.environ: | 70 | if not 'BUILDDIR' in os.environ: |
78 | logger.error("You must source the environment before run this script.") | 71 | logger.error("You must source the environment before run this script.") |