§
    �Ÿj7  ã                   óÈ  — U d Z ddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZ ddlmZmZmZmZmZmZ ddlmZ ddlmZmZmZmZ ddlmZ dd	lmZ dd
lmZ ddlm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z& ej'        Z'i Z(e)e*d<   e( +                    e¦  «         ddddiidfiZ,e)e*d<   e, +                     edddd¦  «        ¦  «         e( +                    e,¦  «         i Z-e)e*d<   e- +                    e
¦  «         ddddddd d!d"d#d$d%d&œZ.e)e*d'<   e- +                    e.¦  «         ee"e$gZ/ej        ej        ej0                          e*d(<    G d)„ de'¦  «        Z1 G d*„ d+e1¦  «        Z2dS ),a(  A minimal application base mixin for all ZMQ based IPython frontends.

This is not a complete console app, as subprocess will not be able to receive
input, there is no real readline support, among other limitations. This is a
refactoring of what used to be the IPython/qt/console/qtconsoleapp.py
é    N)Úbase_aliasesÚ
base_flags)ÚCBoolÚCUnicodeÚDictÚListÚTypeÚUnicode)Úboolean_flagé   )ÚKernelManagerÚconnectÚfind_connection_fileÚtunnel_to_kernel)ÚBlockingKernelClient)ÚKernelConnectionInfo)ÚNoSuchKernel)Ú	localhost)ÚKernelRestarter)ÚSession)Ú	_filefindÚflagsÚexistingÚJupyterConsoleAppzkernel*.jsonzJConnect to an existing kernel. If no argument specified, guess most recentÚ	app_flagszconfirm-exitzJupyterConsoleApp.confirm_exitzòSet to display confirmation dialog on exit. You can always use 'exit' or
       'quit', to force a direct exit without any confirmation. This can also
       be set in the config file by setting
       `c.JupyterConsoleApp.confirm_exit`.
    zùDon't prompt the user when exiting. This will terminate the kernel
       if it is owned by the frontend, and leave it alive if it is external.
       This can also be set in the config file by setting
       `c.JupyterConsoleApp.confirm_exit`.
    ÚaliaseszJupyterConsoleApp.ipzJupyterConsoleApp.transportzJupyterConsoleApp.hb_portzJupyterConsoleApp.shell_portzJupyterConsoleApp.iopub_portzJupyterConsoleApp.stdin_portzJupyterConsoleApp.control_portzJupyterConsoleApp.existingz!JupyterConsoleApp.connection_filezJupyterConsoleApp.kernel_namezJupyterConsoleApp.sshserverzJupyterConsoleApp.sshkey)ÚipÚ	transportÚhbÚshellÚiopubÚstdinÚcontrolr   ÚfÚkernelÚsshÚsshkeyÚapp_aliasesÚclassesc                   óÂ  — e Zd ZU dZdZej        eef         e	d<   dZ
ej        eef         e	d<   eZ ee¦  «        Z ee¦  «        Z eedd¬¦  «        ZeZ e e¦   «         ¦  «        Z ed	dd
¬¦  «        Z ed	dd¬¦  «        Zdefd„Z ed	dd¬¦  «        Z eddd¬¦  «        Z eddd¬¦  «        Zddeddfd„Zdd„Z dd„Z!defd„Z"dd„Z#dd„Z$ddeddfd„Z%dS )r   z%The base Jupyter console application.zjupyter-console-mixinÚnamea  
        The Jupyter Console Mixin.

        This class contains the common portions of console client (QtConsole,
        ZMQ-based terminal console, etc).  It is not a full console, in that
        launched terminal subprocesses will not be able to accept input.

        The Console using this mixing supports various extra features beyond
        the single-process Terminal IPython shell, such as connecting to
        existing kernel, via:

            jupyter console <appname> --existing

        as well as tunnel via SSH

    ÚdescriptionTz The kernel manager class to use.)Údefault_valueÚconfigÚhelpÚ z/The SSH server to use to connect to the kernel.)r.   r/   z<Path to the ssh key to use for logging in to the ssh server.Úreturnc                 ó.   — dt          j        ¦   «         z  S )Nzkernel-%i.json)ÚosÚgetpid©Úselfs    úf/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/jupyter_client/consoleapp.pyÚ_connection_file_defaultz*JupyterConsoleApp._connection_file_defaultˆ   s   € Ø¥"¤)¡+¤+Ñ-Ð-ó    z$Connect to an already running kernelÚpythonz(The name of the default kernel to start.z’
        Set to display confirmation dialog on exit. You can always use 'exit' or 'quit',
        to force a direct exit without any confirmation.NÚargvc                 ó   — | j         | _        dS )z€build argv to be passed to kernel subprocess

        Override in subclasses if any args should be passed to the kernel
        N)Ú
