From e0cdfbae1715e9d38a019b265e71bc89bad82f83 Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Thu, 20 Feb 2020 01:22:31 -0800 Subject: [PATCH] [python] fix a few of the python tools to be python 2 and 3 compatible --- platform/lpc15xx/lpccheck.py | 4 ++-- platform/zynq/mkbootheader.py | 4 ++-- tools/bin2h.py | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/platform/lpc15xx/lpccheck.py b/platform/lpc15xx/lpccheck.py index 495515d1..24f37de8 100755 --- a/platform/lpc15xx/lpccheck.py +++ b/platform/lpc15xx/lpccheck.py @@ -3,8 +3,8 @@ import sys, os, struct if len(sys.argv) < 2: - print "not enough args, usage:" - print "%s " % sys.argv[0] + print ("not enough args, usage:") + print ("%s " % sys.argv[0]) sys.exit(1) f = open(sys.argv[1], "r+b") diff --git a/platform/zynq/mkbootheader.py b/platform/zynq/mkbootheader.py index 5178d086..da615e96 100755 --- a/platform/zynq/mkbootheader.py +++ b/platform/zynq/mkbootheader.py @@ -5,8 +5,8 @@ import sys, os, array if len(sys.argv) < 3: - print "not enough args, usage:" - print "%s " % sys.argv[0] + print ("not enough args, usage:") + print ("%s " % sys.argv[0]) sys.exit(1) fin = open(sys.argv[1], "r+b") diff --git a/tools/bin2h.py b/tools/bin2h.py index 52d4baee..3583e2a6 100755 --- a/tools/bin2h.py +++ b/tools/bin2h.py @@ -13,18 +13,18 @@ parser.add_option("-a", "--after", dest="after", action="append", if options.before and len(options.before) > 0: for b in options.before: - print b + print (b) offset = 0 -f = bytearray(sys.stdin.read()) +f = bytearray(sys.stdin.read(), 'utf-8') for c in f: if offset != 0 and offset % 16 == 0: - print "" - print "%#04x," % c, + print ("") + sys.stdout.write("%#04x," % c) offset = offset + 1 -print "" +print ("") if options.after and len(options.after) > 0: for a in options.after: - print a + print (a)