Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix py3 print compat and trailing whitespaces #469

Merged
merged 1 commit into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

"""
"""
Sample code to use with ServiceClient.pde
"""

Expand All @@ -10,7 +10,7 @@
from rosserial_arduino.srv import *

def callback(req):
print "The arduino is calling! Please send it a message:"
print("The arduino is calling! Please send it a message:")
t = TestResponse()
t.output = raw_input()
return t
Expand Down
8 changes: 4 additions & 4 deletions rosserial_arduino/src/rosserial_arduino/make_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
THIS_PACKAGE = "rosserial_arduino"

__usage__ = """
make_libraries.py generates the Arduino rosserial library files. It
make_libraries.py generates the Arduino rosserial library files. It
requires the location of your Arduino sketchbook/libraries folder.

rosrun rosserial_arduino make_libraries.py <output_path>
Expand Down Expand Up @@ -71,14 +71,14 @@

# need correct inputs
if (len(sys.argv) < 2):
print __usage__
print(__usage__)
exit()

# get output path
path = sys.argv[1]
if path[-1] == "/":
path = path[0:-1]
print "\nExporting to %s" % path
print("\nExporting to %s" % path)

rospack = rospkg.RosPack()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

"""
"""
Sample code to use with ServiceClient.pde
"""

Expand All @@ -10,7 +10,7 @@
from rosserial_arduino.srv import *

def callback(req):
print "The arduino is calling! Please send it a message:"
print("The arduino is calling! Please send it a message:")
t = TestResponse()
t.output = raw_input()
return t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@

# need correct inputs
if (len(sys.argv) < 2):
print __usage__
print(__usage__)
exit()

# get output path
path = sys.argv[1]
if path[-1] == "/":
path = path[0:-1]
print "\nExporting to %s" % path
print("\nExporting to %s" % path)

rospack = rospkg.RosPack()

Expand Down
2 changes: 1 addition & 1 deletion rosserial_mbed/src/examples/ServiceClient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from rosserial_mbed.srv import *

def callback(req):
print "The mbed is calling! Please send it a message:"
print("The mbed is calling! Please send it a message:")
t = TestResponse()
t.output = raw_input()
return t
Expand Down
4 changes: 2 additions & 2 deletions rosserial_mbed/src/rosserial_mbed/make_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@

# need correct inputs
if (len(sys.argv) < 2):
print __usage__
print(__usage__)
exit()

# get output path
path = sys.argv[1]
if path[-1] == "/":
path = path[0:-1]
print "\nExporting to %s" % path
print("\nExporting to %s" % path)

rospack = rospkg.RosPack()

Expand Down
6 changes: 3 additions & 3 deletions rosserial_python/src/rosserial_python/SerialClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class RosSerialServer:
operations (e.g. publish/subscribe) from its connection to the rest of ros.
"""
def __init__(self, tcp_portnum, fork_server=False):
print "Fork_server is: ", fork_server
print("Fork_server is: ", fork_server)
self.tcp_portnum = tcp_portnum
self.fork_server = fork_server

Expand All @@ -234,7 +234,7 @@ def listen(self):

while True:
#accept connections
print "waiting for socket connection"
print("waiting for socket connection")
(clientsocket, address) = self.serversocket.accept()

