def _generatePythonPath(self, pkg): """ roslib.launcher Recursive subroutine for building dependency list and Python path. @param pkg: Name of package for which Python paths should be generated. @type pkg: str """ if pkg in self._packages: return [] # short-circuit if this is a catkin-ized package m = self._rp.get_manifest(pkg) if m.is_catkin: self._packages.add(pkg) return [] packages = self._getDepends(pkg) packages.append(pkg) paths = [] try: for p in packages: m = self._rp.get_manifest(p) d = self._rp.get_path(p) self._appendPackagePaths(m, paths, d) self._packages.add(p) except: self._packages.discard(pkg) raise return paths
def packages_of(stack, env=os.environ): """ @return: name of packages that are part of stack @rtype: [str] @raise InvalidROSStackException: if stack cannot be located @raise ValueError: if stack name is invalid """ # record settings for error messages ros_root = env[ROS_ROOT] ros_package_path = env.get(ROS_PACKAGE_PATH, '') if not stack: raise ValueError("stack name not specified") stack_dir = get_stack_dir(stack) if stack_dir is None: raise InvalidROSStackException("Cannot locate installation of stack %s. ROS_ROOT[%s] ROS_PACKAGE_PATH[%s]"%(stack, ros_root,ros_package_path)) packages = [] l = [os.path.join(stack_dir, d) for d in os.listdir(stack_dir)] # kwc: this really is just a 1-directory reimplementation of # list_pkgs(). Should merge implementations, though have to deal # with issues of cache, etc... while l: d = l.pop() if os.path.isdir(d): if roslib.packages.is_pkg_dir(d): p = os.path.basename(d) # this is sometimes true if we've descended into a build directory if not p in packages: packages.append(p) elif os.path.exists(os.path.join(d, 'rospack_nosubdirs')): # don't descend pass elif os.path.basename(d) not in ['build', '.svn', '.git']: #recurse l.extend([os.path.join(d, e) for e in os.listdir(d)]) return packages
def package_manifests_of(stack_dir): """ @return: list of package names and manifest file paths for stack dir. These will be returned as a list of (name, path) pairs. @rtype: [(str, str)] """ # Unary stack check m_file = os.path.join(stack_dir, 'manifest.xml') if os.path.isfile(m_file): return [(os.path.basename(os.path.abspath(stack_dir)), m_file),] l = [os.path.join(stack_dir, d) for d in os.listdir(stack_dir)] manifests = [] packages = [] while l: d = l.pop() if os.path.isdir(d): if roslib.packages.is_pkg_dir(d): p = os.path.basename(d) m_file = os.path.join(d, 'manifest.xml') # this is sometimes true if we've descended into a build directory if not p in packages: packages.append(p) manifests.append((p, m_file)) elif os.path.exists(os.path.join(d, 'rospack_nosubdirs')): # don't descend pass elif os.path.basename(d) not in ['build', '.svn', '.git']: #recurse l.extend([os.path.join(d, e) for e in os.listdir(d)]) return manifests