Skip to content

Commit 1c512b3

Browse files
author
Marti Bolivar
committed
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 <[email protected]>
1 parent 8f4d11a commit 1c512b3

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

support/scripts/reset.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
22

3+
from __future__ import print_function
4+
35
import serial
46
import os
57
import platform
@@ -37,12 +39,12 @@ def choose_path(possible_paths):
3739
elif len(possible_paths) == 1:
3840
return possible_paths[0]
3941
else:
40-
print ('Found multiple candidates for the Maple device:')
42+
print('Found multiple candidates for the Maple device:')
4143
return choose_among_options(possible_paths)
4244

4345
def choose_among_options(options):
4446
for (i,p) in enumerate(options):
45-
print ('\t%d. %s' % (i+1, p))
47+
print('\t%d. %s' % (i+1, p))
4648

4749
prompt = 'Enter a number to select one, or q to quit: '
4850
while True:
@@ -63,12 +65,12 @@ def choose_among_options(options):
6365
plat_bits = platform.architecture()[0]
6466
if plat_sys == 'Linux':
6567
if plat_bits == '64bit':
66-
print ('You appear to be using 64-bit Linux. Let us know if this works.')
68+
print('You are using 64-bit Linux. Let us know if this works.')
6769
maple_path = unix_get_maple_path('ttyACM')
6870
# fall back on /dev/maple if that doesn't work
6971
if maple_path is None:
7072
maple_path = '/dev/maple'
71-
print ('Could not find Maple serial port; defaulting to /dev/maple.')
73+
print('Could not find Maple serial port; defaulting to /dev/maple.')
7274
elif plat_sys == 'Darwin':
7375
maple_path = unix_get_maple_path('tty.usbmodem')
7476
elif plat_sys == 'Windows':
@@ -78,17 +80,17 @@ def choose_among_options(options):
7880
"the path to the Maple's serial port device file:")
7981

8082
if maple_path is None:
81-
print ('Could not find the Maple serial port for reset.', \
82-
'Perhaps this is your first upload, or the board is already', \
83-
'in bootloader mode.')
84-
print ()
85-
print ("If your sketch doesn't upload, try putting your Maple", \
86-
'into bootloader mode manually by pressing the RESET button', \
87-
'then letting it go and quickly pressing button BUT', \
88-
'(hold for several seconds).')
83+
print('Could not find the Maple serial port for reset.',
84+
'Perhaps this is your first upload, or the board is already',
85+
'in bootloader mode.')
86+
print()
87+
print("If your sketch doesn't upload, try putting your Maple",
88+
'into bootloader mode manually by pressing the RESET button',
89+
'then letting it go and quickly pressing button BUT',
90+
'(hold for several seconds).')
8991
sys.exit()
9092

91-
print ('Using %s as Maple serial port' % maple_path)
93+
print('Using %s as Maple serial port' % maple_path)
9294

9395
try:
9496
ser = serial.Serial(maple_path, baudrate=115200, xonxoff=1)
@@ -119,6 +121,6 @@ def choose_among_options(options):
119121
ser.close()
120122

121123
except Exception as e:
122-
print ('Failed to open serial port %s for reset' % maple_path)
124+
print('Failed to open serial port %s for reset' % maple_path)
123125
sys.exit()
124126

0 commit comments

Comments
 (0)