
    Vh                         d dl mZmZmZ eZd dlmZ d dlZd dl	Z	d dl
mZ d dlmZmZ d dlmZ d dlmZ  e       Z G d d	e      Zy)
    )absolute_importdivisionprint_function)
raise_fromN)AnsibleConnectionFailure)to_textto_bytes)TerminalBase)Displayc                      e Zd Z ej                  d      gZ ej                  d       ej                  dej                         ej                  d       ej                  d       ej                  dej                         ej                  dej                         ej                  dej                         ej                  d	       ej                  d
       ej                  dej                         ej                  dej                         ej                  dej                         ej                  dej                         ej                  d      gZd Z	ddZ
d Zy)TerminalModules7   [\r\n]?[\w\+\-\.:\/\[\]]+(?:\([^\)]+\)){0,3}(?:[>#]) ?$s   % ?Errors   ^% \w+s   % ?Bad secrets   [\r\n%] Bad passwordss   invalid inputs    (?:incomplete|ambiguous) commands   connection timed outs   [^\r\n]+ not founds!   '[^']' +returned error code: ?\d+s   Bad masks   % ?(\S+) ?overlaps with ?(\S+)s   [%\S] ?Error: ?[\s]+s   [%\S] ?Informational: ?[\s]+s   Command authorization failedc                 V   	 | j                  d       	 | j                  d       	 | j                  d       y # t        $ r}t        t        d      |       Y d }~Hd }~ww xY w# t        $ r t        j                  d       Y ^w xY w# t        $ r t        j                  d       Y y w xY w)Ns   terminal datadumpz!unable to set terminal parameterss   terminal width 0zIWARNING: Unable to set terminal width, command responses may be truncateds   terminal no promptz:WARNING: Unable disable prompt, command responses may fail)_exec_cli_commandr   r   display)selfes     p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/ciscosmb/plugins/terminal/ciscosmb.pyon_open_shellzTerminalModule.on_open_shell>   s    	Y""#78	""#67	""#89 ( 	Y/0STVWXX	Y
 ( 	OO[	 ( 	OOL	s7   8 A# B 	A AA #BBB('B(Nc           	         ddi}|rt        dd      |d<   ||d<   d|d	<   	 | j                  t        t        j                  |      d             | j                         }||j                  d
      st        d|z        y # t        $ r?}| j                         }t        t        d|d|j                        |       Y d }~y d }~ww xY w)Ncommandenablez[\r\n]?(?:.*)?[Pp]assword: ?$surrogate_or_strict)errorspromptanswerTprompt_retry_check   #z?failed to elevate privilege to enable mode still at prompt [%s]z7unable to elevate privilege to enable mode, at prompt [z] with error: )
r   r   r	   jsondumps_get_promptendswithr   r   message)r   passwdcmdr   r   s        r   	on_becomezTerminalModule.on_becomeR   s    9% %09NC	N $C	N)-C%&	""C1FG %%'F~V__T%:.U  &;
 ( 	%%'F/199&  	s   A B 	C5CCc                     | j                         }|y d|v r#| j                  d       | j                  d       y |j                  d      r| j                  d       y y )Ns   (configs   ends   disabler   )r    r   r!   )r   r   s     r   on_unbecomezTerminalModule.on_unbecomem   s[    !!#>""6*"":.__T""":. #    )N)__name__
__module____qualname__recompileterminal_stdout_reMIterminal_stderr_rer   r%   r'    r(   r   r   r   %   s3   
 	

NO
 	

< 

:rtt$

$%

,-

$bdd+

7>

+RTT2

)*

89

<&

5rtt<

+RTT2

3RTT:

34"(6/r(   r   )
__future__r   r   r   type__metaclass__ansible.module_utils.sixr   r   r,   ansible.errorsr   ansible.module_utils._textr   r	   ansible.plugins.terminalr
   ansible.utils.displayr   r   r   r2   r(   r   <module>r;      s?   ( C B 0  	 3 8 1 )
)S/\ S/r(   