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 various issues discovered by flake8 #241

Merged
merged 1 commit into from
Feb 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/roslib/src/roslib/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def _get_message_or_service_class(type_str, message_type, reload_on_error=False)
# this logic is mainly to support rosh, so that a user doesn't
# have to exit a shell just because a message wasn't built yet
if val is None and reload_on_error:
try:
reload # Python 2
except NameError:
from importlib import reload # Python 3
try:
if pypkg:
reload(pypkg)
Expand Down
2 changes: 1 addition & 1 deletion core/roslib/src/roslib/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _get_pkg_subdir_by_dir(package_dir, subdir, required=True, env=None):
elif required and not os.path.isdir(d):
try:
os.makedirs(d) # lazy create
except error:
except os.error:
raise Exception("""Package '%(package)s' is improperly configured:
Cannot create a '%(subdir)s' directory in %(package_dir)s.
Please check permissions and try again.
Expand Down
2 changes: 1 addition & 1 deletion core/roslib/src/roslib/scriptutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def script_resolve_name(script_name, name):
return name
# Check for private name: ~name resolves to /caller_id/name
elif roslib.names.is_private(name):
return ns_join(roslib.names.make_caller_id(script_name), name[1:])
return roslib.names.ns_join(roslib.names.make_caller_id(script_name), name[1:])
return roslib.names.get_ros_namespace() + name


Expand Down
1 change: 1 addition & 0 deletions tools/rosunit/src/rosunit/baretest.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def start(self):
elif self.cwd == 'cwd':
cwd = os.getcwd()
elif self.cwd == 'ros-root':
from roslib.rosenv import get_ros_root
cwd = get_ros_root()
else:
cwd = rospkg.get_ros_home()
Expand Down
7 changes: 6 additions & 1 deletion tools/rosunit/src/rosunit/pmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@ def kill_process(self, name):
method was called.
@rtype: bool
"""
if not isinstance(name, basestring):
def is_string_type(obj):
try:
return isinstance(obj, basestring)
except NameError:
return isinstance(obj, str)
if not is_string_type(name):
raise PmonException('kill_process takes in a process name but was given: %s' % name)
printlog('[%s] kill requested' % name)
with self.plock:
Expand Down
4 changes: 1 addition & 3 deletions tools/rosunit/src/rosunit/xmlrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

from __future__ import print_function

__revision__ = '$Id$'

import codecs
import os.path
import re
Expand Down Expand Up @@ -237,7 +235,7 @@ def run(self, test):
classname = class_.__module__ + '.' + class_.__name__
if self._stream is None:
filename = 'TEST-%s.xml' % classname
stream = file(os.path.join(self._path, filename), 'w')
stream = open(os.path.join(self._path, filename), 'w')
stream.write('<?xml version="1.0" encoding="utf-8"?>\n')
else:
stream = self._stream
Expand Down