
    G@d                     b    d Z ddlZddlZddlmZ ej        dk    sddlZddlmZ d Z		 	 d
d	Z
dS )z,Utilities to connect to kernels through ssh.    N)QMessageBoxnt)_c                 .    t          j        |            d S )N)pexpectrun)cmds    Glib/python3.11/site-packages/spyder/plugins/ipythonconsole/utils/ssh.py_stop_tunnelr      s    K    	127.0.0.1皙?c                    d}|r|d|z   z  }d|v r |                     d          \  }}	|d|	z  z  }|d|}
t          j        |
d          \  }}|st          ||                    d          d	z   |                    d
                             }d|||||fz  }
t          j        |
d          \  }}|s1t          j        t          |
                    ddd                     |S d||||||fz  }
t          j
                                        }|                    dd           d}t          j        |
|          }d}	 	 |                    |ddgd          }|dk    r|                     d          d         }t          d          |z  }t!          j        | t          d          |t           j        t           j        z  t           j                  }|t           j        k    r|                    d           |                    d           t+          t          d                     |dk    r||                    |           |s|t+          t          d!                    |                    |           d}nS# t          j        $ r Y St          j        $ r0 |j        rt+          t          d"          |
z            |j        cY S w xY w)#z
    We decided to replace pyzmq's openssh_tunnel method to work around
    issue https://github.com/zeromq/pyzmq/issues/589 which was solved
    in pyzmq https://github.com/zeromq/pyzmq/pull/615
    zssh z-i :z -p %sz
 -O check T)withexitstatusz(pid=   )z&%s -O forward -L 127.0.0.1:%i:%s:%i %sz
-O forwardz	-O cancel   z/%s -f -S none -L 127.0.0.1:%i:%s:%i %s sleep %iSSH_ASKPASSNz,Are you sure you want to continue connecting)envFz[Pp]assword:z[Pp]assphraseg?)timeoutr   @zfThe authenticity of host <b>%s</b> can't be established. Are you sure you want to continue connecting?Warningyesnoz1The authenticity of the host can't be establishedz Could not connect to remote hostzTunnel '%s' failed to start)splitr   r   intfindatexitregisterr   replaceosenvironcopypopspawnexpectr   r   questionYesNosendlineRuntimeErrorTIMEOUTEOF
exitstatuspid)selflportrportserverremoteipkeyfilepasswordr   sshportr	   outputr0   r1   r   
ssh_newkeytunnelfailedihostr)   replys                         r
   openssh_tunnelrB      sK    C uw
f}}||C((x$!cc66
*C";s4@@@VZ 	&W--a/C0@0@@ABB6%:1 1&{3tDDD 	OL#++l6A67+9 +9 : : : J
;"%uhvw?P PC *//

CGGM4   ?J]3C(((FF)(	^_=   A Avv||C((, + , ,.23 $,T1Y<<-8_{~-M-8^= = KO++OOE***OOD)))&LMMO O OAvv(.)))  J)"1%G#H#HIII OOH%%%FF%  	 	 	H{ 	" 	" 	"  ""1%B#C#Cc#IJJJz!!!		"3)s    B8J =AJ K;KK)r   NNr   )__doc__r    r#   qtpy.QtWidgetsr   namer   spyder.config.baser   r   rB    r   r
   <module>rH      s    3 2  				 & & & & & &	w$NNN               9D8;N N N N N Nr   