def __call__(self, prefix, parsed_args, **kwargs): package_name = getattr(parsed_args, self.package_name_key) try: paths = get_executable_paths(package_name=package_name) except PackageNotFound: return [] return [os.path.basename(p) for p in paths]
def run_standalone_container(*, container_node_name): """Run a standalone component container.""" try: paths = get_executable_paths(package_name='rclcpp_components') except PackageNotFound: raise RuntimeError("Package 'rclcpp_components' not found") executable_path = next((p for p in paths if 'component_container' in p), None) if executable_path is None: raise RuntimeError('No component container node found!') return subprocess.Popen([executable_path, '__node:=' + container_node_name])
def main(self, *, args): if args.package_name is None: package_names = get_package_names() else: package_names = [args.package_name] for package_name in sorted(package_names): try: paths = get_executable_paths(package_name=package_name) except PackageNotFound: if args.package_name is None: assert False, 'This should never happen' raise RuntimeError(f"Package '{args.package_name}' not found") for path in sorted(paths): if args.full_path: print(path) else: print(package_name, os.path.basename(path))
def get_executable_path(*, package_name, executable_name): paths = get_executable_paths(package_name=package_name) paths2base = {} for p in paths: basename = os.path.basename(p) if basename == executable_name: # pick exact match paths2base[p] = basename elif sys.platform == 'win32': # check extensions listed in PATHEXT for match without extension pathext = os.environ.get('PATHEXT', '').lower().split(os.pathsep) ext = os.path.splitext(basename)[1].lower() if ext in pathext and basename[:-len(ext)] == executable_name: # pick match because of known extension paths2base[p] = basename if not paths2base: return None if len(paths2base) > 1: raise MultipleExecutables(paths2base.keys()) return list(paths2base.keys())[0]