Hi Thierry,
On Wed, Mar 27, 2019 at 02:04:39PM +0100, Thierry Reding wrote:
This script is incompatible with Python 3, so make sure it is run using Python 2 explicitly. This establishes compatibility on systems that default to Python 3 and which make the python symlink point to the Python 3 binary.
Thank you for your report and patch.
However, EDK2 has recently enabled support for using both Python 2 and Python 3, so my preference would be not to lock down hard on 2.
The below is my attempt at making the script compatible with both, and it appears to work at my end.
It *does* require additionally installing the configparser module(s), which on Debian means $ sudo apt-get install python-metaconfig python3-metaconfig or if packaging is too old-school $ pip install configparser # sudo? I dunno, I'm old-school.
Would this alternative solution also work for you?
Regards,
Leif
diff --git a/parse-platforms.py b/parse-platforms.py index 7483749..8674b5d 100755 --- a/parse-platforms.py +++ b/parse-platforms.py @@ -1,36 +1,37 @@ #!/usr/bin/python
-import sys, os, argparse, ConfigParser +from __future__ import print_function +import sys, os, argparse, configparser
default_filename='platforms.config'
def list_platforms(): - for p in platforms: print p + for p in platforms: print(p)
def shortlist_platforms(): - for p in platforms: print p, + for p in platforms: print(p, end=' ')
def get_images(): if args.platform: try: value = config.get(args.platform, "EXTRA_FILES") - print value, + print(value, end=' ') except: pass try: value = config.get(args.platform, "BUILD_ATF") if value == "yes": - print "bl1.bin fip.bin" + print("bl1.bin fip.bin") return True except: try: value = config.get(args.platform, "UEFI_BIN") - print value + print(value) return True except: - print "No images found!" + print("No images found!") else: - print "No platform specified!" + print("No platform specified!")
return False
@@ -43,7 +44,7 @@ def get_executables(): except: return False
- print "%s/%s" % (arch, value) + print("%s/%s" % (arch, value)) return True except: pass @@ -56,14 +57,14 @@ def get_option(): try: value = config.get(args.platform, args.option) if value: - print value + print(value) return True except: return True # Option not found, return True, and no output else: - print "No option specified!" + print("No option specified!") else: - print "No platform specified!" + print("No platform specified!") return False
parser = argparse.ArgumentParser(description='Parses platform configuration for Linaro UEFI build scripts.') @@ -78,7 +79,7 @@ if args.config_file: else: config_filename = os.path.dirname(os.path.realpath(sys.argv[0])) + '/' + default_filename
-config = ConfigParser.ConfigParser() +config = configparser.ConfigParser() config.read(config_filename)
platforms = config.sections() @@ -92,7 +93,5 @@ commands = {"shortlist": shortlist_platforms, try: retval = commands[args.command]() except: - print ("Unrecognized command '%s'" % args.command) - -if retval != True: + print("Unrecognized command '%s'" % args.command) sys.exit(1)