extra_argsÚkernel_argv©r6   r;   s     r7   Úbuild_kernel_argvz#JupyterConsoleApp.build_kernel_argv™   s   € ð
  œ?ˆÔÐÐr9   c                 óŽ  — | j         }| j        r�	 t          | j        d|g¦  «        }nE# t          $ r8 | j                             d| j        ¦  «         |                      d¦  «         Y nw xY w| j                             d|¦  «         || _        n‰	 t          | j        |g¦  «        }nq# t          $ rd | j        t          j
                             | j        ¦  «        k    r&t          j
                             || j        ¦  «        }n| j        }|| _        Y nw xY w	 t          | j        d|g¦  «        | _        n1# t          $ r$ | j                             d| j        ¦  «         Y dS w xY w	 |                      ¦   «          dS # t          $ r; | j                             d| j        d¬	¦  «         |                      d¦  «         Y dS w xY w)
a‹  find the connection file, and load the info if found.

        The current working directory and the current profile's security
        directory will be searched for the file if it is not given by
        absolute path.

        When attempting to connect to an existing kernel and the `--existing`
        argument does not match an existing file, it will be interpreted as a
        fileglob, and the matching file in the current profile's security dir
        with the latest access time will be used.

        After this method is called, self.connection_file contains the *full path*
        to the connection file, never just its name.
        ú.z1Could not find existing kernel connection file %sr   z!Connecting to existing kernel: %szConnection File not found: %sNz"Failed to load connection file: %rT©Úexc_info)Úruntime_dirr   r   Ú	ExceptionÚlogÚcriticalÚexitÚdebugÚconnection_filer3   ÚpathÚbasenameÚjoinr   ÚOSErrorÚload_connection_fileÚerror)r6   rE   Úcfs      r7   Úinit_connection_filez&JupyterConsoleApp.init_connection_file    s  € ð Ô&ˆØŒ=ð 	*ðÝ)¨$¬-¸#¸{Ð9KÑLÔL��øÝð ð ð Ø”×!Ò!ØGÈÌñô ð ð —	’	˜!‘”���ð	øøøð
 ŒH�NŠNÐ>ÀÑCÔCÐCØ#%ˆDÔ Ð ð	*Ý)¨$Ô*>ÀÀÑNÔN��øÝð *ð *ð *àÔ'­2¬7×+;Ò+;¸DÔ<PÑ+QÔ+QÒQÐQåœŸš k°4Ô3GÑHÔH�B�BàÔ-�BØ')�Ô$Ð$Ð$ð*øøøð	Ý#,¨TÔ-AÀCÈÐCUÑ#VÔ#VˆDÔ Ð øÝð 	ð 	ð 	ØŒH�NŠNÐ:¸DÔ<PÑQÔQÐQØˆFˆFð	øøøð	Ø×%Ò%Ñ'Ô'Ð'Ð'Ð'øÝð 	ð 	ð 	ØŒH�NŠNØ4ØÔ$Øð ñ ô ð ð
 �IŠI�a‰LŒLˆLˆLˆLˆLð	øøøsG   �( ¨?A*Á)A*ÂB( Â(A+DÄDÄD7 Ä7*E%Å$E%Å)E? Å?AGÇGc                 ó  — | j         r| j        s	| j        sdS |                      ¦   «          | j        }| j        }|dk    r/| j                             d|¦  «         t          j	        d¦  «         | j        r| j        s|| _        t          ¦   «         }|| j        | j        | j        | j        | j        dœ}| j                             d|| j        ¦  «         t          ¦   «         | _        	 t#          || j        | j        ¦  «        }n8#  | j                             dd¬	¦  «         |  	                    d
