2 from argparse
import RawTextHelpFormatter
10 logging.getLogger().setLevel(logging.INFO)
13 ip_and_port = input.split(
":")
14 if len(ip_and_port) != 2:
15 msg =
"Please give host in the format host:port, e.g. 10.3.4.1:2375 or hostname:2375" 16 raise argparse.ArgumentTypeError(msg)
20 parser = argparse.ArgumentParser(
22 formatter_class=RawTextHelpFormatter,
23 description=
"Simply running ros nodes in docker containers on remote robots.")
24 parser.add_argument(
"subcommand", choices=[
"build",
"run",
"stop",
"push"],
25 help=
"build: Creates an image that can run roscommand\n\ 26 run: Runs an image with your_roscommand (and builds it first)\n\ 27 stop: Stops image that runs that command\n\ 28 push: Push image to predefined registry\n")
30 g = parser.add_mutually_exclusive_group()
31 g.add_argument(
"-e",
"--env", action=
'store_true', default=
True,
32 help=
"use the existing docker environment (see https://dockr.ly/2zMPc17 for details)")
34 g.add_argument(
"-i",
"--ip",
"--host", nargs=1, type=ip_validator, metavar=
'HOST:PORT',
35 help=
"set the host (robot) to deploy image to")
37 parser.add_argument(
"-f",
"--dockerfile", dest=
"dockerfile", nargs=1, type=open, default=
None,
38 help=
"use a custom Dockerfile")
40 parser.add_argument(
"-n",
"--no-build", action=
'store_true',
41 help=
"dont (re-)build the image before running")
43 parser.add_argument(
"roscommand", nargs=argparse.REMAINDER,
44 help=
"Everything after the subcommand will be interpreted as the ros command to be run in your image")
47 args = parser.parse_args()
48 logging.info(
"parsing ")
51 dockerfname = os.path.realpath(args.dockerfile[0].name)
52 logging.debug(dockerfname)
58 fname = rp.get_path(
'dockeros') +
'/config/config.yaml' 60 config = yaml.load(
open(fname))
61 except Exception
as e:
62 logging.warn(
"No config file found under " + fname)
66 dockerfile=dockerfname)
68 dock_obj.make_client()
70 dock_obj.make_client(args.ip_and_port[0], args.ip_and_port[1])
72 if args.subcommand ==
"build":
75 elif args.subcommand ==
"run":
80 elif args.subcommand ==
"stop":
83 elif args.subcommand ==
"push":