aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-07-24 16:59:14 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-07-24 16:59:14 -0400
commitcbd3ff0bf7a78052e7a8558963030c3dbdaec357 (patch)
tree2a7e93addd868f4ba71f9f41992deb50fe77a02a /support
parentbabc82aa582b3949bdb425429c1f486eafa336b2 (diff)
downloadlibrambutan-cbd3ff0bf7a78052e7a8558963030c3dbdaec357.tar.gz
librambutan-cbd3ff0bf7a78052e7a8558963030c3dbdaec357.zip
stm32loader.py: Use print function.
Towards py3k compatibility. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'support')
-rwxr-xr-xsupport/stm32loader.py22
1 files changed, 12 insertions, 10 deletions
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
# <http://www.gnu.org/licenses/>.
+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'])