¦  «         Y nxY w|\  | _        | _        | _        | _        | _        | j        }t&          j                             |¦  «        \  }}|dz   |z   | _        |                      ¦   «          | j                             d¦  «         | j                             dt&          j                             | j        ¦  «        ¦  «         dS )zset up ssh tunnels, if needed.NÚtcpz1Can only use ssh tunnels with TCP sockets, not %séÿÿÿÿ)r   Ú
shell_portÚ
iopub_portÚ
stdin_portÚhb_portÚcontrol_portz#Forwarding connections to %s via %szCould not setup tunnelsTrC   r   z-sshz/To connect another client via this tunnel, use:z--existing %s)r   Ú	sshserverr'   rP   r   r   rG   rQ   ÚsysrI   r   rW   rX   rY   rZ   r[   Úinfor   rK   r3   rL   ÚsplitextÚwrite_connection_filerM   )r6   r   r   r^   ÚnewportsrR   ÚrootÚexts           r7   Úinit_sshzJupyterConsoleApp.init_sshÚ   sê  € àŒ}ð 	 T¤^ð 	¸D¼Kð 	ØˆFØ×!Ò!Ñ#Ô#Ð#à”Nˆ	ØŒWˆà˜ÒÐØŒH�NŠNÐNÐPYÑZÔZÐZÝŒH�R‰LŒLˆLàŒ;ð 	˜tœ~ð 	àˆDŒNÝ‘”ˆBð Øœ/Øœ/Øœ/Ø”|Ø Ô-ð&
ð &
ˆð 	Œ�ŠÐ;¸RÀÄÑPÔPÐPõ ‘+”+ˆŒð	Ý'¨¨d¬n¸d¼kÑJÔJˆHˆHøð	àŒH�NŠNÐ4¸tˆNÑDÔDÐDØ�IŠI�a‰LŒLˆLˆLˆLøøøð ñ	
ØŒOØŒOØŒOØŒLØÔð Ô!ˆÝ”G×$Ò$ RÑ(Ô(‰	ˆˆcØ# f™}¨sÑ2ˆÔØ×"Ò"Ñ$Ô$Ð$ØŒ�ŠÐGÑHÔHÐHØŒ�Š�o¥r¤w×'7Ò'7¸Ô8LÑ'MÔ'MÑNÔNÐNÐNÐNs   Ã)D Ä3D:c                 ó  — d}|sˆt          t          j        ¦   «         ¦  «                             d¦  «        d         }| j        }t
          j                             |d|z  ¦  «        }t
          j                             |¦  «        s|nd}|¯ˆ|S )Nr0   ú-rV   zkernel-%s.json)	ÚstrÚuuidÚuuid4ÚsplitrE   r3   rL   rN   Úexists)r6   rR   ÚidentrE   s       r7   Ú_new_connection_filez&JupyterConsoleApp._new_connection_file  s‰   € ØˆØð 		6õ �œ
