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 rostopic hz and bw in Python 3 #1126

Merged
merged 7 commits into from
Aug 15, 2017
12 changes: 2 additions & 10 deletions tools/rostopic/src/rostopic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,11 +1488,7 @@ def _rostopic_cmd_hz(argv):
if len(args) == 0:
parser.error("topic must be specified")
try:
if options.window_size != -1:
import string
window_size = string.atoi(options.window_size)
else:
window_size = options.window_size
window_size = int(options.window_size)
except:
parser.error("window size must be an integer")

Expand Down Expand Up @@ -1540,11 +1536,7 @@ def _rostopic_cmd_bw(argv=sys.argv):
if len(args) > 1:
parser.error("you may only specify one input topic")
try:
if options.window_size:
import string
window_size = string.atoi(options.window_size)
else:
window_size = options.window_size
window_size = int(options.window_size) if options.window_size else None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will set the variable to None in case the option is 0. So this should check for None explicitly:

int(options.window_size) if options.window_size is not None else None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a window_size of 0 even make sense for rostopic bw? Just falling back to the default might be better in that case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is what the user asked for why do something else? This magic would then also need to be documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user is always right 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user is always right

Oh no, but we give him what was asked for anyway 😉 🔥

except:
parser.error("window size must be an integer")
topic = rosgraph.names.script_resolve_name('rostopic', args[0])
Expand Down