| 32 | self.proc = None |
| 33 | |
| 34 | def connect(self, **kwargs): |
| 35 | args = ['ssh'] |
| 36 | if self.user: |
| 37 | args = args + ['-l', self.user] |
| 38 | |
| 39 | if self.port: |
| 40 | args = args + ['-p', self.port] |
| 41 | |
| 42 | args = args + ['--', self.host, 'docker system dial-stdio'] |
| 43 | |
| 44 | preexec_func = None |
| 45 | if not constants.IS_WINDOWS_PLATFORM: |
| 46 | def f(): |
| 47 | signal.signal(signal.SIGINT, signal.SIG_IGN) |
| 48 | preexec_func = f |
| 49 | |
| 50 | env = dict(os.environ) |
| 51 | |
| 52 | # drop LD_LIBRARY_PATH and SSL_CERT_FILE |
| 53 | env.pop('LD_LIBRARY_PATH', None) |
| 54 | env.pop('SSL_CERT_FILE', None) |
| 55 | |
| 56 | self.proc = subprocess.Popen( |
| 57 | args, |
| 58 | env=env, |
| 59 | stdout=subprocess.PIPE, |
| 60 | stdin=subprocess.PIPE, |
| 61 | preexec_fn=preexec_func) |
| 62 | |
| 63 | def _write(self, data): |
| 64 | if not self.proc or self.proc.stdin.closed: |