def __init__(self, selected_names=[], excludes=[], with_stacks=False, hide_transitives=True, depth=1): """ :param hide_transitives: if true, then dependency of children to grandchildren will be hidden if parent has same dependency """ self.rospack = rospkg.RosPack() self.rosstack = rospkg.RosStack() self.stacks = {} self.packages = {} self.edges = [] self.excludes = excludes self.with_stacks = with_stacks self.depth = depth self.selected_names = selected_names self.hide_transitives = hide_transitives for name in self.selected_names: if name is None or name.strip() == '': continue namefound = False if name in self.rospack.list(): self.add_package_recursively(name) namefound = True if name in self.rosstack.list(): namefound = True for package_name in self.rosstack.packages_of(name): self.add_package_recursively(package_name)
def from_roslaunch(roslaunch_files, env=None): """ @param roslaunch_file: roslaunch_file to load from @type roslaunch_file: str """ if env is None: env = os.environ # can't go any further if launch file doesn't validate l, c = roslaunch.XmlLoader(), roslaunch.ROSLaunchConfig() for f in roslaunch_files: try: l.load(f, c, verbose=False) except roslaunch.RLException as e: raise WtfException("Unable to load roslaunch file [%s]: %s" % (f, str(e))) ctx = WtfContext() ctx.rospack = rospkg.RosPack(rospkg.get_ros_paths(env)) ctx.rosstack = rospkg.RosStack(rospkg.get_ros_paths(env)) ctx.launch_files = roslaunch_files _load_roslaunch(ctx, roslaunch_files) # ctx.pkg and ctx.stack initialized by _load_roslaunch _load_pkg(ctx, ctx.pkg) if ctx.stack: _load_stack(ctx, ctx.stack) _load_env(ctx, env) return ctx
def test_control_data(): if disable: return rospack = rospkg.RosPack() rosstack = rospkg.RosStack() from rosrelease.sourcedeb_support import control_data stack_name = 'python_qt_binding' stack_version = '1.2.3' md5sum = '12345' metadata = control_data(stack_name, stack_version, md5sum, rospack, rosstack) assert metadata['stack'] == stack_name assert metadata['version'] == stack_version assert metadata['description-full'] assert metadata['md5sum'] == md5sum assert 'python-qt4' in metadata['rosdep-keys'] assert 'oneiric' in metadata['rosdeps'], metadata['rosdeps'] assert 'python-qt4' in metadata['rosdeps']['oneiric'] stack_name = 'visualization' metadata = control_data(stack_name, stack_version, md5sum, rospack, rosstack) assert metadata['description-full'] assert 'python_qt_binding' in metadata['depends']
def test_offline(self): cmd = 'roswtf' # point at a different 'master' env = os.environ.copy() env['ROS_MASTER_URI'] = 'http://localhost:11312' rospack = rospkg.RosPack() rosstack = rospkg.RosStack() env['ROS_PACKAGE_PATH'] = rosstack.get_path('ros_comm') + os.pathsep + rospack.get_path('std_msgs') cwd = get_roswtf_path() kwds = { 'env': env, 'stdout': PIPE, 'stderr': PIPE, 'cwd': cwd} # run roswtf nakedly output = Popen([cmd], **kwds).communicate() # - due both a positive and negative test self.assert_('No errors or warnings' in output[0], "OUTPUT[%s]"%str(output)) self.assert_('ERROR' not in output[0], "OUTPUT[%s]"%str(output)) # run roswtf on a simple launch file offline p = os.path.join(get_test_path(), 'min.launch') output = Popen([cmd, p], **kwds).communicate()[0] self.assert_('No errors or warnings' in output, "OUTPUT[%s]"%output) self.assert_('ERROR' not in output, "OUTPUT[%s]"%output)
def test_confirm_stack_version(): distro = rospkg.distro.load_distro( os.path.join(get_test_path(), 'fuerte.rosdistro')) stack_name = 'common_rosdeps' distro_stack = distro.stacks[stack_name] # checkout the stack twice and make one look like a ROS_PACKAGE_PATH executor = MockExecutor() tmpdir1 = checkout_branch(distro_stack, 'release', executor) tmpdir2 = checkout_branch(distro_stack, 'release', executor) stack_tmpdir1 = os.path.join(tmpdir1, stack_name) stack_tmpdir2 = os.path.join(tmpdir2, stack_name) rosstack = rospkg.RosStack(ros_paths=[stack_tmpdir1]) try: confirm_stack_version(rosstack, stack_tmpdir2, stack_name, '1.0.2') try: confirm_stack_version(rosstack, stack_tmpdir2, stack_name, '0.1.2') assert False, "should raise" except ReleaseException: pass finally: shutil.rmtree(tmpdir1) shutil.rmtree(tmpdir2)
def manifest_depends(ctx): # This rule should probably be cache optimized errors = [] rospack = rospkg.RosPack() rosstack = rospkg.RosStack() stack_list = rosstack.list() #print stack_list for s in ctx.stacks: try: s_deps = [] s_pkgs = _packages_of(rosstack, s) for p in s_pkgs: s_deps.extend(rospack.get_depends(p, implicit=False)) m = rosstack.get_manifest(s) m_file = os.path.join(rosstack.get_path(s), 'stack.xml') for d in m.depends: if not d.name in stack_list: errors.append("%s (%s does not exist)"%(m_file, d)) elif d.name in ['ros', 'ros_comm']: # ros dependency always exists. ros_comm # dependency has implicit connections (msggen), so # we ignore. continue else: pkgs = _packages_of(rosstack, d.name) # check no longer works due to rosdeps chains #if not [p for p in pkgs if p in s_deps]: # errors.append("%s (%s appears to be an unnecessary depend)"%(m_file, d)) except rospkg.ResourceNotFound: # report with a different rule pass return errors
def _init_rosstack(env=None): global _rosstack, _ros_paths if env is None: env = os.environ ros_paths = rospkg.get_ros_paths(env) if ros_paths != _ros_paths: _ros_paths = ros_paths _rosstack = rospkg.RosStack(ros_paths)
def test_convert_html_to_text(): rosstack = rospkg.RosStack() from rosrelease.sourcedeb_support import convert_html_to_text for stack_name in rosstack.list(): m = rosstack.get_manifest(stack_name) converted = convert_html_to_text(m.description) # some stacks do in fact have empty descriptions if stack_name in ['navigation', 'visualization', 'geometry']: assert converted
def test_stack_rosdeps_keys(): if disable: return from rosrelease.rosdep_support import stack_rosdep_keys rospack = rospkg.RosPack() rosstack = rospkg.RosStack() resolved = stack_rosdep_keys('python_qt_binding', rospack, rosstack) assert 'python-qt-bindings' in resolved, resolved assert 'qt4-qmake' in resolved, resolved #no dupes assert len(resolved) == len(list(set(resolved)))
def confirm_stack_version(rosstack, checkout_path, stack_name, stack_version): """ :raises: :exc:`ReleaseException` If declared stack versions do not match declared version """ rosstack_vcs = rospkg.RosStack([checkout_path]) vcs_version = rosstack_vcs.get_stack_version(stack_name) local_version = rosstack.get_stack_version(stack_name) if vcs_version != stack_version: raise ReleaseException( "The version number of stack %s stored in version control does not match specified release version:\n\n%s" % (stack_name, vcs_version)) if local_version != stack_version: raise ReleaseException( "The version number of stack %s on your ROS_PACKAGE_PATH does not match specified release version:\n\n%s" % (stack_name, local_version))
def from_env(env=None): """ Initialize WtfContext from environment. @raise WtfException: if context state cannot be initialized """ if env is None: env = os.environ ctx = WtfContext() ctx.rospack = rospkg.RosPack(rospkg.get_ros_paths(env)) ctx.rosstack = rospkg.RosStack(rospkg.get_ros_paths(env)) _load_env(ctx, env) return ctx
def expand_to_packages(names, env=None): """ Expand names into a list of packages. Names can either be of packages or stacks. @param names: names of stacks or packages @type names: [str] @return: ([packages], [not_found]). expand_packages() returns two lists. The first is of packages names. The second is a list of names for which no matching stack or package was found. Lists may have duplicates. @rtype: ([str], [str]) """ if env is None: env = os.environ ros_paths = rospkg.get_ros_paths(env) rospack = rospkg.RosPack(ros_paths) rosstack = rospkg.RosStack(ros_paths) return rospkg.expand_to_packages(names, rospack, rosstack)
def __init__(self, rospack=None, rosstack=None, underlay_key=None): """ :param underlay_key: If set, all views loaded by this loader will depend on this key. """ if rospack is None: rospack = rospkg.RosPack() if rosstack is None: rosstack = rospkg.RosStack() self._rospack = rospack self._rosstack = rosstack self._rosdep_yaml_cache = {} self._underlay_key = underlay_key # cache computed list of loadable resources self._loadable_resource_cache = None
def __init__(self): self._result_lock = threading.Lock() self.rospack = rospkg.RosPack() self.rosstack = rospkg.RosStack() self.printer = Printer() self.result = {} self.paths = {} self.dependency_tracker = parallel_build.DependencyTracker(rospack=self.rospack) self.flag_tracker = package_stats.PackageFlagTracker(self.dependency_tracker) self.output = {} self.profile = {} self.ros_parallel_jobs = 0 self.build_list = [] self.start_time = time.time() self.log_dir = '' self.logging_enabled = True
def legacy_main(): print("rosrelease-legacy version %s"%(__version__)) executor = get_default_executor() if not check_version(): executor.info("This release script is out-of-date.\nPlease upgrade your release and ros_release scripts") executor.exit(1) print("initializing...") rospack = rospkg.RosPack() rosstack = rospkg.RosStack() try: distros_dir = os.path.join(rospack.get_path('release_resources'), '..', 'distros') except rospkg.ResourceNotFound: executor.error("cannot find 'release_resources' package. Please see release setup instructions") executor.exit(1) try: _legacy_main(executor, rospack, rosstack, distros_dir) except ReleaseException as e: executor.error(str(e)) executor.exit(1)
def from_package(pkg, env=None): """ Initialize WtfContext from package name. @param pkg: package name @type pkg: str @raise WtfException: if context state cannot be initialized """ if env is None: env = os.environ ctx = WtfContext() ctx.rospack = rospkg.RosPack(rospkg.get_ros_paths(env)) ctx.rosstack = rospkg.RosStack(rospkg.get_ros_paths(env)) _load_pkg(ctx, pkg) stack = ctx.rospack.stack_of(pkg) if stack: _load_stack(ctx, stack) _load_env(ctx, env) return ctx
def test_resolve_rosdeps(): from rosrelease.rosdep_support import resolve_rosdeps rospack = rospkg.RosPack() rosstack = rospkg.RosStack() rosdep_keys = ['python-qt-bindings'] resolved = resolve_rosdeps(rosdep_keys, 'oneiric', rospack, rosstack) assert 'python-qt4' in resolved, resolved assert 'python-qt4-dev' in resolved, resolved #no dupes assert len(resolved) == len(list(set(resolved))) rosdep_keys = ['python-empy', 'python-nose'] resolved = resolve_rosdeps(rosdep_keys, 'oneiric', rospack, rosstack) assert set(['python-empy', 'python-nose']) == set(resolved) #no dupes assert len(resolved) == len(list(set(resolved))) try: resolve_rosdeps(['not a key'], 'oneiric', rospack, rosstack) assert False, "should have raised" except KeyError as e: assert 'not a key' in str(e), "[%s]" % e
def from_stack(stack, env=None): """ Initialize WtfContext from stack. @param stack: stack name @type stack: str @raise WtfException: if context state cannot be initialized """ if env is None: env = os.environ ctx = WtfContext() ctx.rospack = rospkg.RosPack(rospkg.get_ros_paths(env)) ctx.rosstack = rospkg.RosStack(rospkg.get_ros_paths(env)) _load_stack(ctx, stack) try: ctx.pkgs = ctx.rosstack.packages_of(stack) except rospkg.ResourceNotFound: # this should be handled elsewhere ctx.pkgs = [] _load_env(ctx, env) return ctx
def readFromROS(): packageName = entryWidgetPackageName.get().strip() try: package = rospkg.RosStack() package.get_manifest(packageName) fileToCheckIfInstall = packageName + "/stack.xml" # version = package.get_manifest(packageName).version except: try: package = rospkg.RosPack() package.get_manifest(packageName) fileToCheckIfInstall = packageName + "/manifest.xml" except: tkMessageBox.showerror(message="The package name is not a ROS stack or package") return entryWidgetFileToCheckIfInstall.insert(0, fileToCheckIfInstall) entryWidgetSourcePath.insert(0, package.get_path(packageName)) entryWidgetMaintainer.insert(0, package.get_manifest(packageName).author) entryWidgetHomepage.insert(0, package.get_manifest(packageName).url) entryWidgetLicense.insert(0, package.get_manifest(packageName).license) entryWidgetBrief.insert(0, package.get_manifest(packageName).brief) entryWidgetDescription.insert(END, package.get_manifest(packageName).description)
def test_offline(self): # this test is disabled for now; now that test_roswtf is part # of ros_comm, the tricks before that were used no longer work cmd = 'roswtf' # pass in special test key to roswtf for ROS_PACKAGE_PATH env = os.environ.copy() rospack = rospkg.RosPack() rosstack = rospkg.RosStack() env['ROS_PACKAGE_PATH'] = os.pathsep.join([ rosstack.get_path('ros_comm'), rospack.get_path('std_msgs'), rosstack.get_path('roscpp_core') ]) cwd = rospack.get_path('roswtf') kwds = {'env': env, 'stdout': PIPE, 'stderr': PIPE, 'cwd': cwd} # run roswtf nakedly in the roswtf directory. Running in # ROS_ROOT effectively make roswtf have dependencies on # every package in the ROS stack, which doesn't work. output, err = Popen([cmd], **kwds).communicate() self.assert_('No errors or warnings' in output, "OUTPUT[%s]\nstderr[%s}" % (output, err)) self.assert_('ERROR' not in output, "CMD [%s] KWDS[%s] OUTPUT[%s]" % (cmd, kwds, output)) # run roswtf on a simple launch file online rospack = rospkg.RosPack() p = os.path.join(rospack.get_path('roswtf'), 'test', 'min.launch') output = Popen([cmd, p], **kwds).communicate()[0] self.assert_('No errors or warnings' in output, "CMD[%s] OUTPUT[%s]" % ([cmd, p], output)) self.assert_('ERROR' not in output, "OUTPUT[%s]" % output)
def test_compute_stack_depends(): # mostly tripwire -- need to scaffold in fake RPP to do better than this rospack = rospkg.RosPack() rosstack = rospkg.RosStack() depends = _compute_stack_depends('geometry', rospack, rosstack) assert 'ros' in depends
class WtfContext(object): """ WtfContext stores common state about the ROS filesystem and online environment. The primary use of this is for convenience (not having to load this state manually) and performance (not having to do the same calculation repeatedly). """ __slots__ = [ 'pkg', 'pkg_dir', 'pkgs', 'stack', 'stack_dir', 'stacks', 'manifest_file', 'manifest', 'env', 'ros_root', 'ros_package_path', 'pythonpath', 'ros_master_uri', 'roslaunch_uris', 'launch_files', 'launch_file_deps', 'launch_file_missing_deps', 'system_state', 'service_providers', 'topics', 'services', 'nodes', 'uri_node_map', 'expected_edges', 'actual_edges', 'unconnected_subscriptions', 'use_sim_time', 'warnings', 'errors', 'rospack', 'rosstack' ] def __init__(self): # main package we are running self.pkg = None self.pkg_dir = None # main stack we are running self.stack = None self.stack_dir = None # - list of all packages involved in this check self.pkgs = [] # - list of all stacks involved in this check self.stacks = [] # manifest location of package that we are running self.manifest_file = None # manifest of package that we are running self.manifest = None # environment variables self.env = {} # provide these for convenience self.ros_root = None self.ros_package_path = None self.pythonpath = None # launch file that is being run self.launch_files = None self.launch_file_deps = None self.launch_file_missing_deps = None # online state self.roslaunch_uris = None self.system_state = None #master.getSystemState self.topics = None self.services = None self.service_providers = None #names of nodes with services self.nodes = None self.uri_node_map = {} self.expected_edges = None self.actual_edges = None self.unconnected_subscriptions = None self.use_sim_time = None # caching rospack instance self.rospack = self.rosstack = None # warnings that we have collected so far self.warnings = [] # errors that we have collected so far self.errors = [] def as_dictionary(self): """ @return: dictionary representation of context, which is useful for producing error messages @rtype: dict """ return dict((s, getattr(self, s)) for s in self.__slots__) @staticmethod def from_roslaunch(roslaunch_files, env=None): """ @param roslaunch_file: roslaunch_file to load from @type roslaunch_file: str """ if env is None: env = os.environ # can't go any further if launch file doesn't validate l, c = roslaunch.XmlLoader(), roslaunch.ROSLaunchConfig() for f in roslaunch_files: try: l.load(f, c, verbose=False) except roslaunch.RLException, e: raise WtfException("Unable to load roslaunch file [%s]: %s" % (f, str(e))) ctx = WtfContext() ctx.rospack = rospkg.RosPack(rospkg.get_ros_paths(env)) ctx.rosstack = rospkg.RosStack(rospkg.get_ros_paths(env)) ctx.launch_files = roslaunch_files _load_roslaunch(ctx, roslaunch_files) # ctx.pkg and ctx.stack initialized by _load_roslaunch _load_pkg(ctx, ctx.pkg) if ctx.stack: _load_stack(ctx, ctx.stack) _load_env(ctx, env) return ctx
def analyze_fuerte_groovy(ros_distro, stack_name, workspace, test_depends_on): print "Testing on distro %s"%ros_distro print "Testing stack %s"%stack_name # global try try: distro_name = ros_distro # set environment print "Setting up environment" env = get_environment() env['INSTALL_DIR'] = os.getcwd() env['STACK_BUILD_DIR'] = env['INSTALL_DIR'] + '/build/' + stack_name env['ROS_PACKAGE_PATH'] = os.pathsep.join([env['INSTALL_DIR']+'/'+STACK_DIR + '/' + stack_name, env['INSTALL_DIR']+'/'+DEPENDS_DIR, env['INSTALL_DIR']+'/'+DEPENDS_ON_DIR, env['ROS_PACKAGE_PATH']]) print "env[ROS_PACKAGE_PATH]: %s"% env['ROS_PACKAGE_PATH'] #return #env['ROS_ROOT'] = '/opt/ros/%s/share/ros'%ros_distro #env['PYTHONPATH'] = env['ROS_ROOT']+'/core/roslib/src' #env['PATH'] = '%s:%s:%s'%(env['QACPPBIN'],env['HTMLVIEWBIN'], os.environ['PATH']) print "Environment set to %s"%str(env) # Create_new/remove_old STACK_DIR,build,doc,cvs folder stack_path = env['INSTALL_DIR']+'/'+STACK_DIR + '/' if os.path.exists(stack_path): shutil.rmtree(stack_path) os.makedirs(stack_path) build_path = env['INSTALL_DIR'] + '/build/' if os.path.exists(build_path): shutil.rmtree(build_path) os.makedirs(build_path) doc_path = env['INSTALL_DIR'] + '/doc/' if os.path.exists(doc_path): shutil.rmtree(doc_path) os.makedirs(doc_path) csv_path = env['INSTALL_DIR'] + '/csv/' if os.path.exists(csv_path): shutil.rmtree(csv_path) os.makedirs(csv_path) snapshots_path = env['INSTALL_DIR'] + '/snapshots/' if os.path.exists(snapshots_path): shutil.rmtree(snapshots_path) # create dummy test results test_results_path = env['INSTALL_DIR'] + '/test_results' if os.path.exists(test_results_path): shutil.rmtree(test_results_path) os.makedirs(test_results_path) test_file= test_results_path + '/test_file.xml' f = open(test_file, 'w') f.write('<?xml version="1.0" encoding="UTF-8"?>\n') f.write('<testsuite tests="1" failures="0" time="1" errors="0" name="dummy test">\n') f.write(' <testcase name="dummy rapport" classname="Results" /> \n') f.write('</testsuite> \n') f.close() # Parse distro file distro_obj = rospkg.distro.load_distro(rospkg.distro.distro_uri(distro_name)) print 'Operating on ROS distro %s'%distro_obj.release_name # Install the stacks to test from source call('echo -e "\033[33;33m Color Text"', env, 'Set output-color for installing to yellow') print 'Installing the stacks to test from source' stack_list = [''] stack_list[0] = stack_name rosinstall = stacks_to_rosinstall(stack_list, distro_obj.stacks, 'devel') rosinstall_file = '%s.rosinstall'%STACK_DIR print 'Generating rosinstall file [%s]'%(rosinstall_file) print 'Contents:\n\n'+rosinstall+'\n\n' with open(rosinstall_file, 'w') as f: f.write(rosinstall) print 'rosinstall file [%s] generated'%(rosinstall_file) call('rosinstall -n %s /opt/ros/%s %s'%(STACK_DIR, distro_name, rosinstall_file), env, 'Install the stacks to test from source.') # get all stack dependencies of stacks we're testing print "Computing dependencies of stacks we're testing" depends_all = [] #for stack in options.stack: stack_dir = os.path.join(STACK_DIR, stack_name) rosstack = rospkg.RosStack(ros_paths=[stack_dir]) depends_one = rosstack.get_depends(stack_name, implicit=False) print 'Dependencies of stack %s: %s'%(stack_name, str(depends_one)) for d in depends_one: #if not d in options.stack and not d in depends_all: if d != stack_name and not d in depends_all: print 'Adding dependencies of stack %s'%d get_depends_all(distro_obj, d, depends_all) print 'Resulting total dependencies of all stacks that get tested: %s'%str(depends_all) if len(depends_all) > 0: #if options.source_only: # Install dependencies from source #print 'Installing stack dependencies from source' #rosinstall = stacks_to_rosinstall(depends_all, distro_obj.released_stacks, 'release-tar') #rosinstall_file = '%s.rosinstall'%DEPENDS_DIR #print 'Generating rosinstall file [%s]'%(rosinstall_file) #print 'Contents:\n\n'+rosinstall+'\n\n' #with open(rosinstall_file, 'w') as f: # f.write(rosinstall) # print 'rosinstall file [%s] generated'%(rosinstall_file) #call('rosinstall -n %s /opt/ros/%s %s'%(DEPENDS_DIR, distro_name, rosinstall_file), env, # 'Install the stack dependencies from source.') # Install Debian packages of stack dependencies print 'Installing debian packages of "%s" dependencies: %s'%(stack_name, str(depends_all)) call('sudo apt-get update', env) call('sudo apt-get install %s --yes'%(stacks_to_debs(depends_all, distro_name)), env) else: print 'Stack(s) %s do(es) not have any dependencies, not installing anything now'%str(stack_name) # Install system dependencies of stacks re're testing print "Installing system dependencies of stacks we're testing" #for stack in options.stack: call('rosdep install -y %s'%stack_name, env, 'Install system dependencies of stack %s'%stack_name) # Get uri data vcs = distro_obj.stacks[stack_name].vcs_config uri_data = {} if vcs.type == 'svn': uri_data['vcs_type'] = 'svn' uri_data['uri'] = vcs.anon_dev uri_data['uri_info'] = 'empty' elif vcs.type == 'git': uri_data['vcs_type'] = 'git' uri_data['uri'] = vcs.anon_repo_uri # Get branch p = subprocess.Popen(["git", "branch"],cwd=r'%s/%s/%s/'%(workspace,STACK_DIR,stack_name), env=env,stdout=subprocess.PIPE) out = p.communicate()[0] branch = 'groovy-devel'#out[2:] uri_data['uri_info'] = branch print "branch: %s"%branch elif vcs.type == 'hg': uri_data['vcs_type'] = 'hg' uri_data['uri'] = vcs.anon_repo_uri # Get revision number p = subprocess.Popen(["hg", "log", "-l", "1", "--template", "{node}"],cwd=r'%s/%s/%s/'%(workspace,STACK_DIR,stack_name), env=env,stdout=subprocess.PIPE) out = p.communicate()[0] revision_number = out[:12] #first 12 numbers represents the revision number uri_data['uri_info'] = revision_number print "revision_number: %s"%revision_number uri = uri_data['uri'] uri_info = uri_data['uri_info'] vcs_type = uri_data['vcs_type'] # Run hudson helper for stacks only call('echo -e "\033[33;34m Color Text"', env, 'Set color from build-output to blue') print "Running Hudson Helper for stacks we're testing" res = 0 for r in range(0, int(0)+1): env['ROS_TEST_RESULTS_DIR'] = env['ROS_TEST_RESULTS_DIR'] + '/' + STACK_DIR + '_run_' + str(r) helper = subprocess.Popen(('%s/jenkins_scripts/code_quality/build_helper.py --dir %s build'%(workspace,STACK_DIR + '/' + stack_name)).split(' '), env=env) helper.communicate() print "helper_return_code is: %s"%(helper.returncode) if helper.returncode != 0: res = helper.returncode # Concatenate filelists call('echo -e "\033[33;0m Color Text"', env, 'Set color to white') print '----------------- Concatenate filelists ----------------- ' stack_dir = STACK_DIR + '/' + str(stack_name) filelist = stack_dir + '/filelist.lst' helper = subprocess.Popen(('%s/jenkins_scripts/code_quality/concatenate_filelists.py --dir %s --filelist %s'%(workspace,stack_dir, filelist)).split(' '), env=env) helper.communicate() print '////////////////// concatenate filelists done ////////////////// \n\n' # Run CMA print '----------------- Run CMA analysis ----------------- ' cmaf = stack_dir + '/' + str(stack_name) helper = subprocess.Popen(('pal QACPP -cmaf %s -list %s'%(cmaf, filelist)).split(' '), env=env) helper.communicate() print '////////////////// cma analysis done ////////////////// \n\n' # Export metrics to yaml and csv files print '----------------- Export metrics to yaml and csv files ----------------- ' print 'stack_dir: %s '%str(stack_dir) print 'stack_name: %s '%str(stack_name) helper = subprocess.Popen(('%s/jenkins_scripts/code_quality/export_metrics_to_yaml.py --path %s --doc doc --csv csv --config %s/jenkins_scripts/code_quality/export_config.yaml --distro %s --stack %s --uri %s --uri_info %s --vcs_type %s'%(workspace,stack_dir,workspace, ros_distro, stack_name, uri, uri_info, vcs_type)).split(' '), env=env) helper.communicate() print '////////////////// export metrics to yaml and csv files done ////////////////// \n\n' # Push results to server print '----------------- Push results to server ----------------- ' helper = subprocess.Popen(('%s/jenkins_scripts/code_quality/push_results_to_server.py --path %s --doc doc'%(workspace,stack_dir)).split(' '), env=env) helper.communicate() print '////////////////// push results to server done ////////////////// \n\n' # Upload results to QAVerify print ' ----------------- upload results to QAVerify ----------------- ' project_name = stack_name + '-' + ros_distro helper = subprocess.Popen(('%s/jenkins_scripts/code_quality/upload_to_QAVerify.py --path %s --snapshot %s --project %s --stack_name %s'%(workspace, workspace, snapshots_path, project_name, stack_name)).split(' '), env=env) helper.communicate() print '////////////////// upload results to QAVerify done ////////////////// \n\n' print ' ----------------- Remove directories ----------------- ' # Remove STACK_DIR, build, doc, cvs-folder's if os.path.exists(stack_path): shutil.rmtree(stack_path) if os.path.exists(build_path): shutil.rmtree(build_path) if os.path.exists(doc_path): shutil.rmtree(doc_path) if os.path.exists(csv_path): shutil.rmtree(csv_path) if os.path.exists(snapshots_path): shutil.rmtree(snapshots_path) print '////////////////// Remove directories ////////////////// \n\n' print 'ANALYSIS PROCESS OF STACK %s DONE\n\n'%str(stack_name) if res != 0: print "helper_return_code is: %s"%(helper.returncode) raise Exception("build_helper.py failed. Often an analysis mistake. Check out the console output above for details.") return res # global except except Exception, ex: print "Global exception caught. Generating email" generate_email("%s. Check the console output for test failure details."%ex, env) traceback.print_exc(file=sys.stdout) raise ex
def __init__(self, problem): # Initial setup self.master = tk.Tk() self.problem = problem # Set title self.master.winfo_toplevel().title("Interactive Cost Tuning") # Set icon icon = rp.RosStack().get_path( 'exotica') + '/doc/images/EXOTica_icon.png' img = tk.PhotoImage(file=icon) self.master.tk.call('wm', 'iconphoto', self.master._w, img) # Grab current rhos and cost task map names self.rho = {} self.original_rho = {} self.cost_task_map_names = [] for k in problem.get_task_maps().keys(): try: r = problem.get_rho(k) self.rho[k] = r self.original_rho[k] = r self.cost_task_map_names.append(k) except: continue # Setup labels and entries self.entries = {} for i, k in enumerate(self.cost_task_map_names): tk.Label(self.master, text=k).grid(row=i, column=0) self.entries[k] = tk.Entry(self.master) self.entries[k].grid(row=i, column=1, pady=4) self.entries[k].insert(0, self.rho[k]) n_cost_task_maps = len(self.cost_task_map_names) tk.Label(self.master, text='Filename').grid(row=n_cost_task_maps, column=0, pady=4) self.entries['filename'] = tk.Entry(self.master) self.entries['filename'].grid(row=n_cost_task_maps, column=1, pady=4) self.entries['filename'].insert(0, 'FilenameHere') # Setup buttons tk.Button(self.master, text="Set", command=self.set_button).grid(row=n_cost_task_maps + 1, column=0, pady=4) tk.Button(self.master, text="Save", command=self.save_button).grid(row=n_cost_task_maps + 1, column=1, pady=4) tk.Button(self.master, text="Reset", command=self.reset_button).grid(row=n_cost_task_maps + 2, column=0, pady=4) tk.Button(self.master, text="Quit", command=self.quit_button).grid(row=n_cost_task_maps + 2, column=1, pady=4)
def __init__(self, context): super(RosPackGraph, self).__init__(context) self.initialized = False self._current_dotcode = None self._update_thread = WorkerThread(self._update_thread_run, self._update_finished) self._nodes = {} self._edges = {} self._options = {} self._options_serialized = '' self.setObjectName('RosPackGraph') rospack = rospkg.RosPack() rosstack = rospkg.RosStack() # factory builds generic dotcode items self.dotcode_factory = PydotFactory() # self.dotcode_factory = PygraphvizFactory() # generator builds rosgraph self.dotcode_generator = RosPackageGraphDotcodeGenerator( rospack, rosstack) # dot_to_qt transforms into Qt elements using dot layout self.dot_to_qt = DotToQtGenerator() self._widget = QWidget() rp = rospkg.RosPack() ui_file = os.path.join(rp.get_path('rqt_dep'), 'resource', 'RosPackGraph.ui') loadUi(ui_file, self._widget, {'InteractiveGraphicsView': InteractiveGraphicsView}) self._widget.setObjectName('RosPackGraphUi') if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) self._scene = QGraphicsScene() self._scene.setBackgroundBrush(Qt.white) self._widget.graphics_view.setScene(self._scene) self._widget.depth_combo_box.insertItem(0, self.tr('infinite'), -1) self._widget.depth_combo_box.insertItem(1, self.tr('1'), 2) self._widget.depth_combo_box.insertItem(2, self.tr('2'), 3) self._widget.depth_combo_box.insertItem(3, self.tr('3'), 4) self._widget.depth_combo_box.insertItem(4, self.tr('4'), 5) self._widget.depth_combo_box.currentIndexChanged.connect( self._refresh_rospackgraph) self._widget.directions_combo_box.insertItem(0, self.tr('depends'), 0) self._widget.directions_combo_box.insertItem(1, self.tr('depends_on'), 1) self._widget.directions_combo_box.insertItem(2, self.tr('both'), 2) self._widget.directions_combo_box.currentIndexChanged.connect( self._refresh_rospackgraph) self._widget.package_type_combo_box.insertItem(0, self.tr('wet & dry'), 3) self._widget.package_type_combo_box.insertItem(1, self.tr('wet only'), 2) self._widget.package_type_combo_box.insertItem(2, self.tr('dry only'), 1) self._widget.package_type_combo_box.currentIndexChanged.connect( self._refresh_rospackgraph) completionmodel = StackageCompletionModel( self._widget.filter_line_edit, rospack, rosstack) completer = RepeatedWordCompleter(completionmodel, self) completer.setCompletionMode(QCompleter.PopupCompletion) completer.setWrapAround(True) completer.setCaseSensitivity(Qt.CaseInsensitive) self._widget.filter_line_edit.editingFinished.connect( self._refresh_rospackgraph) self._widget.filter_line_edit.setCompleter(completer) self._widget.filter_line_edit.selectionChanged.connect( self._clear_filter) self._widget.with_stacks_check_box.clicked.connect( self._refresh_rospackgraph) self._widget.mark_check_box.clicked.connect(self._refresh_rospackgraph) self._widget.colorize_check_box.clicked.connect( self._refresh_rospackgraph) self._widget.hide_transitives_check_box.clicked.connect( self._refresh_rospackgraph) self._widget.show_system_check_box.clicked.connect( self._refresh_rospackgraph) self._widget.refresh_graph_push_button.setIcon( QIcon.fromTheme('view-refresh')) self._widget.refresh_graph_push_button.pressed.connect( self._update_rospackgraph) self._widget.highlight_connections_check_box.toggled.connect( self._refresh_rospackgraph) self._widget.auto_fit_graph_check_box.toggled.connect( self._refresh_rospackgraph) self._widget.fit_in_view_push_button.setIcon( QIcon.fromTheme('zoom-original')) self._widget.fit_in_view_push_button.pressed.connect(self._fit_in_view) self._widget.load_dot_push_button.setIcon( QIcon.fromTheme('document-open')) self._widget.load_dot_push_button.pressed.connect(self._load_dot) self._widget.save_dot_push_button.setIcon( QIcon.fromTheme('document-save-as')) self._widget.save_dot_push_button.pressed.connect(self._save_dot) self._widget.save_as_svg_push_button.setIcon( QIcon.fromTheme('document-save-as')) self._widget.save_as_svg_push_button.pressed.connect(self._save_svg) self._widget.save_as_image_push_button.setIcon( QIcon.fromTheme('image')) self._widget.save_as_image_push_button.pressed.connect( self._save_image) self._deferred_fit_in_view.connect(self._fit_in_view, Qt.QueuedConnection) self._deferred_fit_in_view.emit() context.add_widget(self._widget) # If in either of following case, this turnes True # - 1st filtering key is already input by user # - filtering key is restored self._filtering_started = False
def _package_args_handler(command, parser, options, args): if options.rosdep_all: if args: parser.error('cannot specify additional arguments with -a') else: # let the loader filter the -a. This will take out some # packages that are catkinized (for now). lookup = _get_default_RosdepLookup(options) loader = lookup.get_loader() args = loader.get_loadable_resources() not_found = [] elif not args: parser.error('no packages or stacks specified') # package or stack names as args. have to convert stack names to packages. # - overrides to enable testing packages = [] not_found = [] if options.from_paths: for path in args: if options.verbose: print("Using argument '{0}' as a path to search.".format(path)) if not os.path.exists(path): print("given path '{0}' does not exist".format(path)) return 1 path = os.path.abspath(path) if 'ROS_PACKAGE_PATH' not in os.environ: os.environ['ROS_PACKAGE_PATH'] = '{0}'.format(path) else: os.environ['ROS_PACKAGE_PATH'] = '{0}{1}{2}'.format( path, os.pathsep, os.environ['ROS_PACKAGE_PATH']) pkgs = find_catkin_packages_in(path, options.verbose) packages.extend(pkgs) # Make packages list unique packages = list(set(packages)) else: rospack = rospkg.RosPack() rosstack = rospkg.RosStack() val = rospkg.expand_to_packages(args, rospack, rosstack) packages = val[0] not_found = val[1] if not_found: raise rospkg.ResourceNotFound(not_found[0], rospack.get_ros_paths()) # Handle the --ignore-src option if command in ['install', 'check'] and options.ignore_src: if options.verbose: print('Searching ROS_PACKAGE_PATH for ' 'sources: ' + str(os.environ['ROS_PACKAGE_PATH'].split(':'))) ws_pkgs = get_workspace_packages() for path in os.environ['ROS_PACKAGE_PATH'].split(':'): path = os.path.abspath(path.strip()) if os.path.exists(path): pkgs = find_catkin_packages_in(path, options.verbose) ws_pkgs.extend(pkgs) elif options.verbose: print('Skipping non-existent path ' + path) set_workspace_packages(ws_pkgs) lookup = _get_default_RosdepLookup(options) # Handle the --skip-keys option by pretending that they are packages in the catkin workspace if command in ['install', 'check'] and options.skip_keys: if options.verbose: print('Skipping the specified rosdep keys:\n- ' + '\n- '.join(options.skip_keys)) lookup.skipped_keys = options.skip_keys if 0 and not packages: # disable, let individual handlers specify behavior # possible with empty stacks print('No packages in arguments, aborting') return return command_handlers[command](lookup, packages, options)
else: proc = subprocess.Popen(['rosversion', pkg], stdout=subprocess.PIPE) version = proc.communicate()[0].rstrip() if (version == '<unversioned>' and os.path.isfile('package.xml')): tree = ET.parse('package.xml').getroot() version = tree.find('version').text print("(%s) - %s" % (pkg, version)) else: print("(%s) - Not found." % pkg) pkgs = [ 'move_basic', 'ubiquity_motor', 'fiducials', 'magni_robot', 'fiducial_slam', 'raspicam_node', 'pi_sonar', 'oled_display_node', 'dnn_detect' ] if __name__ == '__main__': rospack = rospkg.RosPack() rosstack = rospkg.RosStack() try: from joblib import Parallel, delayed Parallel(n_jobs=-1)(delayed(versionSupport)(pkg) for pkg in pkgs) except ImportError: for pkg in pkgs: versionSupport(pkg)
def test_check_stack_depends(): # mostly tripwire -- need to scaffold in fake RPP to do better than this rospack = rospkg.RosPack() rosstack = rospkg.RosStack() check_stack_depends('geometry', rospack, rosstack)