prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Contrib SSH : can't import on Windows due to posix pipe use
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
I have set up an async SSHD on my Windows 10 box and I had to patch contrib/ssh/server.py in order to do it. The problem is that we import prompt_toolkit.input.posix_pipe at the top, when we need to be versatile to platform and import prompt_toolkit.input.win32_pipe on Windows platforms instead.
Here's how I'm handling this locally:
--- a/prompt_toolkit/contrib/ssh/server.py 2020-05-29 13:15:17.950284900 -0700
+++ b/prompt_toolkit/contrib/ssh/server.py 2020-05-29 13:27:21.302283000 -0700
@@ -9,7 +9,14 @@
from prompt_toolkit.application.current import AppSession, create_app_session
from prompt_toolkit.data_structures import Size
-from prompt_toolkit.input.posix_pipe import PosixPipeInput
+from importlib import import_module
+from prompt_toolkit.utils import is_windows
+if (is_windows()):
+ pipe_module = import_module('prompt_toolkit.input.win32_pipe')
+ pipe_input = pipe_module.Win32PipeInput
+else:
+ pipe_module = import_module('prompt_toolkit.input.posix_pipe')
+ pipe_input = pipe_module.PosixPipeInput
from prompt_toolkit.output.vt100 import Vt100_Output
__all__ = [
@@ -27,7 +34,7 @@
# PipInput object, for sending input in the CLI.
# (This is something that we can use in the prompt_toolkit event loop,
# but still write date in manually.)
- self._input = PosixPipeInput()
+ self._input = pipe_input()
# Output object. Don't render to the real stdout, but write everything
# in the SSH channel.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with contrib/ssh/server.py and inspect how its pipe input is imported and initialized. Make the SSH server select the platform-appropriate pipe input so async SSHD setup works on Windows while preserving POSIX behavior, then verify both import paths and Windows initialization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100