stdio.py 1006 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- test-case-name: twisted.test.test_stdio -*-
  2. # Copyright (c) Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. Standard input/out/err support.
  6. This module exposes one name, StandardIO, which is a factory that takes an
  7. IProtocol provider as an argument. It connects that protocol to standard input
  8. and output on the current process.
  9. It should work on any UNIX and also on Win32 (with some caveats: due to
  10. platform limitations, it will perform very poorly on Win32).
  11. Future Plans::
  12. support for stderr, perhaps
  13. Rewrite to use the reactor instead of an ad-hoc mechanism for connecting
  14. protocols to transport.
  15. Maintainer: James Y Knight
  16. """
  17. from twisted.python.runtime import platform
  18. if platform.isWindows():
  19. from twisted.internet._win32stdio import StandardIO, Win32PipeAddress as PipeAddress
  20. else:
  21. from twisted.internet._posixstdio import ( # type: ignore[assignment]
  22. PipeAddress,
  23. StandardIO,
  24. )
  25. __all__ = ["StandardIO", "PipeAddress"]