%PDF- %PDF-
| Direktori : /lib/python3.9/site-packages/ansible/plugins/terminal/__pycache__/ |
| Current File : //lib/python3.9/site-packages/ansible/plugins/terminal/__pycache__/__init__.cpython-39.pyc |
a
�)gV � @ sP d dl mZmZmZ eZd dlZd dlmZm Z d dl
mZ G dd� de�ZdS )� )�absolute_import�division�print_functionN)�ABC�abstractmethod)�AnsibleConnectionFailurec @ s� e Zd ZdZg Zg Ze�d�e�d�e�d�gZdZ dZ
dZdd� Zdd d
�Z
dd� Zd
d� Zdd� Zddd�Zdd� Zddd�Zdd� ZdS )�TerminalBasea�
A base class for implementing cli connections
.. note:: Unlike most of Ansible, nearly all strings in
:class:`TerminalBase` plugins are byte strings. This is because of
how close to the underlying platform these plugins operate. Remember
to mark literal strings as byte string (``b"string"``) and to use
:func:`~ansible.module_utils._text.to_bytes` and
:func:`~ansible.module_utils._text.to_text` to avoid unexpected
problems.
s \x1b\[\?1h\x1b=s \x08.s \x1b\[mNTc C s
|| _ d S )N)�_connection)�selfZ
connection� r �E/usr/lib/python3.9/site-packages/ansible/plugins/terminal/__init__.py�__init__@ s zTerminalBase.__init__c C s | j �|�S )z�
Executes the CLI command on the remote device and returns the output
:arg cmd: Byte string command to be executed
)r Zexec_command)r
�cmdZcheck_rcr r r �_exec_cli_commandC s zTerminalBase._exec_cli_commandc C s
| j �� S )zk
Returns the current prompt from the device
:returns: A byte string of the prompt
)r Z
get_prompt�r
r r r �_get_promptK s zTerminalBase._get_promptc C s dS )a Called after the SSH session is established
This method is called right after the invoke_shell() is called from
the Paramiko SSHClient instance. It provides an opportunity to setup
terminal parameters such as disbling paging for instance.
Nr r r r r �
on_open_shellS s zTerminalBase.on_open_shellc C s dS )a& Called before the connection is closed
This method gets called once the connection close has been requested
but before the connection is actually closed. It provides an
opportunity to clean up any terminal resources before the shell is
actually closed
Nr r r r r �on_close_shell\ s zTerminalBase.on_close_shellc C s dS )a� Called when privilege escalation is requested
:kwarg passwd: String containing the password
This method is called when the privilege is requested to be elevated
in the play context by setting become to True. It is the responsibility
of the terminal plugin to actually do the privilege escalation such
as entering `enable` mode for instance
Nr �r
�passwdr r r � on_becomef s
zTerminalBase.on_becomec C s dS )a Called when privilege deescalation is requested
This method is called when the privilege changed from escalated
(become=True) to non escalated (become=False). It is the responsibility
of this method to actually perform the deauthorization procedure
Nr r r r r �on_unbecomer s zTerminalBase.on_unbecomec C s
| � |�S )zjDeprecated method for privilege escalation
:kwarg passwd: String containing the password
)r r r r r �on_authorize{ s zTerminalBase.on_authorizec C s | � � S )z5Deprecated method for privilege deescalation
)r r r r r �on_deauthorize� s zTerminalBase.on_deauthorize)T)N)N)�__name__�
__module__�__qualname__�__doc__Zterminal_stdout_reZterminal_stderr_re�re�compileZansi_reZterminal_initial_promptZterminal_initial_answerZterminal_inital_prompt_newliner
r r r r r r r r r r r r r s&