Format: application/x-python-code
⬇ Download File (3.8 KB)
   1  o
   2  
   3  �h�@s�dZddlmZddlZddlZddlmZmZddlm	Z	m
   4  Z
   5  ddlZddlmZe	r2ddl
   6  mZdddd
   7  �Zdd�Z	d d!dd�Z	d"d#dd�Zgd�ZdS)$z1Connection file-related utilities for the kernel
   8  �)�annotationsN)�PIPE�Popen)�
   9  TYPE_CHECKING�Any)�write_connection_file��IPKernelApp�app�IPKernelApp | None�return�strcCsNddlm}|durddlm}|��sd}t|��|��}||jd|jg�S)z�Return the path to the connection file of an app
  10  
  11      Parameters
  12      ----------
  13      app : IPKernelApp instance [optional]
  14          If unspecified, the currently running app will be used
  15      r)�filefindNrz.app not specified, and not in a running Kernel�.)	Ztraitlets.utilsr�ipykernel.kernelappr	Zinitialized�RuntimeError�instance�connection_fileZconnection_dir)r
  16  rr	�msg�r�Gc:\Users\shubh\Videos\agent\nova\Lib\site-packages\ipykernel/connect.py�get_connection_filesrcCs|durt�St�|�S)z�Return the absolute path for a connection file
  17  
  18      - If nothing specified, return current Kernel's connection file
  19      - Otherwise, call jupyter_client.find_connection_file
  20      N)r�jupyter_clientZfind_connection_file)rrrr�_find_connection_file(s
  21  rFr�
  22  str | None�unpack�bool�str | dict[str, Any]cCsbt|�}t|��}|��}Wd�n1swY|r/t�|�}|�dd���|d<|S|S)a�Return the connection information for the current Kernel.
  23  
  24      Parameters
  25      ----------
  26      connection_file : str [optional]
  27          The connection file to be used. Can be given by absolute path, or
  28          IPython will search in the security directory.
  29          If run from IPython,
  30  
  31          If unspecified, the connection file for the currently running
  32          IPython Kernel will be used, which is only allowed from inside a kernel.
  33  
  34      unpack : bool [default: False]
  35          if True, return the unpacked dict, otherwise just the string contents
  36          of the file.
  37  
  38      Returns
  39      -------
  40      The connection dictionary of the current kernel, as string or dict,
  41      depending on `unpack`.
  42      N�key�)r�open�read�json�loads�get�encode)rr�cf�fZinfo_str�inforrr�get_connection_info4s
  43  
  44  �
  45  r)�argv�list[str] | None�
  46  Popen[Any]cCs`|durgn|}t|�}d�ddg�}i}d|d<ttjd|d|g|�ftttjd	kd
  47  �|��S)a�Connect a qtconsole to the current kernel.
  48  
  49      This is useful for connecting a second qtconsole to a kernel, or to a
  50      local notebook.
  51  
  52      Parameters
  53      ----------
  54      connection_file : str [optional]
  55          The connection file to be used. Can be given by absolute path, or
  56          IPython will search in the security directory.
  57          If run from IPython,
  58  
  59          If unspecified, the connection file for the currently running
  60          IPython Kernel will be used, which is only allowed from inside a kernel.
  61  
  62      argv : list [optional]
  63          Any extra args to be passed to the console.
  64  
  65      Returns
  66      -------
  67      :class:`subprocess.Popen` instance running the qtconsole frontend
  68      N�;z"from qtconsole import qtconsoleappzqtconsoleapp.main()T�start_new_sessionz-cz
  69  --existing�win32)�stdout�stderr�	close_fds)r�joinr�sys�
  70  executabler�platform)rr*r&�cmd�kwargsrrr�connect_qtconsoleZs���r9)rrr)r9)N)r
  71  rrr
  72  )NF)rrrrrr)NN)rrr*r+rr,)�__doc__�
  73  __future__rr"r4�
  74  subprocessrr�typingrrrrrr	rrr)r9�__all__rrrr�<module>s"
  75  �'�-