Return the cmd string to execute
(self, cmd, ssh=SSH_PATH)
| 261 | return stdout, stderr, retcode |
| 262 | |
| 263 | def _cmd_str(self, cmd, ssh=SSH_PATH): |
| 264 | """ |
| 265 | Return the cmd string to execute |
| 266 | """ |
| 267 | |
| 268 | # TODO: if tty, then our SSH_SHIM cannot be supplied from STDIN Will |
| 269 | # need to deliver the SHIM to the remote host and execute it there |
| 270 | |
| 271 | command = [ssh] |
| 272 | if ssh != SCP_PATH: |
| 273 | command.append(self.host) |
| 274 | if self.tty and ssh == SSH_PATH: |
| 275 | command.append("-t -t") |
| 276 | if self.passwd or self.priv: |
| 277 | command.append(self.priv and self._key_opts() or self._passwd_opts()) |
| 278 | if ssh != SCP_PATH and self.remote_port_forwards: |
| 279 | command.append( |
| 280 | " ".join( |
| 281 | [f"-R {item}" for item in self.remote_port_forwards.split(",")] |
| 282 | ) |
| 283 | ) |
| 284 | if self.ssh_options: |
| 285 | command.append(self._ssh_opts()) |
| 286 | |
| 287 | command.append(cmd) |
| 288 | |
| 289 | return " ".join(command) |
| 290 | |
| 291 | def _run_nb_cmd(self, cmd): |
| 292 | """ |