From c9df168fa0e1a797c72ee7eab2ec0cbfc3c5174b Mon Sep 17 00:00:00 2001 From: Michael Kinney Date: Thu, 14 Aug 2014 20:08:17 +0000 Subject: Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney Reviewed-by: lhauch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the behavior of the –version flag in the Rsa2048Sha256 tools and update logic for showing program name, version, usage, and copyright information to match other BaseTools. git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15805 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py | 24 ++++++++++------------ .../Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py | 23 +++++++++------------ 2 files changed, 21 insertions(+), 26 deletions(-) (limited to 'BaseTools') diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py index 630670ef6d..0b1624ab1b 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py @@ -27,22 +27,22 @@ import os import sys import argparse import subprocess +from Common.BuildVersion import gBUILD_VERSION + +# +# Globals for help information +# +__prog__ = 'Rsa2048Sha256GenerateKeys' +__version__ = '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION) +__copyright__ = 'Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.' +__usage__ = '%s [options]' % (__prog__) + if __name__ == '__main__': - # - # Save name of the program - # - ProgramName = sys.argv[0] - - # - # Print copyright - # - print '%s - Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.' % (ProgramName) - # # Create command line argument parser object # - parser = argparse.ArgumentParser(prog=ProgramName, usage='%(prog)s [options]', add_help=False) + parser = argparse.ArgumentParser(prog=__prog__, version=__version__, usage=__usage__, description=__copyright__, conflict_handler='resolve') group = parser.add_mutually_exclusive_group(required=True) group.add_argument("-o", "--output", dest='OutputFile', type=argparse.FileType('wb'), metavar='filename', nargs='*', help="specify the output private key filename in PEM format") group.add_argument("-i", "--input", dest='InputFile', type=argparse.FileType('rb'), metavar='filename', nargs='*', help="specify the input private key filename in PEM format") @@ -51,8 +51,6 @@ if __name__ == '__main__': parser.add_argument("-v", "--verbose", dest='Verbose', action="store_true", help="increase output messages") parser.add_argument("-q", "--quiet", dest='Quiet', action="store_true", help="reduce output messages") parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=range(0,10), default=0, help="set debug level") - parser.add_argument("--version", dest='Version', action="store_true", help="display the program version and exit") - parser.add_argument("-h", "--help", dest='Help', action="help", help="display this help text") # # Parse command line arguments diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py index b4c9aa4ce4..b83c9d4d42 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py @@ -25,6 +25,15 @@ import subprocess import uuid import struct import collections +from Common.BuildVersion import gBUILD_VERSION + +# +# Globals for help information +# +__prog__ = 'Rsa2048Sha256Sign' +__version__ = '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION) +__copyright__ = 'Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.' +__usage__ = '%s -e|-d [options] ' % (__prog__) # # GUID for SHA 256 Hash Algorithm from UEFI Specification @@ -49,20 +58,10 @@ EFI_CERT_BLOCK_RSA_2048_SHA256_STRUCT = struct.Struct('16s256s256s') TEST_SIGNING_PRIVATE_KEY_FILENAME = 'TestSigningPrivateKey.pem' if __name__ == '__main__': - # - # Save name of the program - # - ProgramName = sys.argv[0] - - # - # Print copyright - # - print '%s - Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.' % (ProgramName) - # # Create command line argument parser object # - parser = argparse.ArgumentParser(prog=ProgramName, usage='%(prog)s -e|-d [options] ', add_help=False) + parser = argparse.ArgumentParser(prog=__prog__, version=__version__, usage=__usage__, description=__copyright__, conflict_handler='resolve') group = parser.add_mutually_exclusive_group(required=True) group.add_argument("-e", action="store_true", dest='Encode', help='encode file') group.add_argument("-d", action="store_true", dest='Decode', help='decode file') @@ -71,8 +70,6 @@ if __name__ == '__main__': parser.add_argument("-v", "--verbose", dest='Verbose', action="store_true", help="increase output messages") parser.add_argument("-q", "--quiet", dest='Quiet', action="store_true", help="reduce output messages") parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=range(0,10), default=0, help="set debug level") - parser.add_argument("--version", dest='Version', action="store_true", help="display the program version and exit") - parser.add_argument("-h", "--help", dest='Help', action="help", help="display this help text") parser.add_argument(metavar="input_file", dest='InputFile', type=argparse.FileType('rb'), help="specify the input filename") # -- cgit v1.2.3