push.py
Go to the documentation of this file.
00001 """
00002 The push command pushes the local workspace to the
00003 remote workspace, making it identical to the current workspace.
00004 
00005 Copyright 2015 Fetch Robotics Inc.
00006 Author: Alex Henning
00007 """
00008 
00009 import os
00010 import subprocess
00011 import sys
00012 
00013 from ..util import ssh, add_user, add_robot, add_workspace
00014 
00015 name = "push"
00016 help_text = "Push the workspace to the robot"
00017 
00018 
00019 def main(args):
00020     print "Pushing %s/src to %s@%s:%s/src" % (
00021         args.workspace, args.user, args.robot, args.remote_workspace
00022     )
00023 
00024     # Synchronize the workspaces
00025     proc = subprocess.Popen(
00026         ["rsync",
00027          # Following line is a trick to magically create the directory
00028          # if it doesn't exist.
00029          "--rsync-path", "mkdir -p " + args.remote_workspace + " && rsync",
00030          "-phErtz",
00031          "--delete",
00032          args.workspace + "/src",
00033          args.user + "@" + args.robot + ":" + args.remote_workspace + "/"]
00034     )
00035     proc.wait()
00036     if proc.returncode != 0:
00037         print "ERROR: Syncing failed"
00038         sys.exit(-1)
00039 
00040     # Use rosdep to install all dependencies
00041     if args.install_deps:
00042         ssh(args.user, args.robot,
00043             "cd "+args.remote_workspace+" && "
00044             "source devel/setup.bash && "
00045             "rosdep update && "
00046             "rosdep install --from-paths src --ignore-src -y")
00047 
00048     # Run the build commands
00049     if args.build is not None:
00050         for build in args.build:
00051             build = build if build is not None else ""
00052             if args.build_type != "default":
00053                 build += " -DCMAKE_BUILD_TYPE="+args.build_type
00054             command = "source /opt/ros/" + os.getenv("ROS_DISTRO") + \
00055                       "/setup.bash && cd " + args.remote_workspace + \
00056                       " && catkin_make " + build
00057             if ssh(args.user, args.robot, command) != 0:
00058                 print "ERROR: Build failed"
00059                 sys.exit(-1)
00060 
00061 
00062 def add_arguments(parser):
00063     add_user(parser)
00064     add_robot(parser)
00065     add_workspace(parser)
00066     parser.add_argument("--install-deps", action="store_true",
00067                         help="Install dependencies using rosdep")
00068     parser.add_argument("--build", nargs="?", action="append",
00069                         help="Build after syncing")
00070     parser.add_argument("--build-type", action="store", default="default",
00071                         choices=["Debug", "Release", "RelWithDebInfo", "MinSizeRel", "default"],
00072                         help="Type of build to use `default`, `Debug`, `Release`, and `RelWithDebInfo`")


fetch_tools
Author(s): Alex Henning
autogenerated on Thu Jun 6 2019 21:10:20