4343
4444from __future__ import print_function
4545
46+ from __future__ import absolute_import
4647import argparse
4748import logging
4849import os
@@ -434,9 +435,9 @@ def __load_capabilities(self):
434435 spec_index .remove_provider (provider .name )
435436 self .__spec_index = spec_index
436437 # Prune spec_file_index
437- spec_paths = spec_index .interface_paths .values () + \
438- spec_index .semantic_interface_paths .values () + \
439- spec_index .provider_paths .values ()
438+ spec_paths = list ( spec_index .interface_paths .values () ) + \
439+ list ( spec_index .semantic_interface_paths .values () ) + \
440+ list ( spec_index .provider_paths .values () )
440441 for package_name , package_dict in self .spec_file_index .items ():
441442 for spec_type in ['capability_interface' , 'semantic_capability_interface' , 'capability_provider' ]:
442443 package_dict [spec_type ][:] = [path for path in package_dict [spec_type ] if path in spec_paths ]
@@ -540,7 +541,7 @@ def _handle_capability_events(self, event):
540541 # Update the capability
541542 capability = event .capability
542543 with self .__graph_lock :
543- if capability not in self .__capability_instances .keys ():
544+ if capability not in list ( self .__capability_instances .keys () ):
544545 rospy .logerr ("Unknown capability instance: '{0}'"
545546 .format (capability ))
546547 return
@@ -585,7 +586,7 @@ def __cleanup_graph(self):
585586 if cap .started_by == USER_SERVICE_REASON :
586587 # Started by user, do not garbage collect this
587588 continue
588- rdepends = get_reverse_depends (cap .interface , self .__capability_instances .values ())
589+ rdepends = get_reverse_depends (cap .interface , list ( self .__capability_instances .values () ))
589590 if rdepends :
590591 # Someone depends on me, do not garbage collect this
591592 rospy .logdebug ("Keeping the '{0}' provider of the '{1}' interface, " .format (cap .name , cap .interface ) +
@@ -636,7 +637,7 @@ def __stop_capability(self, name):
636637 "which is not in the list of capability instances." )
637638 return
638639 capability = self .__capability_instances [name ]
639- rdepends = get_reverse_depends (name , self .__capability_instances .values ())
640+ rdepends = get_reverse_depends (name , list ( self .__capability_instances .values () ))
640641 for cap in rdepends :
641642 if cap .state in ['stopping' , 'terminated' ]: # pragma: no cover
642643 # It is possible that this cap was stopped by another cap in this list
@@ -685,7 +686,7 @@ def __get_providers_for_interface(self, interface, allow_semantic=False):
685686 return providers # Could be empty
686687
687688 def __start_capability (self , capability , preferred_provider ):
688- if capability not in self .__spec_index .interfaces .keys () + self .__spec_index .semantic_interfaces .keys ():
689+ if capability not in list ( self .__spec_index .interfaces .keys ()) + list ( self .__spec_index .semantic_interfaces .keys () ):
689690 raise RuntimeError ("Capability '{0}' not found." .format (capability ))
690691 # If no preferred provider is given, use the default
691692 preferred_provider = preferred_provider or self .__default_providers [capability ]
@@ -909,9 +910,9 @@ def handle_get_providers(self, req):
909910
910911 def _handle_get_providers (self , req ):
911912 if req .interface :
912- if req .interface not in self .__spec_index .interfaces .keys () + self .__spec_index .semantic_interfaces .keys ():
913+ if req .interface not in list ( self .__spec_index .interfaces .keys ()) + list ( self .__spec_index .semantic_interfaces .keys () ):
913914 raise RuntimeError ("Capability Interface '{0}' not found." .format (req .interface ))
914- providers = self .__get_providers_for_interface (req .interface , allow_semantic = req .include_semantic ).keys ()
915+ providers = list ( self .__get_providers_for_interface (req .interface , allow_semantic = req .include_semantic ).keys () )
915916 default_provider = self .__default_providers [req .interface ]
916917 else :
917918 providers = self .__spec_index .provider_names
@@ -942,7 +943,7 @@ def _handle_get_running_capabilities(self, req):
942943 running_capability .capability = Capability (instance .interface , instance .name )
943944 running_capability .started_by = instance .started_by
944945 running_capability .pid = instance .pid
945- rdepends = get_reverse_depends (instance .interface , self .__capability_instances .values ())
946+ rdepends = get_reverse_depends (instance .interface , list ( self .__capability_instances .values () ))
946947 for dep in rdepends :
947948 running_capability .dependent_capabilities .append (Capability (dep .interface , dep .name ))
948949 resp .running_capabilities .append (running_capability )
@@ -961,7 +962,7 @@ def handle_get_remappings(self, req):
961962
962963 def _handle_get_remappings (self , req ):
963964 interface = None
964- if req .spec in self .__capability_instances .keys ():
965+ if req .spec in list ( self .__capability_instances .keys () ):
965966 interface = self .__capability_instances [req .spec ]
966967 else :
967968 providers = dict ([(i .provider .name , i ) for i in self .__capability_instances .values ()])
0 commit comments