Skip to content

Commit 3904df6

Browse files
committed
Reformat
1 parent 6e7d74e commit 3904df6

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

scripts/ssh.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def main():
2828
default=False,
2929
help="Use windows instead of panes.",
3030
)
31+
parser.add_argument(
32+
"--container",
33+
type=str,
34+
help="Connect to a Docker container on the remote host",
35+
)
3136
parser.add_argument(
3237
"-v",
3338
"--verbose",
@@ -65,19 +70,33 @@ def main():
6570

6671
if remote_pc == "all":
6772
try:
68-
commands = dict(robot.get_shell_commands("ssh"))
73+
if args.container:
74+
commands = {
75+
name: f"docker -H ssh://{pc.user}@{pc.hostname} exec -it {args.container} /bin/bash"
76+
for name, pc in robot.remote_pcs.items()
77+
}
78+
else:
79+
commands = dict(robot.get_shell_commands("ssh"))
6980
except ValueError:
7081
print_error(f"Command ssh not found for any PC on robot {robot_name}!")
7182
exit(1)
7283
else:
73-
if not robot.remote_pcs[remote_pc].has_command("ssh"):
74-
print_error(
75-
f"Command ssh not found for PC {remote_pc} on robot {robot_name}!"
76-
)
77-
exit(1)
78-
commands = {
79-
remote_pc: robot.get_shell_command(remote_pc, "ssh", {"robot": robot_name})
80-
}
84+
pc = robot.remote_pcs[remote_pc]
85+
if args.container:
86+
commands = {
87+
remote_pc: f"docker -H ssh://{pc.user}@{pc.hostname} exec -it {args.container} /bin/bash"
88+
}
89+
else:
90+
if not pc.has_command("ssh"):
91+
print_error(
92+
f"Command ssh not found for PC {remote_pc} on robot {robot_name}!"
93+
)
94+
exit(1)
95+
commands = {
96+
remote_pc: robot.get_shell_command(
97+
remote_pc, "ssh", {"robot": robot_name}
98+
)
99+
}
81100

82101
# If single command, launch directly replacing the current process
83102
# Otherwise, use tmux to split the terminal

0 commit comments

Comments
 (0)