5 from rospkg 
import RosPack
 
    6 from rospkg.common 
import MANIFEST_FILE, PACKAGE_FILE
 
    7 from subprocess 
import Popen, PIPE
 
    9 from xml.etree 
import ElementTree
 
   17     plugins := {name: spec, name: spec, ...} 
   18     spec := {class: class, args: args} 
   23     plugin_keys = plugins.keys()
 
   25     for instance_name 
in plugin_keys:
 
   26       instance_spec = plugins[instance_name]
 
   27       instance_class = instance_spec[
"class"]
 
   28       instance_args = instance_spec[
"args"]
 
   30         rospy.logerr(
'cannot find %s in plugins for %s' % (instance_class,
 
   35           module_name, class_from_class_type = module_path.rsplit(
'.', 1)
 
   36           module = __builtin__.__import__(module_name, 
 
   37                                           fromlist=[class_from_class_type],
 
   39           class_ref = getattr(module, class_from_class_type, 
None)
 
   41             rospy.logfatal(
'cannot find %s' % (class_from_class_type))
 
   43             self.
plugins.append(class_ref(instance_name, instance_args))
 
   44             self.
plugins[-1].registerManager(manager)
 
   46           rospy.logerr(
'failed to load %s' % (instance_class))
 
   47           traceback.print_exc(file=sys.stdout)
 
   51     load plugins of jsk_teleop_joy defined in the packages. 
   54     p = Popen([
"rospack", 
'plugins', 
'--attrib', 
'plugin', self.
package_name],
 
   59     output = p.stdout.readlines()
 
   60     for output_line 
in output:
 
   61       package_name = output_line.split(
' ')[0]
 
   62       xml_path = output_line.split(
' ')[1].strip()
 
   63       if os.path.isfile(xml_path):
 
   65           root = ElementTree.parse(xml_path)
 
   67           rospy.logerr(
"failed to open %s" % (xml_path))
 
   68         for library_elem 
in root.getiterator(
'library'):
 
   69           for class_elem 
in library_elem.getiterator(
'class'):
 
   70             items = class_elem.attrib
 
   71             if 'name' not in items:
 
   72               rospy.logerr(
'class tag of %s does not have name attribute'  
   76               if 'type' not in items:
 
   77                 rospy.logerr(
'%s does not have type attribute' % (name))
 
   79                 plugin_name = items[
'type']