#now do something with the clientsocket
Expand Down Expand Up @@ -402,7 +402,7 @@ def __init__(self, port=None, baud=57600, timeout=5.0, fix_pyserial_for_test=Fal
def requestTopics(self):
""" Determine topics to subscribe/publish. """
rospy.loginfo('Requesting topics...')

# TODO remove if possible
if not self.fix_pyserial_for_test:
with self.read_lock:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@

# need correct inputs
if (len(sys.argv) < 2):
print __usage__
print(__usage__)
exit()

# get output path
path = sys.argv[1]
if path[-1] == "/":
path = path[0:-1]
print "\nExporting to %s" % path
print("\nExporting to %s" % path)

rospack = rospkg.RosPack()

Expand Down
6 changes: 3 additions & 3 deletions rosserial_vex_v5/src/rosserial_vex_v5/make_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@

# need correct inputs
if (len(sys.argv) < 2):
print __usage__
print(__usage__)
exit()

# get output path
path = sys.argv[1]
if path[-1] == "/":
path = path[0:-1]
print "\nExporting to %s" % path
print("\nExporting to %s" % path)

rospack = rospkg.RosPack()

Expand Down
8 changes: 4 additions & 4 deletions rosserial_windows/src/rosserial_windows/make_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
THIS_PACKAGE = "rosserial_windows"

__usage__ = """
make_libraries.py generates the Windows rosserial library files. It
make_libraries.py generates the Windows rosserial library files. It
requires the location of your project's ros_lib folder.

rosrun rosserial_windows make_libraries.py <output_path>
Expand Down Expand Up @@ -71,14 +71,14 @@

# need correct inputs
if (len(sys.argv) < 2):
print __usage__
print(__usage__)
exit()

# get output path
path = sys.argv[1]
if path[-1] == "/":
path = path[0:-1]
print "\nExporting to %s" % path
print("\nExporting to %s" % path)

rospack = rospkg.RosPack()

Expand Down
52 changes: 26 additions & 26 deletions rosserial_xbee/scripts/setup_xbee.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@
import serial
import yaml
import sys
import time
import time

from optparse import OptionParser

#
#

help = """
%prog [options] port my_adr

setup_xbee.py is a configuration script for Xbees. It takes
setup_xbee.py is a configuration script for Xbees. It takes
factory fresh xbee and programs it to work with your rosserial network.
If XBee is not factory fresh, use Digi's X-CTU software to program it.

port : serial port of port of the xbee (/dev/ttyUSB0)
my_adr: MY address is the 16 bit address of this xbee in the
my_adr: MY address is the 16 bit address of this xbee in the
network. This must be a unique address in the network.
This address is always 0 for the coordinator. """
parser = OptionParser(usage=help)
Expand All @@ -67,18 +67,18 @@ def send(port, cmd):
for c in cmd+'\r':
port.write(c)
time.sleep(0.06)

def setAT(port, cmd):
port.flushInput()
send(port, 'AT'+cmd)
rsp = port.readline()
print rsp
print(rsp)
if 'OK' in rsp:
return True
else :
return False

baud_lookup= { 1200 : 0,
baud_lookup= { 1200 : 0,
2400 : 1,
4800 : 2,
9600 : 3,
Expand All @@ -88,9 +88,9 @@ def setAT(port, cmd):
115200 : 7}



def beginAtMode(port):

for i in range(0,3):
port.write('+')
time.sleep(0.05)
Expand All @@ -101,30 +101,30 @@ def beginAtMode(port):
return False

if __name__ == '__main__':

opts, args = parser.parse_args()

if len(args) < 2:
print "Not enough arguments!"
print("Not enough arguments!")
exit()

baud = 57600
port_name = args[0]
my_address = int(args[1])

port = serial.Serial(port_name, baud, timeout=1.5)

if beginAtMode(port):
print "Connected to the XBee"
print("Connected to the XBee")
else:
print "Failed to connect to the XBee"
print("Failed to connect to the XBee")
exit()


cmd = ''
if (opts.coordinator):
cmd += 'AP2,CE1,' #API mode 2, and enable coordinator

cmd += 'MY%d,'%int(args[1]) #set the xbee address
cmd += 'BD%d,'%baud_lookup[57600] #set the xbee to interface at 57600 baud
cmd += 'ID%d,'%opts.pan_id
Expand All @@ -134,20 +134,20 @@ def beginAtMode(port):
cmd += 'RO5,' #sets packetization timeout to 5 characters
cmd += 'WR' #wrtie the commands to nonvolatile memory


if setAT(port, 'RE'): #reset the xbee
print "XBee reset"
print("XBee reset")
else:
print "Reset failed"
print("Reset failed")
exit()
beginAtMode(port)
time.sleep(1)
print "Sending command : ", cmd
print("Sending command : ", cmd)

if setAT(port, cmd):
print "XBee sucessfully programed!"
print("XBee sucessfully programed!")
else:
print "XBee programming failed. Try again and then investigate using X-CTU"
print("XBee programming failed. Try again and then investigate using X-CTU")