™œÑ%Ô%×+Ò+¨CÑ0Ô0°Ô4ˆEØÔ*ˆKÝ”—’˜kÐ+;¸eÑ+CÑDÔDˆBõ œ7Ÿ>š>¨"Ñ-Ô-Ð5��°2ˆBð ð 		6ð ˆ	r9   c                 óÔ  — | j         r	d| _        dS t          j        t          j        t          j        ¦  «         	 |                      | j        | j        | j        | j	        | j
        | j        | j        | j        | j        | j        | | j        ¬¦  «        | _        | j        j        }nE# t$          $ r8 | j                             d| j        ¦  «         |                      d¦  «         Y nw xY wt-          j        t0          | j        ¦  «        | _        | j        | j        _        i }| j        |d<    | j        j        di |¤Ž t;          j        | j        j        ¦  «         | j         r| j         !                    ¦   «          | j        }|j	        | _	        |j
        | _
        |j        | _        |j        | _        |j        | _        |j        | _        t;          j        | j        j"        ¦  «         dS )zInitialize the kernel manager.N)r   Úsessionr   rW   rX   rY   rZ   r[   rK   Úkernel_nameÚparentÚdata_dirzCould not find kernel %rr   Úextra_arguments© )#r   Úkernel_managerÚsignalÚSIGINTÚSIG_DFLÚkernel_manager_classr   ro   r   rW   rX   rY   rZ   r[   rK   rp   rr   Úkernel_specr   rG   rH   rI   ÚtÚcastr   Úkernel_client_classÚclient_factoryr>   Ústart_kernelÚatexitÚregisterÚcleanup_ipc_filesr\   r`   Úcleanup_connection_file)r6   rz   ÚkwargsÚkms       r7   Úinit_kernel_managerz%JupyterConsoleApp.init_kernel_manager  sÓ  € ð Œ=ð 	Ø"&ˆDÔØˆFÝŒ•f”m¥V¤^Ñ4Ô4Ð4ð	Ø"&×";Ò";Ø”7ØœØœ.Øœ?Øœ?Øœ?ØœØ!Ô.Ø $Ô 4Ø Ô,ØØœð #<ñ #ô #ˆDÔð  Ô-Ô9ˆKˆKøÝð 	ð 	ð 	ØŒH×ÒÐ8¸$Ô:JÑKÔKÐKØ�IŠI�a‰LŒLˆLˆLˆLð	øøøõ  œf¥]°DÔ4GÑHÔHˆÔØ-1Ô-EˆÔÔ*ØˆØ$(Ô$4ˆÐ Ñ!Ø(ˆÔÔ(Ð2Ð2¨6Ð2Ð2Ð2ÝŒ˜Ô+Ô=Ñ>Ô>Ð>àŒ>ð 	8àÔ×5Ò5Ñ7Ô7Ð7ð Ô ˆØœ-ˆŒØœ-ˆŒØœ-ˆŒØ”zˆŒØœOˆÔØ!Ô1ˆÔåŒ˜Ô+ÔCÑDÔDÐDÐDÐDs   »A)B% Â%?C'Ã&C'c                 ó&  — | j         �| j                              ¦   «         | _        nQ|                      | j        | j        | j        | j        | j        | j	        | j
        | j        | j        | ¬¦
  «
        | _        | j                             ¦   «          dS )zInitialize the kernel client.N)
ro   r   r   rW   rX   rY   rZ   r[   rK   rq   )ru   ÚclientÚkernel_clientr}   ro   r   r   rW   rX   rY   rZ   r[   rK   Ústart_channelsr5   s    r7   Úinit_kernel_clientz$JupyterConsoleApp.init_kernel_clientS  s‘   € àÔÐ*Ø!%Ô!4×!;Ò!;Ñ!=Ô!=ˆDÔÐà!%×!9Ò!9ØœØ”7Øœ.Øœ?Øœ?Øœ?ØœØ!Ô.Ø $Ô 4Øð ":ñ "ô "ˆDÔð 	Ô×)Ò)Ñ+Ô+Ð+Ð+Ð+r9   c                 óÌ   — t          | dd¦  «        rdS |                      ¦   «          |                      ¦   «          |                      ¦   «          |                      ¦   «          dS )zu
        Classes which mix this class in should call:
               JupyterConsoleApp.initialize(self,argv)
        Ú_dispatchingFN)ÚgetattrrS   rd   r†   r‹   r?   s     r7   Ú
initializezJupyterConsoleApp.initializeg  sf   € õ
 �4˜¨Ñ/Ô/ð 	ØˆFØ×!Ò!Ñ#Ô#Ð#Ø�Š‰ŒˆØ× Ò Ñ"Ô"Ð"Ø×ÒÑ!Ô!Ð!Ð!Ð!r9   )N)r1   N)&Ú__name__Ú
__module__Ú__qualname__Ú__doc__r+   r{   ÚUnionrg   r
   Ú__annotations__r,   r)   r   r   r   r	   r   ry   r   r}   r   r>   r\   r'   r8   r   r   rp   r   Úconfirm_exitÚobjectr@   rS   rd   rm   r†   r‹   r�   rt   r9   r7   r   r   ]   s'  € € € € € € Ø/Ð/à"9€Dˆ!Œ'�#�w�,Ô
