From cbd3ff0bf7a78052e7a8558963030c3dbdaec357 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 24 Jul 2012 16:59:14 -0400 Subject: stm32loader.py: Use print function. Towards py3k compatibility. Signed-off-by: Marti Bolivar --- support/stm32loader.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'support') diff --git a/support/stm32loader.py b/support/stm32loader.py index 737e403..3597526 100755 --- a/support/stm32loader.py +++ b/support/stm32loader.py @@ -22,6 +22,8 @@ # along with stm32loader; see the file COPYING3. If not see # . +from __future__ import print_function + import sys, getopt import serial import time @@ -42,7 +44,7 @@ QUIET = 20 def mdebug(level, message): if(QUIET >= level): - print >> sys.stderr , message + print(message, file=sys.stderr) class CmdException(Exception): @@ -321,7 +323,7 @@ class CommandInterface: def usage(): - print """Usage: %s [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin] + print("""Usage: %s [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin] -h This help -q Quiet -V Verbose @@ -336,7 +338,7 @@ def usage(): ./stm32loader.py -e -w -v example/main.bin - """ % sys.argv[0] + """ % sys.argv[0]) def read(filename): """Read the file to be programmed and turn it into a binary""" @@ -373,7 +375,7 @@ if __name__ == "__main__": try: import psyco psyco.full() - print "Using Psyco..." + print("Using Psyco...") except ImportError: pass @@ -395,7 +397,7 @@ if __name__ == "__main__": opts, args = getopt.getopt(sys.argv[1:], "hqVewvrp:b:a:l:") except getopt.GetoptError, err: # print help information and exit: - print str(err) # will print something like "option -a not recognized" + print(str(err)) # will print something like "option -a not recognized" usage() sys.exit(2) @@ -454,7 +456,7 @@ if __name__ == "__main__": try: cmd.initChip() except CmdException: - print "Can't init. Ensure that BOOT0 is enabled and reset device" + print("Can't init. Ensure that BOOT0 is enabled and reset device") bootversion = cmd.cmdGet() @@ -478,13 +480,13 @@ if __name__ == "__main__": if conf['verify']: verify = cmd.readMemory(conf['address'], len(data)) if(data == verify): - print "Verification OK" + print("Verification OK") else: - print "Verification FAILED" - print str(len(data)) + ' vs ' + str(len(verify)) + print("Verification FAILED") + print(str(len(data)) + ' vs ' + str(len(verify))) for i in xrange(0, len(data)): if data[i] != verify[i]: - print hex(i) + ': ' + hex(data[i]) + ' vs ' + hex(verify[i]) + print(hex(i) + ': ' + hex(data[i]) + ' vs ' + hex(verify[i])) if not conf['write'] and conf['read']: rdata = cmd.readMemory(conf['address'], conf['len']) -- cgit v1.2.3