diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-06-28 12:02:48 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-06-28 12:02:48 -0400 |
commit | f9e7ed43d6e72693a5ee358a7006cd6566960b19 (patch) | |
tree | 4409333457a43e9bdad2783679a255884c0286da /support/scripts | |
parent | 53b9bcfbf2ca25e7c4802cba123194cd842d9b5d (diff) | |
download | librambutan-f9e7ed43d6e72693a5ee358a7006cd6566960b19.tar.gz librambutan-f9e7ed43d6e72693a5ee358a7006cd6566960b19.zip |
reset.py: Use the real print function (requires Python 2.6+).
Use "from __future__ import print_function" so the recent py3k
compatibility patches to reset.py preserve the old output in Python 2.
This increases our minimum Python version to 2.6, but avoids ugly
output Python 2, where print statements with a tuple argument print
the tuple with parentheses etc.
Python 2.6 came out almost four years ago, and it's widely available:
- even on older Linux distros (e.g. Ubuntu 10.04 and Debian Squeeze
have 2.6 default at time of writing),
- on OS X since 10.6,
- and Windows users will probably be installing from python.org
anyway, so they've likely got a reasonably recent vintage.
Dropping 2.5 support thus doesn't seem likely to cause problems.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'support/scripts')
-rwxr-xr-x | support/scripts/reset.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/support/scripts/reset.py b/support/scripts/reset.py index 8ab9b9f..2a876d6 100755 --- a/support/scripts/reset.py +++ b/support/scripts/reset.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function + import serial import os import platform @@ -37,12 +39,12 @@ def choose_path(possible_paths): elif len(possible_paths) == 1: return possible_paths[0] else: - print ('Found multiple candidates for the Maple device:') + print('Found multiple candidates for the Maple device:') return choose_among_options(possible_paths) def choose_among_options(options): for (i,p) in enumerate(options): - print ('\t%d. %s' % (i+1, p)) + print('\t%d. %s' % (i+1, p)) prompt = 'Enter a number to select one, or q to quit: ' while True: @@ -63,12 +65,12 @@ plat_sys = platform.system() plat_bits = platform.architecture()[0] if plat_sys == 'Linux': if plat_bits == '64bit': - print ('You appear to be using 64-bit Linux. Let us know if this works.') + print('You are using 64-bit Linux. Let us know if this works.') maple_path = unix_get_maple_path('ttyACM') # fall back on /dev/maple if that doesn't work if maple_path is None: maple_path = '/dev/maple' - print ('Could not find Maple serial port; defaulting to /dev/maple.') + print('Could not find Maple serial port; defaulting to /dev/maple.') elif plat_sys == 'Darwin': maple_path = unix_get_maple_path('tty.usbmodem') elif plat_sys == 'Windows': @@ -78,17 +80,17 @@ else: "the path to the Maple's serial port device file:") if maple_path is None: - print ('Could not find the Maple serial port for reset.', \ - 'Perhaps this is your first upload, or the board is already', \ - 'in bootloader mode.') - print () - print ("If your sketch doesn't upload, try putting your Maple", \ - 'into bootloader mode manually by pressing the RESET button', \ - 'then letting it go and quickly pressing button BUT', \ - '(hold for several seconds).') + print('Could not find the Maple serial port for reset.', + 'Perhaps this is your first upload, or the board is already', + 'in bootloader mode.') + print() + print("If your sketch doesn't upload, try putting your Maple", + 'into bootloader mode manually by pressing the RESET button', + 'then letting it go and quickly pressing button BUT', + '(hold for several seconds).') sys.exit() -print ('Using %s as Maple serial port' % maple_path) +print('Using %s as Maple serial port' % maple_path) try: ser = serial.Serial(maple_path, baudrate=115200, xonxoff=1) @@ -119,6 +121,6 @@ try: ser.close() except Exception as e: - print ('Failed to open serial port %s for reset' % maple_path) + print('Failed to open serial port %s for reset' % maple_path) sys.exit() |