
    VhD                    J    d dl mZ d dlZd dlmZmZ d dlmZ  G d de      Zy)    )annotationsN)ABCabstractmethod)AnsibleConnectionFailurec                      e Zd ZdZg Zg Z ej                  d       ej                  d       ej                  d      gZdZ	dZ
dZd ZddZd	 Zd
 Zd ZddZd ZddZd Zy)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.common.text.converters.to_bytes` and
        :func:`~ansible.module_utils.common.text.converters.to_text` to avoid unexpected
        problems.
    s   \x1b\[\?1h\x1b=s   \x08.s   \x1b\[mNTc                    || _         y N)_connection)self
connections     Q/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/terminal/__init__.py__init__zTerminalBase.__init__?   s
    %    c                8    | j                   j                  |      S )z
        Executes the CLI command on the remote device and returns the output

        :arg cmd: Byte string command to be executed
        )r   exec_command)r   cmdcheck_rcs      r   _exec_cli_commandzTerminalBase._exec_cli_commandB   s     ,,S11r   c                6    | j                   j                         S )zk
        Returns the current prompt from the device

        :returns: A byte string of the prompt
        )r   
get_promptr   s    r   _get_promptzTerminalBase._get_promptJ   s     **,,r   c                     y)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 disabling paging for instance.
        N r   s    r   on_open_shellzTerminalBase.on_open_shellR        	r   c                     y)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   s    r   on_close_shellzTerminalBase.on_close_shell[   s     	r   c                     y)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   passwds     r   	on_becomezTerminalBase.on_becomee   s     	r   c                     y)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   s    r   on_unbecomezTerminalBase.on_unbecomeq   r   r   c                $    | j                  |      S )zjDeprecated method for privilege escalation

        :kwarg passwd: String containing the password
        )r#   r!   s     r   on_authorizezTerminalBase.on_authorizez   s    
 ~~f%%r   c                "    | j                         S )z5Deprecated method for privilege deescalation
        )r%   r   s    r   on_deauthorizezTerminalBase.on_deauthorize   s     !!r   )Tr
   )__name__
__module____qualname____doc__terminal_stdout_reterminal_stderr_rerecompileansi_reterminal_initial_promptterminal_initial_answerterminal_inital_prompt_newliner   r   r   r   r   r#   r%   r'   r)   r   r   r   r   r      s    
   	

&'

9

;G # # &*"&2-
&"r   r   )	
__future__r   r0   abcr   r   ansible.errorsr   r   r   r   r   <module>r9      s!   & # 	 # 3h"3 h"r   