o
    »¼tf³  ã                   @  st   d Z ddlm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mZ dd	lmZ G d
d„ deeeƒZdS )z7A lab app that runs a sub process for a demo or a test.é    )ÚannotationsN)ÚAny)ÚExtensionAppÚExtensionAppJinjaMixin)ÚIOLoopé   )Ú	LabConfigÚadd_handlers)ÚProcessc                   @  sJ   e Zd ZdZdZdZddd„Zdd	d
„Zddd„Zddd„Z	ddd„Z
dS )Ú
ProcessAppzFA jupyterlab app that runs a separate process and exits on completion.TFÚreturnú tuple[list[str], dict[str, Any]]c                 C  s   t jdgi fS )zeGet the command and kwargs to run with `Process`.
        This is intended to be overridden.
        z	--version)ÚsysÚ
executable©Úself© r   úf/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/jupyterlab_server/process_app.pyÚget_command   s   zProcessApp.get_commandÚNonec                 C  s   t  ¡  | j¡ dS )zStart the application.N)r   ÚcurrentZadd_callbackÚ_run_commandr   r   r   r   Úinitialize_settings   s   zProcessApp.initialize_settingsc                 C  s   t | j| ƒ dS )zInitialize the handlers.N)r	   Úhandlersr   r   r   r   Úinitialize_handlers#   s   zProcessApp.initialize_handlersc                 C  sD   |   ¡ \}}| d| j¡ t|fi |¤Ž ¡ }t ¡  || j¡ d S )NÚlogger)	r   Ú
setdefaultÚlogr
   Z
wait_asyncr   r   Z
add_futureÚ_process_finished)r   ÚcommandÚkwargsÚfuturer   r   r   r   '   s   zProcessApp._run_commandr!   r   c              
   C  sb   zt  ¡  ¡  t | ¡ ¡ W d S  ty0 } z| j t	|ƒ¡ t d¡ W Y d }~d S d }~ww )Nr   )
r   r   Ústopr   ÚexitÚresultÚ	Exceptionr   ÚerrorÚstr)r   r!   Úer   r   r   r   -   s   €þzProcessApp._process_finishedN)r   r   )r   r   )r!   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Zload_other_extensionsZopen_browserr   r   r   r   r   r   r   r   r   r      s    



r   )r,   Ú
__future__r   r   Útypingr   Z$jupyter_server.extension.applicationr   r   Ztornado.ioloopr   r   r   r	   Úprocessr
   r   r   r   r   r   Ú<module>   s   