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

use print function and not statement #92

Merged
merged 1 commit into from
Jul 18, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions scripts/dynparam
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#
# Revision $Id$
from __future__ import print_function

NAME='dynparam'
import roslib; roslib.load_manifest('dynamic_reconfigure')
Expand All @@ -46,7 +47,7 @@ def do_list():
connect()
list = dynamic_reconfigure.find_reconfigure_services()
for s in list:
print s
print(s)

def do_set_from_parameters():
usage = """Usage: %prog set_from_parameters [options] node
Expand Down Expand Up @@ -120,9 +121,9 @@ Examples:
try:
set_params(node, values_dict, timeout=options.timeout)
except rospy.service.ServiceException:
print 'couldn\'t set parameters at node %s' % node
print('couldn\'t set parameters at node %s' % node)
except rospy.exceptions.ROSException:
print 'couldn\'t set parameters at node %s' % node
print('couldn\'t set parameters at node %s' % node)

def do_get():
usage = "Usage: %prog get [options] node"
Expand All @@ -139,7 +140,7 @@ def do_get():
connect()
params = get_params(node, timeout=options.timeout)
if params is not None:
print params
print(params)

def do_load():
usage = "Usage: %prog load [options] node file"
Expand Down Expand Up @@ -190,7 +191,7 @@ def do_dump():
finally:
f.close()

print "couldn't get parameters from node %s" % node
print("couldn't get parameters from node %s" % node)

def get_params(node, timeout=None):
client = dynamic_reconfigure.client.Client(node, timeout=timeout)
Expand All @@ -200,14 +201,14 @@ def set_params(node, params, timeout=None):
client = dynamic_reconfigure.client.Client(node, timeout=timeout)
try:
client.update_configuration(params)
except dynamic_reconfigure.DynamicReconfigureParameterException, e:
print 'error updating parameters: ' + str(e)
except dynamic_reconfigure.DynamicReconfigureParameterException as e:
print('error updating parameters: ' + str(e))

def add_timeout_option(parser):
parser.add_option('-t', '--timeout', action='store', type='float', default=None, help='timeout in secs')

def print_usage():
print """dynparam is a command-line tool for getting, setting, and
print("""dynparam is a command-line tool for getting, setting, and
deleting parameters of a dynamically configurable node.

Commands:
Expand All @@ -219,7 +220,7 @@ Commands:
\tdynparam list list configurable nodes

Type dynparam <command> -h for more detailed usage, e.g. 'dynparam get -h'
"""
""")
sys.exit(1)

def connect():
Expand Down
7 changes: 4 additions & 3 deletions scripts/reconfigure_gui
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
from __future__ import print_function

if __name__ == '__main__':
print '\033[91m' + "reconfigure_gui has moved!\n" + '\033[0m'
print " Try: " + '\033[92m' + "rosrun rqt_reconfigure rqt_reconfigure\n" + '\033[0m'
print " If you see this as part of a tutorial or a script, please update to reflect this change."
print('\033[91m' + "reconfigure_gui has moved!\n" + '\033[0m')
print(" Try: " + '\033[92m' + "rosrun rqt_reconfigure rqt_reconfigure\n" + '\033[0m')
print(" If you see this as part of a tutorial or a script, please update to reflect this change.")
6 changes: 3 additions & 3 deletions src/dynamic_reconfigure/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
example server implementation (L{DynamicReconfigureServer}).
"""

from __future__ import with_statement
from __future__ import print_function, with_statement

try:
import roslib; roslib.load_manifest('dynamic_reconfigure')
Expand Down Expand Up @@ -99,7 +99,7 @@ def get_configuration(self, timeout=None):
"""
if timeout is None or timeout == 0.0:
if self.get_configuration(timeout=1.0) is None:
print >> sys.stderr, 'Waiting for configuration...'
print('Waiting for configuration...', file=sys.stderr)

with self._cv:
while self.config is None:
Expand Down Expand Up @@ -306,7 +306,7 @@ def _get_service_proxy(self, suffix, timeout):
try:
rospy.wait_for_service(service_name, 1.0)
except rospy.exceptions.ROSException:
print >> sys.stderr, 'Waiting for service %s...' % service_name
print('Waiting for service %s...' % service_name, file=sys.stderr)
rospy.wait_for_service(service_name, timeout)
else:
rospy.wait_for_service(service_name, timeout)
Expand Down
111 changes: 56 additions & 55 deletions src/dynamic_reconfigure/parameter_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
## @todo
# Need to check types of min max and default
# Need to put sane error on exceptions
from __future__ import print_function

import roslib; roslib.load_manifest("dynamic_reconfigure")
import roslib.packages
Expand Down Expand Up @@ -316,33 +317,33 @@ def generate(self, pkgname, nodename, name):
except:
pass
try:
#print '**************************************************************'
#print '**************************************************************'
print Template("Generating reconfiguration files for $name in $pkgname").\
substitute(name=self.name, pkgname = self.pkgname)
#print '**************************************************************'
#print '**************************************************************'
#print('**************************************************************')
#print('**************************************************************')
print(Template("Generating reconfiguration files for $name in $pkgname").\
substitute(name=self.name, pkgname = self.pkgname))
#print('**************************************************************')
#print('**************************************************************')
self.generatecpp()
self.generatedoc()
self.generatewikidoc()
self.generateusage()
self.generatepy()
self.deleteobsolete()
except Exception, e:
print "Error building srv %s.srv"%name
except Exception as e:
print("Error building srv %s.srv"%name)
import traceback
traceback.print_exc()
exit(1)

def generatewikidoc(self):
self.mkdir("docs")
f = open(os.path.join(self.pkgpath, "docs", self.msgname+".wikidoc"), 'w')
print >> f, \
print(
"""# Autogenerated param section. Do not hand edit.
param {
group.0 {
name=Dynamically Reconfigurable Parameters
desc=See the [[dynamic_reconfigure]] package for details on dynamically reconfigurable parameters."""
desc=See the [[dynamic_reconfigure]] package for details on dynamically reconfigurable parameters.""", file=f)
i=-1
for param in self.group.get_parameters():
i=i+1
Expand All @@ -354,59 +355,59 @@ def generatewikidoc(self):
except:
if param['type'] == int_t or param['type'] == double_t:
range = Template("Range: $min to $max").substitute(param)
print >> f, Template(
print(Template(
"""$i.name= ~$name
$i.default= $default
$i.type= $type
$i.desc=$description $range"""
$i.desc=$description $range""", file=f)
).substitute(param, range = range, i = i)
print >> f,"}\n}\n# End of autogenerated section. You may edit below."
print("}\n}\n# End of autogenerated section. You may edit below.", file=f)
f.close()

def generateusage(self):
self.mkdir("docs")
f = open(os.path.join(self.pkgpath, "docs", self.msgname+"-usage.dox"), 'w')
#print >> f, "/**"
print >> f, "\\subsubsection usage Usage"
print >> f, '\\verbatim'
print >> f, Template('<node name="$nodename" pkg="$pkgname" type="$nodename">').\
substitute(pkgname = self.pkgname, nodename = self.nodename)
#print("/**", file=f)
print("\\subsubsection usage Usage", file=f)
print('\\verbatim', file=f)
print(Template('<node name="$nodename" pkg="$pkgname" type="$nodename">').\
substitute(pkgname = self.pkgname, nodename = self.nodename), file=f)
for param in self.group.get_parameters():
print >> f, Template(' <param name="$name" type="$type" value="$default" />').substitute(param)
print >> f, '</node>'
print >> f, '\\endverbatim'
print >> f
#print >> f, "*/"
print(Template(' <param name="$name" type="$type" value="$default" />').substitute(param), file=f)
print('</node>', file=f)
print('\\endverbatim', file=f)
print("", file=f)
#print("*/", file=f)
f.close()

def generatedoc(self):
self.mkdir("docs")
f = open(os.path.join(self.pkgpath, "docs", self.msgname+".dox"), 'w')
#print >> f, "/**"
print >> f, "\\subsubsection parameters ROS parameters"
print >> f
print >> f, "Reads and maintains the following parameters on the ROS server"
print >> f
#print("/**", file=f)
print("\\subsubsection parameters ROS parameters", file=f)
print("", file=f)
print("Reads and maintains the following parameters on the ROS server", file=f)
print("", file=f)
for param in self.group.get_parameters():
print >> f, Template("- \\b \"~$name\" : \\b [$type] $description min: $min, default: $default, max: $max").substitute(param)
print >> f
#print >> f, "*/"
print(Template("- \\b \"~$name\" : \\b [$type] $description min: $min, default: $default, max: $max").substitute(param), file=f)
print("", file=f)
#print("*/", file=f)
f.close()

def generateusage(self):
self.mkdir("docs")
f = open(os.path.join(self.pkgpath, "docs", self.msgname+"-usage.dox"), 'w')
#print >> f, "/**"
print >> f, "\\subsubsection usage Usage"
print >> f, '\\verbatim'
print >> f, Template('<node name="$nodename" pkg="$pkgname" type="$nodename">').\
substitute(pkgname = self.pkgname, nodename = self.nodename)
#print("/**", file=f)
print("\\subsubsection usage Usage", file=f)
print('\\verbatim', file=f)
print(Template('<node name="$nodename" pkg="$pkgname" type="$nodename">').\
substitute(pkgname = self.pkgname, nodename = self.nodename), file=f)
for param in self.group.get_parameters():
print >> f, Template(' <param name="$name" type="$type" value="$default" />').substitute(param)
print >> f, '</node>'
print >> f, '\\endverbatim'
print >> f
#print >> f, "*/"
print(Template(' <param name="$name" type="$type" value="$default" />').substitute(param), file=f)
print('</node>', file=f)
print('\\endverbatim', file=f)
print('', file=f)
#print("*/", file=f)
f.close()

def crepr(self, param, val):
Expand Down Expand Up @@ -545,31 +546,31 @@ def deleteobsolete(self): ### @todo remove this after the transition period.
# def generatemsg(self):
# self.mkdir("msg")
# f = open(os.path.join(self.pkgpath, "msg", self.msgname+".msg"), 'w')
# print >> f, "# This is an autogerenated file. Please do not edit."
# print >> f, ""
# print("# This is an autogerenated file. Please do not edit.", file=f)
# print("", file=f)
# for param in self.parameters:
# print >> f, Template("$type $name # $description").substitute(param, type=self.msgtype(param['type']))
# print(Template("$type $name # $description").substitute(param, type=self.msgtype(param['type'])), file=f)
# f.close()
#
# def generategetsrv(self):
# self.mkdir("srv")
# f = open(os.path.join(self.pkgpath, "srv", "Get"+self.msgname+".srv"), 'w')
# print >> f, "# This is an autogerenated file. Please do not edit."
# print >> f, ""
# print >> f, "---"
# print >> f, self.msgname, "config", "# Current configuration of node."
# print >> f, self.msgname, "defaults", "# Minimum values where appropriate."
# print >> f, self.msgname, "min", "# Minimum values where appropriate."
# print >> f, self.msgname, "max", "# Maximum values where appropriate."
# print("# This is an autogerenated file. Please do not edit.", file=f)
# print("", file=f)
# print("---", file=f)
# print(self.msgname, "config", "# Current configuration of node.", file=f)
# print(self.msgname, "defaults", "# Minimum values where appropriate.", file=f)
# print(self.msgname, "min", "# Minimum values where appropriate.", file=f)
# print(self.msgname, "max", "# Maximum values where appropriate.", file=f)
# f.close()
#
# def generatesetsrv(self):
# self.mkdir("srv")
# f = open(os.path.join(self.pkgpath, "srv", "Set"+self.msgname+".srv"), 'w')
# print >> f, "# This is an autogerenated file. Please do not edit."
# print >> f, self.msgname, "config", "# Requested node configuration."
# print >> f, "---"
# print >> f, self.msgname, "config", "# What the node's configuration was actually set to."
# print("# This is an autogerenated file. Please do not edit.", file=f)
# print(self.msgname, "config", "# Requested node configuration.", file=f)
# print("---", file=f)
# print(self.msgname, "config", "# What the node's configuration was actually set to.", file=f)
# f.close()

def generatepy(self):
Expand Down
Loading