Skip to content

Commit 2934d51

Browse files
committed
Win PTY implementation for ssh connections in windows
1 parent 9eef3d5 commit 2934d51

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

ark_sdk_python/common/connections/ssh/ark_pty_ssh_connection.py

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def connect(self, connection_details: ArkConnectionDetails) -> None:
3333
Raises:
3434
ArkException: _description_
3535
"""
36+
# pylint: disable=import-error
3637
from pexpect import pxssh
3738

3839
if self.__is_connected:

ark_sdk_python/common/connections/ssh/ark_pty_ssh_win_connection.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ArkPTYSSHWinConnection(ArkConnection):
2626
__DEFAULT_ROW_SIZE: Final[int] = 24
2727
__DEFAULT_NONEAGER_TIMEOEUT: Final[float] = 1.0
2828
__DEFAULT_PROMPT_OVERALL_TIMEOUT: Final[float] = 20.0
29+
__CHAR_SLEEP_TIME: Final[float] = 0.05
2930

3031
def __init__(self):
3132
super().__init__()
@@ -35,11 +36,11 @@ def __init__(self):
3536
self.__output_lock: threading.Lock = threading.Lock()
3637
self.__buffer: str = ''
3738

38-
def __strip_ansi(self, input: str) -> str:
39-
input = input.strip()
40-
input = ArkPTYSSHWinConnection.__ANSI_COLOR_STRIPPER.sub('', input)
41-
input = ArkPTYSSHWinConnection.__ANSI_ESCAPE_STRIPPER.sub('', input)
42-
return input
39+
def __strip_ansi(self, ansi_input: str) -> str:
40+
ansi_input = ansi_input.strip()
41+
ansi_input = ArkPTYSSHWinConnection.__ANSI_COLOR_STRIPPER.sub('', ansi_input)
42+
ansi_input = ArkPTYSSHWinConnection.__ANSI_ESCAPE_STRIPPER.sub('', ansi_input)
43+
return ansi_input
4344

4445
def __reset_buffer(self) -> None:
4546
with self.__output_lock:
@@ -67,7 +68,7 @@ def __read_until_latest_prompt(
6768
break
6869
if (time.time() - start_time) > overall_timeout and prompt_found_at == -1:
6970
raise RuntimeError(f'Timeout while waiting for prompt [{buffer}]')
70-
time.sleep(0.05)
71+
time.sleep(ArkPTYSSHWinConnection.__CHAR_SLEEP_TIME)
7172
continue
7273

7374
buffer += char
@@ -105,6 +106,7 @@ def connect(self, connection_details: ArkConnectionDetails) -> None:
105106
Raises:
106107
ArkException: _description_
107108
"""
109+
# pylint: disable=import-error
108110
import winpty
109111

110112
if self.__is_connected:

0 commit comments

Comments
 (0)