diff options
author | spashabk-in <shakeebbk@in.ibm.com> | 2017-07-17 06:59:08 -0500 |
---|---|---|
committer | Sachin Gupta <sgupta2m@in.ibm.com> | 2017-07-18 05:42:00 -0400 |
commit | 2611bfa207243a29f674883e51cf6af2112a5f9d (patch) | |
tree | 9cba0feadef2c64912272d3cda21d401d47a6e1f /src/boot | |
parent | 58ee9463a7c31f9bcaf0c60f5c429906e66bf660 (diff) | |
download | talos-sbe-2611bfa207243a29f674883e51cf6af2112a5f9d.tar.gz talos-sbe-2611bfa207243a29f674883e51cf6af2112a5f9d.zip |
Removal of argparse module dependency in compression
Change-Id: Id7c5d0e644477e33581b70fd909cc4c3878c9e73
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/43205
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'src/boot')
-rwxr-xr-x | src/boot/sbeCompression.py | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/boot/sbeCompression.py b/src/boot/sbeCompression.py index a9ac9a23..510b2cc3 100755 --- a/src/boot/sbeCompression.py +++ b/src/boot/sbeCompression.py @@ -30,7 +30,7 @@ import random import sys import binascii import fileinput -import argparse +import getopt import struct import operator err = False @@ -86,7 +86,7 @@ def compress(inputFile, compressedFile): strBits = "" count = 0 - #Create a bitmap for each four bytes of binary. + #Create a bitmap for each four bytes of binary. for i in range(0, os.stat(inputFile).st_size / 4 ): fourByt = f.read(4) @@ -128,15 +128,35 @@ def compress(inputFile, compressedFile): f.close() fW.close() -def main( argv ): +def usage(): + print "usage: sbeCompression.py [-h] [-l <path>] [-i <image>]" + print "SBE Compression Parser" + print "Arguments:" + print "-h, --help\t\tshow this help message and exit" + print "-l, --imageLoc\t\tSeeprom Binary Location" + print "-i, --image\t\tSeeprom Binary" + return 1 - parser = argparse.ArgumentParser( description = "SBE Compression Parser" ) - parser.add_argument( '-l', '--imageLoc', type=str, help = 'Seeprom Binary Location' ) - parser.add_argument( '-i', '--image', type=str, help = 'Seeprom Binary ' ) +def main( argv ): - args = parser.parse_args() - imagePath = args.imageLoc - image = args.image + try: + opts, args = getopt.getopt(argv[1:], "l:i:h", ['imageLoc=', 'image=', 'help']) + except getopt.GetoptError as err: + print str(err) + usage() + exit(1) + + imagePath = '' + image = '' + + for opt, arg in opts: + if opt in ('-l', '--imageLoc'): + imagePath = arg + elif opt in ('-i', '--image'): + image = arg + else: + usage() + exit(1) #Make a copy of SEEPROM binary. cmd1 = "cp " + imagePath + "/" + image + " " + imagePath + "/" + image + ".orig" |