Ask Your Question
0

Accessing install directory from a custom caktin tools verb

asked 2017-06-24 15:28:08 -0500

asymingt gravatar image

updated 2017-06-24 15:28:32 -0500

I would like to create my own verb called 'rsync' that deploys cross-compiled ROS packages on a destination target device using ssh over rsync. In order to do so, I need to access the install directory for my current build profile.

As per the instructions I have created a python script rsync.py that looks something like this.

#!/usr/bin/env python

import os

def main(opts):
  for target in opts.targets:
    os.system("rsync -avz -e ssh  " + install_dir + " " + target)
  return 0

def prepare_arguments(parser):
  add = parser.add_argument
  # What packages to build
  add('targets', nargs='*',
    help='List of target names to rsync the files to.')
  return parser

description = dict(
  verb='rsync',
  description="Deploy products to the robot over rsync",
  main=main,
  prepare_arguments=prepare_arguments
)

My issue is that I cannot set the install_dir variable in the main function to the correct value for the current build profile. Does catkin tools provide a python module that I can get this information from?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-06-25 13:27:51 -0500

tfoote gravatar image

I think you will want to load a Context object from the workspace: https://github.com/catkin/catkin_tool...

An example of doing so can be found in some of the existing verbs.

ctx = Context.load(opts.workspace, opts.profile, load_env=False)

https://github.com/catkin/catkin_tool...

Which shows you can also leverage the arguments from the context parser using add_context_args(parser)

edit flag offensive delete link more

Comments

Thanks, Tully! Catkin-tools is amazing :)

asymingt gravatar image asymingt  ( 2017-06-26 22:50:18 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-06-24 15:28:08 -0500

Seen: 142 times

Last updated: Jun 25 '17