
    Vhv                     j    d dl mZmZmZ e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  G d de      Zy)    )absolute_importdivisionprint_functionN)AnsibleConnectionFailure)to_textto_bytes)TerminalBasec            
          e Zd Z ej                  d       ej                  d      gZ 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
      gZd ZddZ	d Z
y)TerminalModules   \(([^\(\)]+)\) [>#]$s   \(([^\(\)]+)\) \(([^\(\)]+)\)#$s   % ?Errors   % ?Bad secrets   invalid inputs    (?:incomplete|ambiguous) commands   connection timed outs   [^\r\n]+ not founds!   '[^']' +returned error code: ?\d+s
   An invalidc                      y N )selfs    q/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/network/plugins/terminal/edgeswitch.pyon_open_shellzTerminalModule.on_open_shell0   s        Nc                 ~   | j                         }|r|j                  d      ry ddi}|rt        dd      |d<   ||d<   	 | j                  t	        t        j                  |      d             | j                         }||j                  d      st        d	|z        dd
i}| j                  t	        t        j                  |      d             | j                         }||j                  d      st        d      y # t        $ r0}| j                         }t        d|d|j                        d }~ww xY w)N   #commandenablez[\r\n]?[Pp]assword: ?$surrogate_or_strict)errorspromptanswerz?failed to elevate privilege to enable mode still at prompt [%s]zterminal length 0z'failed to setup terminal in enable modez7unable to elevate privilege to enable mode, at prompt [z] with error: )	_get_promptendswithr   _exec_cli_commandr   jsondumpsr   message)r   passwdr   cmdes        r   	on_becomezTerminalModule.on_become3   sH   !!#food+9%$%>G\]C	N#C	N	N""8DJJsODY#Z[%%'F~V__T%:./psy/yzz34C""8DJJsODY#Z[%%'F~V__T%:./XYY &; ( 	N%%'F*  {A  CD  CL  CL  ,M  N  N	Ns   CD 	D<+D77D<c                     | j                         }|y d|v r#| j                  d       | j                  d       y |j                  d      r| j                  d       y y )Ns   (Configs   ends   exitr   )r   r   r   )r   r   s     r   on_unbecomezTerminalModule.on_unbecomeL   s[    !!#>""6*""7+__T"""7+ #r   r   )__name__
__module____qualname__recompileterminal_stdout_reIterminal_stderr_rer   r$   r&   r   r   r   r   r      s     	

+,

67 	

< 

$%

$bdd+

7>

+RTT2

)*

89

>"	N2,r   r   )
__future__r   r   r   type__metaclass__r   r*   ansible.errorsr   ansible.module_utils._textr   r   ansible.plugins.terminalr	   r   r   r   r   <module>r5      s.   & C B  	 3 8 19,\ 9,r   