Skip to content

Commit

Permalink
Merge pull request #28 from ros/resolve_msgs_from_dry
Browse files Browse the repository at this point in the history
resolve message classes from dry packages (fix ros/ros_comm#293)
  • Loading branch information
dirk-thomas committed May 5, 2014
2 parents 5e5265d + a0b04c4 commit c3ae641
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/genpy/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,29 @@ def _get_message_or_service_class(type_str, message_type, reload_on_error=False)
else:
raise ValueError("message type is missing package name: %s"%str(message_type))
pypkg = val = None
try:
# import the package and return the class
pypkg = __import__('%s.%s'%(package, type_str))
val = getattr(getattr(pypkg, type_str), base_type)
try:
# import the package
pypkg = __import__('%s.%s' % (package, type_str))
except ImportError:
val = None
except AttributeError:
val = None
# try importing from dry package if available
try:
from roslib import load_manifest
from roslib.packages import InvalidROSPkgException
try:
load_manifest(package)
try:
pypkg = __import__('%s.%s' % (package, type_str))
except ImportError:
pass
except InvalidROSPkgException:
pass
except ImportError:
pass
if pypkg:
try:
val = getattr(getattr(pypkg, type_str), base_type)
except AttributeError:
pass

# 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
Expand Down

0 comments on commit c3ae641

Please sign in to comment.