bitbake: bitbake-diffsigs: change to use argparse
Argparse is a bit easier to deal with than optparse, and since we're about to add some options, migrate this script over. (Bitbake rev: 7f130e0b5ce6cfc6b35176465f260092cd3b3d64) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
8c015e45ff
commit
e0eda80371
|
@ -3,7 +3,7 @@
|
||||||
# bitbake-diffsigs
|
# bitbake-diffsigs
|
||||||
# BitBake task signature data comparison utility
|
# BitBake task signature data comparison utility
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012-2013 Intel Corporation
|
# Copyright (C) 2012-2013, 2017 Intel Corporation
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -22,7 +22,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import optparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
@ -83,22 +83,27 @@ def find_compare_task(bbhandler, pn, taskname):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parser = optparse.OptionParser(
|
parser = argparse.ArgumentParser(
|
||||||
description = "Compares siginfo/sigdata files written out by BitBake",
|
description="Compares siginfo/sigdata files written out by BitBake")
|
||||||
usage = """
|
|
||||||
%prog -t recipename taskname
|
|
||||||
%prog sigdatafile1 sigdatafile2
|
|
||||||
%prog sigdatafile1""")
|
|
||||||
|
|
||||||
parser.add_option("-D", "--debug",
|
parser.add_argument('-d', '--debug',
|
||||||
help = "enable debug",
|
help='Enable debug output',
|
||||||
action = "store_true", dest="debug", default = False)
|
action='store_true')
|
||||||
|
|
||||||
parser.add_option("-t", "--task",
|
parser.add_argument("-t", "--task",
|
||||||
help = "find the signature data files for last two runs of the specified task and compare them",
|
help="find the signature data files for last two runs of the specified task and compare them",
|
||||||
action="store", dest="taskargs", nargs=2, metavar='recipename taskname')
|
action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname'))
|
||||||
|
|
||||||
options, args = parser.parse_args(sys.argv)
|
parser.add_argument("sigdatafile1",
|
||||||
|
help="First signature file to compare (or signature file to dump, if second not specified). Not used when using -t/--task.",
|
||||||
|
action="store", nargs='?')
|
||||||
|
|
||||||
|
parser.add_argument("sigdatafile2",
|
||||||
|
help="Second signature file to compare",
|
||||||
|
action="store", nargs='?')
|
||||||
|
|
||||||
|
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
if options.debug:
|
if options.debug:
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
@ -108,20 +113,17 @@ if options.taskargs:
|
||||||
tinfoil.prepare(config_only=True)
|
tinfoil.prepare(config_only=True)
|
||||||
find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1])
|
find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1])
|
||||||
else:
|
else:
|
||||||
if len(args) == 1:
|
try:
|
||||||
parser.print_help()
|
if options.sigdatafile1 and options.sigdatafile2:
|
||||||
else:
|
output = bb.siggen.compare_sigfiles(options.sigdatafile1, options.sigdatafile2)
|
||||||
try:
|
elif options.sigdatafile1:
|
||||||
if len(args) == 2:
|
output = bb.siggen.dump_sigfile(options.sigdatafile1)
|
||||||
output = bb.siggen.dump_sigfile(sys.argv[1])
|
except IOError as e:
|
||||||
else:
|
logger.error(str(e))
|
||||||
output = bb.siggen.compare_sigfiles(sys.argv[1], sys.argv[2])
|
sys.exit(1)
|
||||||
except IOError as e:
|
except (pickle.UnpicklingError, EOFError):
|
||||||
logger.error(str(e))
|
logger.error('Invalid signature data - ensure you are specifying sigdata/siginfo files')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except (pickle.UnpicklingError, EOFError):
|
|
||||||
logger.error('Invalid signature data - ensure you are specifying sigdata/siginfo files')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if output:
|
if output:
|
||||||
print('\n'.join(output))
|
print('\n'.join(output))
|
||||||
|
|
Loading…
Reference in New Issue