Ð9Ð9Ñ9ð*€K�”˜˜g˜Ô&ð ð ñ ð" €GØˆD�‰KŒK€EØˆd�7‰mŒm€GØ˜4Ø#ØØ/ðñ ô Ðð
 /Ðà�$�w�w‘y”y‘/”/€Kð �˜ 4Ð.cÐdÑdÔd€IØˆWØ
ØØOðñ ô €Fð.¨#ð .ð .ð .ð .ð ˆx˜ 4Ð.XÐYÑYÔY€Hà�'Ø˜Ð$Rðñ ô €Kð �5ØØð<ðñ ô €Lð+ð + fð +¸ð +ð +ð +ð +ð8ð 8ð 8ð 8ðt4Oð 4Oð 4Oð 4Oðl cð ð ð ð ð3Eð 3Eð 3Eð 3Eðj,ð ,ð ,ð ,ð(
"ð 
"˜vð 
"°ð 
"ð 
"ð 
"ð 
"ð 
"ð 
"r9   c                   óD   ‡ — e Zd ZdZdej        dej        ddfˆ fd„Zˆ xZS )ÚIPythonConsoleAppz$An app to manage an ipython console.Úargsr„   r1   Nc                 óf   •— t          j        dd¬¦  «          t          ¦   «         j        |i |¤Ž dS )zInitialize the app.z6IPythonConsoleApp is deprecated. Use JupyterConsoleAppé   )Ú
stacklevelN)ÚwarningsÚwarnÚsuperÚ__init__)r6   rš   r„   Ú	__class__s      €r7   r¡   zIPythonConsoleApp.__init__w  s<   ø€ åŒÐNÐ[\Ð]Ñ]Ô]Ð]Ø�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ð)Ð)r9   )r�   r‘   r’   r“   r{   ÚAnyr¡   Ú__classcell__)r¢   s   @r7   r™   r™   t  s\   ø€ € € € € Ø.Ð.ð*˜aœeð *¨q¬uð *¸ð *ð *ð *ð *ð *ð *ð *ð *ð *ð *r9   r™   )3r“   r€   r3   rv   r]   Útypingr{   rh   rž   Újupyter_core.applicationr   r   Ú	traitletsr   r   r   r   r	   r
   Útraitlets.config.applicationr   r0   r   r   r   r   Úblockingr   r   Ú
kernelspecr   Úlocalinterfacesr   Ú	restarterr   ro   r   Úutilsr   ÚConnectionFileMixinr   Údictr•   Úupdater   r   r(   r)   r£   r   r™   rt   r9   r7   ú<module>r±      s
  ððð ð ð €€€Ø 	€	€	€	Ø €€€Ø 
€
€
€
Ø Ð Ð Ð Ø €€€Ø €€€à =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5à LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LØ *Ð *Ð *Ð *Ð *Ð *Ø )Ð )Ð )Ð )Ð )Ð )Ø $Ð $Ð $Ð $Ð $Ð $Ø &Ð &Ð &Ð &Ð &Ð &Ø &Ð &Ð &Ð &Ð &Ð &Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð àÔ1Ð ð €€tÐ Ð Ñ Ø ‡‚ˆZÑ Ô Ð ð
 Ø	˜z¨>Ð:Ð;ØTðð€	ˆ4ð ð ñ ð 
× Ò Ø€LØØ(ð	ð
	ñô ñô ð ð  ‡‚ˆYÑ Ô Ð à€ˆÐ Ð Ñ Ø ‡‚ˆ|Ñ Ô Ð ð !Ø.Ø
%Ø+Ø+Ø+Ø/Ø,Ø	,Ø-Ø(Ø(ðð €ˆTð ð ñ ð ‡‚ˆ{Ñ Ô Ð ð #0°À'Ð!J€ˆŒ�”�q”u”Ô	Ð JÐ JÑ JðT"ð T"ð T"ð T"ð T"Ð+ñ T"ô T"ð T"ðn*ð *ð *ð *ð *Ð)ñ *ô *ð *ð *ð *r9   