Execute a new process inside of a given task by redirecting STDIN/STDOUT/STDERR between the CLI and the Mesos Agent API. If a tty is requested, we take over the current terminal and put it into raw mode. We make sure to reset the terminal back to its origina
(self, _cmd, _args=None, _interactive=False, _tty=False)
| 300 | return 0 |
| 301 | |
| 302 | def exec(self, _cmd, _args=None, _interactive=False, _tty=False): |
| 303 | """ |
| 304 | Execute a new process inside of a given task by redirecting |
| 305 | STDIN/STDOUT/STDERR between the CLI and the Mesos Agent API. |
| 306 | |
| 307 | If a tty is requested, we take over the current terminal and |
| 308 | put it into raw mode. We make sure to reset the terminal back |
| 309 | to its original settings before exiting. |
| 310 | |
| 311 | :param cmd: The command to launch inside the task's container |
| 312 | :type args: cmd |
| 313 | :param args: Additional arguments for the command |
| 314 | :type args: list |
| 315 | :param interactive: attach stdin |
| 316 | :type interactive: bool |
| 317 | :param tty: attach a tty |
| 318 | :type tty: bool |
| 319 | """ |
| 320 | |
| 321 | # Store relevant parameters of the call for later. |
| 322 | self.cmd = _cmd |
| 323 | self.args = _args |
| 324 | self.interactive = _interactive |
| 325 | self.tty = _tty |
| 326 | |
| 327 | # Override the container ID with the current container ID as the |
| 328 | # parent, and generate a new UUID for the nested container used to |
| 329 | # run commands passed to `task exec`. |
| 330 | self.container_id = { |
| 331 | 'parent': self.container_id, |
| 332 | 'value': str(uuid.uuid4()) |
| 333 | } |
| 334 | |
| 335 | # Set the entry point of the output thread to be a call to |
| 336 | # _launch_nested_container_session. |
| 337 | self.output_thread_entry_point = self._launch_nested_container_session |
| 338 | |
| 339 | self._run() |
| 340 | |
| 341 | return self._wait() |
| 342 | |
| 343 | def _run(self): |
| 344 | """ |