From 548a99e256a15972b2637c4dfca211cbfd3a577b Mon Sep 17 00:00:00 2001 From: JoshHeitzman Date: Mon, 10 Aug 2020 10:09:56 -0700 Subject: [PATCH] Fix for ssh serving issues: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1207 https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1209 --- prompt_toolkit/contrib/ssh/server.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/prompt_toolkit/contrib/ssh/server.py b/prompt_toolkit/contrib/ssh/server.py index c495b04ad..d9e6235e9 100644 --- a/prompt_toolkit/contrib/ssh/server.py +++ b/prompt_toolkit/contrib/ssh/server.py @@ -39,6 +39,10 @@ def write(s, data): def flush(s): pass + @property + def encoding(s): + return self._chan._orig_chan.get_encoding()[0] + self.stdout = cast(TextIO, Stdout()) def _get_size(self) -> Size: @@ -65,9 +69,11 @@ async def _interact(self) -> None: # Should not happen. raise Exception("`_interact` called before `connection_made`.") - # Disable the line editing provided by asyncssh. Prompt_toolkit - # provides the line editing. - self._chan.set_line_mode(False) + if hasattr(self._chan, "set_line_mode") and self._chan._editor is not None: + # Disable the line editing provided by asyncssh. Prompt_toolkit + # provides the line editing. + self._chan.set_line_mode(False) + term = self._chan.get_terminal_type() self._output = Vt100_Output(