|
3 | 3 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
4 | 4 |
|
5 | 5 | import sys |
| 6 | +import subprocess |
6 | 7 | from plumbum import cli |
7 | 8 | from .base import Docky, DockySub |
8 | 9 | from ..common.api import raise_error, logger |
@@ -81,7 +82,24 @@ class DockyOpen(DockyExec): |
81 | 82 |
|
82 | 83 | def _main(self, *optionnal_command_line): |
83 | 84 | super()._main(*optionnal_command_line) |
84 | | - self._exec("dcpatched", ["exec", "-e", "NOGOSU=True", self.service] + self.cmd) |
| 85 | + # self._exec("dcpatched", ["exec", "-e", "NOGOSU=True", self.service] + self.cmd) |
| 86 | + |
| 87 | + # Get Project Name |
| 88 | + # Example: docky-odoo-brasil-14 odoo |
| 89 | + project_name = self.project.name + "-" + self.project.service |
| 90 | + |
| 91 | + # Get User |
| 92 | + user = self._use_specific_user(self.service) |
| 93 | + |
| 94 | + # Get Container ID |
| 95 | + command = "docker ps -aqf name=" + project_name |
| 96 | + # Example of return value |
| 97 | + # b'b5db9db21381\n' |
| 98 | + # Option text=true return as string instead of bytes and strip remove break line |
| 99 | + # TODO: Is there a better way to do it, for example with Plumbum? |
| 100 | + container_id = subprocess.check_output(command, shell=True,text=True).strip() |
| 101 | + |
| 102 | + self._exec("docker", ["exec", "-u", user, "-it", container_id, "/bin/bash"]) |
85 | 103 |
|
86 | 104 | @Docky.subcommand("system") |
87 | 105 | class DockySystem(DockyExec): |
|
0 commit comments