diff options
-rw-r--r-- | paramiko/server.py | 84 | ||||
-rw-r--r-- | sites/docs/api/server.rst | 1 |
2 files changed, 43 insertions, 42 deletions
diff --git a/paramiko/server.py b/paramiko/server.py index 9ff7243b..e7d37849 100644 --- a/paramiko/server.py +++ b/paramiko/server.py @@ -25,48 +25,6 @@ from paramiko.common import * from paramiko import util -class InteractiveQuery (object): - """ - A query (set of prompts) for a user during interactive authentication. - """ - - def __init__(self, name='', instructions='', *prompts): - """ - Create a new interactive query to send to the client. The name and - instructions are optional, but are generally displayed to the end - user. A list of prompts may be included, or they may be added via - the `add_prompt` method. - - :param name: name of this query - :type name: str - :param instructions: user instructions (usually short) about this query - :type instructions: str - :param prompts: one or more authentication prompts - :type prompts: str - """ - self.name = name - self.instructions = instructions - self.prompts = [] - for x in prompts: - if (type(x) is str) or (type(x) is unicode): - self.add_prompt(x) - else: - self.add_prompt(x[0], x[1]) - - def add_prompt(self, prompt, echo=True): - """ - Add a prompt to this query. The prompt should be a (reasonably short) - string. Multiple prompts can be added to the same query. - - :param prompt: the user prompt - :type prompt: str - :param echo: ``True`` (default) if the user's response should be echoed; - ``False`` if not (for a password or similar) - :type echo: bool - """ - self.prompts.append((prompt, echo)) - - class ServerInterface (object): """ This class defines an interface for controlling the behavior of paramiko @@ -551,6 +509,48 @@ class ServerInterface (object): return OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED +class InteractiveQuery (object): + """ + A query (set of prompts) for a user during interactive authentication. + """ + + def __init__(self, name='', instructions='', *prompts): + """ + Create a new interactive query to send to the client. The name and + instructions are optional, but are generally displayed to the end + user. A list of prompts may be included, or they may be added via + the `add_prompt` method. + + :param name: name of this query + :type name: str + :param instructions: user instructions (usually short) about this query + :type instructions: str + :param prompts: one or more authentication prompts + :type prompts: str + """ + self.name = name + self.instructions = instructions + self.prompts = [] + for x in prompts: + if (type(x) is str) or (type(x) is unicode): + self.add_prompt(x) + else: + self.add_prompt(x[0], x[1]) + + def add_prompt(self, prompt, echo=True): + """ + Add a prompt to this query. The prompt should be a (reasonably short) + string. Multiple prompts can be added to the same query. + + :param prompt: the user prompt + :type prompt: str + :param echo: ``True`` (default) if the user's response should be echoed; + ``False`` if not (for a password or similar) + :type echo: bool + """ + self.prompts.append((prompt, echo)) + + class SubsystemHandler (threading.Thread): """ Handler for a subsytem in server mode. If you create a subclass of this diff --git a/sites/docs/api/server.rst b/sites/docs/api/server.rst index 7519ae99..ea854544 100644 --- a/sites/docs/api/server.rst +++ b/sites/docs/api/server.rst @@ -2,3 +2,4 @@ Server implementation ===================== .. automodule:: paramiko.server + :member-order: bysource |