application.py 894 B

1234567891011121314151617181920212223242526272829303132
  1. """
  2. Interface for Telnet applications.
  3. """
  4. from __future__ import unicode_literals
  5. from abc import ABCMeta, abstractmethod
  6. from six import with_metaclass
  7. __all__ = (
  8. 'TelnetApplication',
  9. )
  10. class TelnetApplication(with_metaclass(ABCMeta, object)):
  11. """
  12. The interface which has to be implemented for any telnet application.
  13. An instance of this class has to be passed to `TelnetServer`.
  14. """
  15. @abstractmethod
  16. def client_connected(self, telnet_connection):
  17. """
  18. Called when a new client was connected.
  19. Probably you want to call `telnet_connection.set_cli` here to set a
  20. the CommandLineInterface instance to be used.
  21. Hint: Use the following shortcut: `prompt_toolkit.shortcuts.create_cli`
  22. """
  23. @abstractmethod
  24. def client_leaving(self, telnet_connection):
  25. """
  26. Called when a client quits.
  27. """