Attach the stdin/stdout/stderr of the CLI to the STDIN/STDOUT/STDERR of a running task. As of now, we can only attach to tasks launched with a remote TTY already set up for them. If we try to attach to a task that was launched without a remote TTY attached,
(self, _no_stdin=False)
| 262 | self.exit_sequence_detected = False |
| 263 | |
| 264 | def attach(self, _no_stdin=False): |
| 265 | """ |
| 266 | Attach the stdin/stdout/stderr of the CLI to the |
| 267 | STDIN/STDOUT/STDERR of a running task. |
| 268 | |
| 269 | As of now, we can only attach to tasks launched with a remote TTY |
| 270 | already set up for them. If we try to attach to a task that was |
| 271 | launched without a remote TTY attached, this command will fail. |
| 272 | |
| 273 | :param task: task ID pattern to match |
| 274 | :type task: str |
| 275 | :param no_stdin: True if we should *not* attach stdin, |
| 276 | False if we should |
| 277 | :type no_stdin: bool |
| 278 | """ |
| 279 | |
| 280 | # Store relevant parameters of the call for later. |
| 281 | self.interactive = not _no_stdin |
| 282 | self.tty = True |
| 283 | |
| 284 | # Set the entry point of the output thread to be a call to |
| 285 | # _attach_container_output. |
| 286 | self.output_thread_entry_point = self._attach_container_output |
| 287 | |
| 288 | self._run() |
| 289 | |
| 290 | if not self.exit_sequence_detected: |
| 291 | # We are only able to get the 'exit_status' of tasks launched via |
| 292 | # the default executor (i.e. as pods rather than via the command |
| 293 | # executor). In the future, mesos will deprecate the command |
| 294 | # executor in favor of the default executor, so this check will |
| 295 | # be able to go away. In the meantime, we will always return '0' |
| 296 | # for tasks launched via the command executor. |
| 297 | if "parent" in self.container_id: |
| 298 | return self._wait() |
| 299 | |
| 300 | return 0 |
| 301 | |
| 302 | def exec(self, _cmd, _args=None, _interactive=False, _tty=False): |
| 303 | """ |