a ì)gVã@sPddlmZmZmZeZddlZddlmZm Z ddl m Z Gdd„deƒZ dS)é)Úabsolute_importÚdivisionÚprint_functionN)ÚABCÚabstractmethod)ÚAnsibleConnectionFailurec@sŽeZdZdZgZgZe d¡e d¡e d¡gZdZ dZ dZ dd„Z dd d „Z d d „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\[mNTcCs ||_dS)N)Ú _connection)ÚselfZ connection©r úE/usr/lib/python3.9/site-packages/ansible/plugins/terminal/__init__.pyÚ__init__@szTerminalBase.__init__cCs |j |¡S)zŒ Executes the CLI command on the remote device and returns the output :arg cmd: Byte string command to be executed )r Z exec_command)r ÚcmdZcheck_rcr r r Ú_exec_cli_commandCszTerminalBase._exec_cli_commandcCs |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_promptKszTerminalBase._get_promptcCsdS)aCalled 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 rr r r Ú on_open_shellSszTerminalBase.on_open_shellcCsdS)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 rr r r Úon_close_shell\szTerminalBase.on_close_shellcCsdS)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_becomefs zTerminalBase.on_becomecCsdS)aCalled 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 rr r r Ú on_unbecomerszTerminalBase.on_unbecomecCs | |¡S)zjDeprecated method for privilege escalation :kwarg passwd: String containing the password )rrr r r Ú on_authorize{szTerminalBase.on_authorizecCs| ¡S)z5Deprecated method for privilege deescalation )rrr r r Úon_deauthorize‚szTerminalBase.on_deauthorize)T)N)N)Ú__name__Ú __module__Ú __qualname__Ú__doc__Zterminal_stdout_reZterminal_stderr_reÚreÚcompileZansi_reZterminal_initial_promptZterminal_initial_answerZterminal_inital_prompt_newliner rrrrrrrrr r r r rs& ý    r) Z __future__rrrÚtypeZ __metaclass__rÚabcrrZansible.errorsrrr r r r Ús