
    oiČ                        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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 ddlmZ ddlmZ d dlmZ d dlmZ d dl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! d dl"m#Z# d dl$m%Z% 	 dZ&d dl'm(Z(m)Z) d dl*m+Z+ d dl,m-Z-m.Z. d dl/m0Z0 d dl1m2Z2 d dl*m3Z3 d dl4m5Z5 d dl6m7Z7 d dl8m9Z9 d dl:m;Z; ddl<m=Z= d dl6m7Z7 d dl:m;Z; d dl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJ d dlKmLZL d dlMmNZN d dlOmPZP ddlQmRZR dd lSmTZT dd!lUmVZV dd"lWmXZX dd#lYmZZZm[Z[m\Z\m]Z] dd$l^m_Z_ dd%l`maZa dd&lbmcZcmdZdmeZe dd'lfmgZg dd(lhmiZi dd)ljmkZkmlZlmmZmmnZn dd*lompZp d+Zqd, Zr G d- d.eL      Zsesj                  Zuy# e>$ r dZ&d dl4m5Z5m7Z7 d dl?m9Z9 Y w xY w)/    N   )VoilaKernelWebsocketHandler)ExecutionRequestHandler)VoilaContentsHandler)urljoin)pathname2url)jupyter_config_path)FileFindHandler
path_regex)recursive_update)LargeFileManager)KernelHandlerT)AllowAllAuthorizer
Authorizer)PasswordIdentityProvider)DEFAULT_TEMPLATE_PATH_LISTDEFAULT_STATIC_FILES_PATH)BaseKernelWebsocketConnection)ZMQChannelsWebsocketConnection)IdentityProvider)url_path_join)run_sync)ConfigManager)ThemesHandler)VoilaLoginHandlerF)r   r   )
BoolCallableDictIntegerListUnicodedefaultTypeBytesvalidate)Application)Config)warn)__version__)VoilaConfiguration)VoilaExecutor)VoilaExporter)ROOTSTATIC_ROOTcollect_static_pathscollect_template_paths)RequestInfoSocketHandler)VoilaShutdownKernelHandler)AllowListFileHandlerMultiStaticFileHandlerTemplateStaticFileHandler)TornadoVoilaHandler)TornadoVoilaTreeHandler)create_include_assets_functionsget_data_dirpjoinget_voila_labextensions_path)voila_kernel_manager_factoryz"(?P<kernel_id>\w+-\w+-\w+-\w+-\w+)c                     | S N )xs    Q/home/ubuntu/docker-apps/notebooks/venv/lib/python3.12/site-packages/voila/app.py_rB   r   s    H    c                       e Zd ZdZeZdZdej                  iddid e	d      fd dd	ii e	d
      fdddii e	d      fdddii e	d      fdZ
eri e
dd ddii e	d      fiZ
 ed      Z ed      Z e       Z edd e	d            Z ed	d e	d            Z ed e	d            Z eed e	d            Zddddd d!d"d#d$d%d&d'd(d)d*Zeri edd+iZeeegZ ed e	d,            Z e       Z ed-d e	d.            Z ed/dd e	d0      1      Z ed/dd e	d2      1      Z  e!g d e	d3            Z" e!egd e	d4            Z# ed/dd56      jI                  d7      Z% ed/dd86      jI                  d7      Z& ed9d e	d:            Z' ed;d e	d<            Z( edd e	d=            Z) eddd>      Z* ed?d e	d@            Z+ edd e	dA            Z, e-d/dd e	dB      C      Z. e/dD      dE        Z0er e1dFddG      Z2 ed/dHdI      jI                  d7      Z3 ed	dJdI      jI                  d7      Z4 e5dK      dL        Z6 e7e8e9d e	dM      N      Z: e7e;e<d e	dO      N      Z= e7e>e?d e	dP      N      Z@eAdQ        ZBeAdR        ZCdS ZD e! e       d e	dT            ZE eFi d e	dU            ZG e5dV      dW        ZH e5dX      dY        ZI e5d      dZ        ZJeAd[        ZKeAd\        ZLeAd]        ZMeAd^        ZN e5d_      d`        ZO e/da      db        ZP e/dc      dd        ZQde ZRdq fdf	ZSdg ZTdheFfdiZUdhe!fdjZVdk ZWdl ZXdm ZYdn ZZdo Z[dp Z\ xZ]S )rVoilavoilazvoila example.ipynb --port 8888	log_levelshow_tracebacksT)rE   r*   zLSet the log level to logging.DEBUG, and show exception tracebacks in output.open_browserFz3Don't open the notebook in a browser after startup.r*   show_marginszXShow left and right margins for the "lab" template, this gives a "classic" template lookclassic_treezFUse the jinja2-based tree page instead of the new JupyterLab-based one)debugz
no-browserzshow-marginszclassic-treetoken
auto_token zovoila [OPTIONS] NOTEBOOK_FILENAME

        This launches a stand-alone server for read-only notebooks.
        zZ
        notebook_path:
            File name of the Jupyter notebook to display.
        i"  u(   Port of the Voilà server. Default 8866.)confighelpzVWill autoreload to server and the page when a template, js file or Python code changesz#The directory to use for notebooks.z9Directory holding static assets (HTML, JS and CSS files).zVoila.autoreloadzVoila.base_urlz
Voila.portzVoila.static_rootzVoila.server_urlz$VoilaConfiguration.default_pool_sizez"VoilaConfiguration.show_tracebacksz!VoilaConfiguration.preheat_kernelz(VoilaConfiguration.progressive_renderingz VoilaConfiguration.strip_sourceszVoilaConfiguration.templatezVoilaConfiguration.themezVoilaConfiguration.classic_treez,VoilaConfiguration.kernel_spec_manager_class)
autoreloadbase_urlportstatic
server_url	pool_sizerH   preheat_kernelprogressive_renderingstrip_sourcestemplatethemerK   kernel_spec_manager_classzVoila.tokenzYLocation of temporary connection files. Defaults to system `tempfile.gettempdir()` value./uH  Path for Voilà API calls. If server_url is unset, this will be             used for both the base route of the server and the client.             If server_url is set, the server will server the routes prefixed             by server_url, while the client will prefix by base_url (this is             useful in reverse proxies).NuI   Path to prefix to Voilà API handlers. Leave unset to default to base_url)rP   
allow_nonerQ   u%   path to notebook to serve with Voilàzpath to jinja2 templateszpaths to static assetsz/
        Mathjax default configuration
        )r_   rQ   )rP   zT
        URL to load Mathjax from.

        Defaults to loading from cdnjs.
        2   zMThe number of additional ports to try if the specified port is not available.	localhostz2The IP address the notebook server will listen on.ap  Whether to open in a browser after starting.
                        The specific browser used is platform dependent and
                        determined by the python standard library `webbrowser`
                        module, unless it is overridden using the --browser
                        (NotebookApp.browser) configuration option.
                        al  Specify what command to use to invoke a web
                      browser when opening the notebook. If not specified, the
                      default browser will be determined by the `webbrowser`
                      standard library module, which allows setting of the
                      BROWSER environment variable to override it.
                         ai  Specify Where to open the notebook on startup. This is the
                                  `new` argument passed to the standard library method `webbrowser.open`.
                                  The behaviour is not guaranteed, but depends on browser support. Valid
                                  values are:
                                  - 2 opens a new tab,
                                  - 1 opens a new window,
                                  - 0 opens in an existing window.
                                  See the `webbrowser.open` documentation for details.
                                  a  Override URL shown to users.
                                 Replace actual URL, including protocol, address, port and base URL,
                                 with the given value when displaying URL to the users. Do not change
                                 the actual connection URL. If authentication token is enabled, the
                                 token is added to the custom URL automatically.
                                 This option is intended to be used when the URL to display to the user
                                 cannot be determined reliably by the Jupyter notebook server (proxified
                                 or containerized setups for example).a  A function that is called prior to the launch of a new kernel instance
            when a user visits the voila webpage. Used for custom user authorization
            or any other necessary pre-launch functions.

            Should be of the form:

            def hook(req: tornado.web.RequestHandler,
                    notebook: nbformat.NotebookNode,
                    cwd: str)

            Although most customizations can leverage templates, if you need access
            to the request object (e.g. to inspect cookies for authentication),
            or to modify the notebook itself (e.g. to inject some custom structure,
            although much of this can be done by interacting with the kernel
            in javascript) the prelaunch hook lets you do that.
            )default_valuer_   rP   rQ   prelaunch_hookc                 X    t        dt        d       |d   | j                  _        |d   S )NzXVoila.prelaunch_hook is deprecated, please use VoilaConfiguration.prelaunch_hook insteadrb   
stacklevelvalue)r(   DeprecationWarningvoila_configurationrd   selfproposals     rA   _valid_prelaunch_hookzVoila._valid_prelaunch_hookh  s3    f	

 3;72C  /  rC   rC   a  The random bytes used to secure cookies.
            By default this is a new random number every time you start the server.
            Set it to a value in a config file to enable logins to persist across server sessions.

            Note: Cookie secrets should be kept private, do not share config files with
            cookie_secret stored in plaintext (you can read the value from a file).
            zToken for identity provider )rQ   r_   zGenerate token automatically cookie_secretc                 ,    t        j                  d      S )N    )osurandomrl   s    rA   _default_cookie_secretzVoila._default_cookie_secret  s    ::b>!rC   zThe authorizer class to use.)rc   klassrP   rQ   z#The identity provider class to use.z-The kernel websocket connection class to use.c                    | j                   r#| j                   }|j                  d      sH|dz  }nB| j                  dv rdt        j                         z  n| j                  }| j                  |      }t        rJ| j                  j                  r4| j                  j                  r| j                  j                  nd}d| }nd}| | S )Nr^   )rO   z0.0.0.0z%sz...z?token=rO   )
custom_display_urlendswithipsocketgethostname_urlJUPYTER_SERVER_2identity_providerrM   token_generated)rl   urlrz   rM   querys        rA   display_urlzVoila.display_url  s    ""))C<<$s
04?0J**,,PTPWPWB))B-C 6 6 < < ))99 &&,, 
 eW%EEugrC   c                 X    | j                   r| j                   nd}| j                  |      S )Nra   )rz   r}   )rl   rz   s     rA   connection_urlzVoila.connection_url  s!    TWW[yy}rC   c                 @    d}d||| j                   | j                  fz  S )Nhttpz%s://%s:%i%s)rT   rS   )rl   rz   protos      rA   r}   z
Voila._url  s%     DIIt}} EEErC   z#Paths to search for voila.(py|json)zFExtra settings to apply to tornado application, e.g. headers, ssl, etcconfig_file_pathsc                 @    t        j                         gt               S r>   )rr   getcwdr	   rt   s    rA   _config_file_paths_defaultz Voila._config_file_paths_default  s    		41344rC   connection_dir_rootc                 j    t        j                         }| j                  j                  d|z         |S )Nz"Using %s to store connection files)tempfile
gettempdirloginfo)rl   connection_dirs     rA   _default_connection_dirzVoila._default_connection_dir  s,    !,,.:^KLrC   c                 "    t         j                  S r>   )loggingINFOrt   s    rA   _default_log_levelzVoila._default_log_level  s    ||rC   c                 @    t        | j                  j                        S r>   )r;   rj   extra_labextensions_pathrt   s    rA   labextensions_pathzVoila.labextensions_path  s    +$$==
 	
rC   c                     t               S r>   )r9   rt   s    rA   data_dirzVoila.data_dir  s
    ~rC   c                 .    t        | j                  d      S )Nschemasr:   r   rt   s    rA   schemas_dirzVoila.schemas_dir  s    T]]I..rC   c                 .    t        | j                  d      S )Nthemesr   rt   s    rA   
themes_dirzVoila.themes_dir  s    T]]H--rC   root_dirc                     | j                   rFt        j                  j                  t        j                  j	                  | j                               S t        j
                         S r>   )notebook_pathrr   pathdirnameabspathr   rt   s    rA   _default_root_dirzVoila._default_root_dir  s=    77??277??43E3E#FGG99;rC   mathjax_urlc                 0    t        dt        d       |d   S )NzWVoila.mathjax_url is deprecated, this option will be removed in the next major release.rb   rf   rh   r(   ri   rk   s     rA   _valid_mathjax_urlzVoila._valid_mathjax_url  s     e	

   rC   mathjax_configc                 0    t        dt        d       |d   S )NzZVoila.mathjax_config is deprecated, this option will be removed in the next major release.rb   rf   rh   r   rk   s     rA   _valid_mathjax_configzVoila._valid_mathjax_config  s     h	

   rC   c                    t         j                  j                  d      rTt         j                  dk\  r@ddl}	 ddlm}m} t        |j                               |u r|j                   |              yyyy# t        $ r Y yw xY w)a,  set default asyncio policy to be compatible with tornado
        Tornado 6 (at least) is not compatible with the default
        asyncio implementation on Windows
        Pick the older SelectorEventLoopPolicy on Windows
        if the known-incompatible default policy is in use.
        do this as early as possible to make it a low priority and overridable
        ref: https://github.com/tornadoweb/tornado/issues/2608
        FIXME: if/when tornado supports the defaults in asyncio,
               remove and bump tornado requirement for py38
        win)      r   N)WindowsProactorEventLoopPolicyWindowsSelectorEventLoopPolicy)sysplatform
startswithversion_infoasyncior   r   typeget_event_loop_policyset_event_loop_policyImportError)rl   r   r   r   s       rA   _init_asyncio_patchzVoila._init_asyncio_patch  s     <<""5)c.>.>&.HT 668956
 112P2RS6 /I)  s   A5 5	B Bc                    | j                          | j                  j                  d| j                         t        |   |       t        | j                        dk(  rw| j                  d   }| j                  st        j                  j                  |      r|| _        net        j                  j                  |      r|| _        n>t        d|z        t        | j                        dk7  rt        d| j                  z        | j                  d| j                         t!        |       | _        | j%                          t'        j&                  t&        j(                  | j*                         y )	Nz"Searching path %s for config filesr   r   z.argument is neither a file nor a directory: %rz!provided more than 1 argument: %rrF   )r   parent)r   r   rL   r   super
initializelen
extra_argsr   rr   r   isdirr   isfile
ValueErrorload_config_filer*   rj   setup_template_dirssignalSIGTERM_handle_signal_stop)rl   argvarg	__class__s      rA   r   zVoila.initialize%  s     ";T=S=ST4 t1$//!$C%%77==%$'DMWW^^C(),D&$H3N  !Q&@4??RSS 	gD,B,BC#5T#B   "fnnd&>&>?rC   c                    | j                   j                  rC| j                   j                  }t        ddg|d      | _        t	        ddg|      | _        t        r| j
                  j                  t               | j                  D cg c]"  }t        j                  j                  |d      $ }}|D ]  }t        j                  j                  |      s#t        |      5 }t        j                  |      }d d d        dv sQt!        |d   | j                   j"                  j$                         t'        |d         | j                   j"                  _         | j(                  j+                  d| j                   j                         | j(                  j+                  dd	j                  | j                               | j(                  j+                  d
d	j                  | j
                               | j,                  rBt        j                  j                  | j,                        st/        d| j,                  z        y y c c}w # 1 sw Y   SxY w)NrF   	nbconvertT)prunez	conf.jsontraitlet_configurationzusing template: %sztemplate paths:
	%sz
	zstatic paths:
	%szNotebook not found: %s)rj   r[   r0   template_pathsr/   static_pathsr~   appendr   rr   r   joinexistsopenjsonloadr   rP   r*   r'   r   rL   r   r   )rl   template_named
conf_pathsp	json_fileconfs          rA   r   zVoila.setup_template_dirs@  s   ##,, 44==M"8+&T#D !5+&!D  !!(()BC@D@S@ST1"'',,q+6TJT 77>>!$a 4I#yy34 047( !9: 44;;NN
 NT !9:N0077J  	+T-E-E-N-NO.D<O<O0PQ,fkk$:K:K.LMbggnnT5G5G&H58J8JJKK 'I) U
4 4s   	'I"I		I	returnc                    | j                   xs | j                  | _         | j                  j                  |       | _        t               D cg c]"  }t        j                  j                  |d      $ }}|t               D cg c]"  }t        j                  j                  |d      $ c}z  }t        | |      | _
        t        |       | _        | j                  j                  }| j                  j                  }|r!| j                  j                  rt!        d      | j                  j"                  }|r|rt!        d      t$        s|rt!        d      t'        | j                  j(                  ||| j                  j*                        } || | j,                  | j                  g d	
      | _        ddi}t1        j2                  dt1        j4                  | j6                        dgd|}t9        j:                  dt        j                  j                  t<        d      d      }	|j?                  |	d       t$        rt1        j2                  dt1        j4                  t@              dgd|}
|
j?                  |	d       | | jB                  tD        d}| jF                  | jH                  sd|d<   n| jF                  | jF                  |d<    | jJ                  di || _&        | jO                  | | jB                  | jL                        | _(        tS        | j                  | j                   xs | j                  | j.                  | j                  d| jT                  |t$        r
n|d| j                  | j                  | jV                  | jX                        }| || jZ                  <   t$        rHi || j\                  | jP                  | jL                  | j^                  ta        | j                  d      d}|S c c}w c c}w )z*Initialize settings for Voila application.r   serverconfignbconfig)r   read_config_pathz6`preheat_kernel` and `prelaunch_hook` are incompatiblez=`preheat_kernel` and `progressive_rendering` are incompatiblezB`progressive_rendering` can only be enabled with jupyter_server>=2)page_config_hook)	comm_open
comm_closecomm_msgcomm_info_requestkernel_info_requestshutdown_request)r   r   kernel_spec_managerallowed_message_types
autoescapeTzjinja2.ext.i18n)loader
extensionsnbuii18n)	localedirfallbackF)newstyle)r   r   login_handler_classrO   rM   )r   r   r   r^   )rS   rV   kernel_managerr   allow_remote_accessrR   voila_jinja2_env
jinja2_envserver_root_dircontents_managerconfig_managerr   r   z/login)ro   
authorizerr   !kernel_websocket_connection_class	login_urlr?   )1rV   rS   rj   r]   r   r	   rr   r   r   r   r  r   r  rX   default_pool_sizerd   	ExceptionrY   r~   r<   multi_kernel_manager_classr   r   r   jinja2EnvironmentFileSystemLoaderr   gettexttranslationr-   install_gettext_translationsr   r   r   rM   rN   identity_provider_classr   authorizer_classr  dictrR   r   r   namero   r  r   )rl   r   r   rX   rW   rY   kernel_manager_classjenv_optenvr   
server_envidentity_provider_kwargssettingss                rA   init_settingszVoila.init_settingsb  s    //:T]]#'#;#;#U#U $V $
  6I5J
01BGGLLN+
 
 	BUBWXQRWW\\!Z8XX+*:
 !1 =#77FF11CC	d66EETUU $ 8 8 N N3O   $9T   <$$??!55FF	 
 3.. $ 8 8#	
 $
    
**4+>+>?)*
 

 ""bggll484
 	(((>++ ../IJ-. J
 33D53I xx'8($
 zz!$//46(1'48JJ(1%AT%A%A &*&D" #33T=S=S 4 DO ]]7$--.. $ 8 8 $ %5z3!22....((
 #!%!3!3"oo%)%;%;595[5[*4==(CH _
 Ys   'O?'Pc                    g }d| j                   i}|j                  t        | j                  dt        z        t
        ft        | j                  dt        z        t        ft        | j                  d      t        ft        | j                  d      t        | j                  ddft        | j                  d      t        d	| j                  t        | j                   j                        d
gdft        | j                  d      t        fg       t        r)|j                  | j                   j#                                | j                   j$                  r2|j'                  t        | j                  dt        z        t(        f       | j                   j*                  r2|j'                  t        | j                  dt        z        t,        f       |j'                  t        | j                  d      t.        | j0                  d
gdf       |j'                  t        | j                  d      t2        | j                   j4                  | j                   j6                  | j8                  df       | j:                  r|j'                  t        | j                  d      t<        t>        j@                  jC                  | j:                  | j8                        | jD                  | jF                  | j                   df       |S | jH                  jK                  d| j8                         |j                  | j                  tL        d| j                   ift        | j                  dtN        z         tL        d| j                   ift        | j                  d      t<        | jD                  | jF                  | j                   dft        | j                  dtN        z        tP        |fg       |S )z*Initialize handlers for Voila application.rj   z/api/kernels/%sz/api/kernels/%s/channelsz/voila/templates/(.*)z/voila/static/(.*)z
index.html)pathsdefault_filenamez/voila/api/themes/(.*)z/voila/api/themesr^   )
themes_urlr   r   no_cache_pathsz/voila/api/shutdown/(.*)z/voila/query/%sz/voila/execution/%sz/voila/labextensions/(.*))r   r   z/voila/files/(.*))	allowlistdenylistr   z/(.*))r   r   rP   rj   zserving directory: %rz/voila/treez/voila/render/(.*))r   rP   rj   z/voila/api/contents%s))rj   extendr   rV   _kernel_id_regexr   r   r5   r4   r   r   r   r;   r   r2   r~   r   get_handlersrX   r   r1   rY   r   r
   r   r3   file_allowlistfile_denylistr   r   r6   rr   r   relpathr   rP   r   rL   r7   r   r   )rl   handlerstree_handler_confs      rA   init_handlerszVoila.init_handlers  s   2D4L4LM ");>N)N "	 ")DGW)W 0	 "$//3KL-
 "$//3HI*"//\R "$//3LM!&9 $.J 44MM/ ,/% "$//3NO.E&(	
T OOD22??AB##22OO!);>N)N -	 ##99OO!)?BR)R ,	 	doo/KL 33'*e		
 	doo/CD$!%!9!9!H!H $ 8 8 F F MM
	
 OO!$//8<')+ ..* +/*=*="&++/3/G/G^ A HHNN2DMMBOO /.0H0HI &doo~
7RS/.0H0HI &doo7LM+.2.A.A&*kk373K3K & OO-E
-R -)+> rC   c                 .   t        j                  d| j                        | _        | j                  j                  d| j                  z         | j                  j                  d| j                  z         | j                         }t        j                  j                  di || _        | j                  j                  j                  | j                         | j                         }| j                  j!                  d|       | j#                          y )Nvoila_)prefixdirzStoring connection files in %s.zServing static files from %s.z.*$r?   )r   mkdtempr   r   r   r   static_rootr  tornadowebr&   appr  updatetornado_settingsr+  add_handlerslisten)rl   r  r)  s      rA   startzVoila.starti  s    &..!9!9
 	7$:M:MMN58H8HHI%%';;**6X6  !6!67%%'eX.rC   c                     | j                   j                  d|z         | j                  j                  | j                  j                         y )NzHandle signal %s.)r   r   ioloopadd_callback_from_signalstop)rl   sigframes      rA   r   zVoila._handle_signal_stopx  s4    )C/0,,T[[-=-=>rC   c                     t        j                  | j                          t        | j                  j
                                y r>   )shutilrmtreer   r   r   shutdown_allrt   s    rA   r=  z
Voila.stop|  s-    d))*2$$1124rC   c           
   #      K   t        t        d|            D ]	  }||z     t        |dz
        D ]-  }t        d|t        j                  d|z  d|z        z          / yw)zGenerate a list of n random ports near the given port.

        The first 5 ports will be sequential, and the remaining n-5 will be
        randomly selected in the range [port-2*n, port+2*n].
           r   rb   N)rangeminmaxrandomrandint)rl   rT   nis       rA   random_portszVoila.random_ports  sg      s1ay! 	A(N	q1u 	?AarAvq1u ==>>	?s   A!A#c           	         d}| j                  | j                  | j                  dz         D ]  }	 | j                  j	                  || j
                         || _        | j                  j                  r| j                  j                  d       | j                  j                  d| j                  z         || _        d} n |s5| j                  j%                  t        d	             | j'                  d       | j(                  r| j+                          t,        j.                  j0                  j3                         | _        	 | j.                  j5                          | j9                          y # t        $ r}|j                  t        j                  k(  r-| j                  j                  t        d      |z         Y d }~|j                  t        j                  t!        t        dt        j                        fv r-| j                  j#                  t        d      |z         Y d }~ d }~ww xY w# t6        $ r | j                  j                  d
       Y w xY w# | j9                          w xY w)NFr   z"Progressive rendering is activatedu   Voilà is running at:
%sTz3The port %i is already in use, trying another port.	WSAEACCESz&Permission to listen on port %i denieduW   ERROR: the Voilà server could not be started because no available port could be found.zStopping...)rN  rT   port_retriesr4  r8  rz   rj   rY   r   r   r   OSErrorerrno
EADDRINUSErB   EACCESgetattrwarningcriticalexitrI   launch_browserr2  r;  IOLoopcurrentr9  KeyboardInterruptr=  )rl   successrT   es       rA   r8  zVoila.listen  s   %%dii1B1BQ1FG 	Ddgg. 	++AAHHMM"FG9D<L<LLM  !	1	4 HH8 IIaL!nn++335	KK IIKK  77e...HHMMOPSWW WWLLE;=!  HH$$Q'O%PSW%WXD ! 	)HHMM-(	) IIKsJ   BE.H2 .	H/7AH*A"H*)H**H/2$II II I.c           
         
 	 t        j                   j                  xs d       

sy  j                  }t        j                  d      \  }t        |dd      5 }t         j                  |      }t         j                  j                  |      } j                   j"                  d   }|j%                  d      }|j'                   |j(                  d|| j                  j*                  d	|       d d d        
 fd
}	t-        j.                  |	      j1                          y # t         j                  $ r4} j                  j                  t        d      |z         d 
Y d }~Fd }~ww xY w# 1 sw Y   xY w)NzNo web browser found: %s.z.html)suffixwzutf-8)encodingr   zbrowser-open.html)open_urlrS   r\   c                  d     j                  t        dt                    j                        S )Nzfile:)new)r   r   r   webbrowser_open_new)browser	open_filerl   s   rA   targetz$Voila.launch_browser.<locals>.target  s0    <<i!89t?W?W    rC   )rj  r?   )
webbrowsergetrh  Errorr   rW  rB   rS   r   mkstempr   r   r   r8   rj   r[   r4  r  get_templatewriterenderr\   	threadingThreadr9  )rl   r_  urifdfhr   include_assets_functionsr  r[   rj  rh  ri  s   `         @@rA   rZ  zVoila.launch_browser  sT   	 nnT\\%9T:G
 mm ((8I"cG, 	 3 3S9C'F((113($ **+=>J!../BCHHH   2288 /		$	
 	'--/C  	HHQ:;a?@G		 	s$   #D, BE6,E3?)E..E36E?r>   )^__name__
__module____qualname__r  r)   versionexamplesr   DEBUGrB   flagsr~   r!   descriptionoption_descriptionnotebook_filenamer   rT   r   rR   r   r.   r1  aliasesr*   r+   r,   classesr   r   rS   rV   r   r    r   r   tagr   r   rQ  rz   rI   rh  rg  rx   r   rd   r%   rn   r$   ro   rM   rN   r"   ru   r#   r   r   r  r   r   r  r   r   r  propertyr   r   r}   r   r   r6  r   r   r   r   r   r   r   r   r   r   r   r   r   r  r+  r9  r   r=  rN  r8  rZ  __classcell__)r   s   @rA   rE   rE   v   s   DG0H
 &w}}5'8$&? ^
 ~u-.CD
 %~t&< j	
 %~t&< VW	
-E< 

<./"
 	K !	  	41-W+XYDd
J d+P)QRHJKK )$%(;?=!K;1+9%SG  5W5g}5!=-@G!7
 YN)

H W
	J 67	M "T2L0MNNd;S9TUL 
cc   
cc  
[
L 
CD
B 
L 
	G "	&

  !
J	
 
	N0 !  ! 

 9d

#T#
 	 ;

#T#
 	 
	!	" 
"	"  ,12	
 #'2"89	#
 -18/BC	-
)  *  F 	$Q'L%M 
T
  !5 "5 "# $
 [  
 

   / / . . Z  m! ! !  !T>@6 LDyt yvJt JX?5	?.`$0rC   rE   )vrS  r  r   r   rr   rJ  rA  r   r{   r   r   rr  rk   tornado.kernel_websocket_handlerr   !tornado.execution_request_handlerr   tornado.contentshandlerr   urllib.parser   urllib.requestr   r  tornado.ioloopr2  tornado.webjupyter_core.pathsr	   jupyter_server.base.handlersr
   r   jupyter_server.config_managerr   1jupyter_server.services.contents.largefilemanagerr   (jupyter_server.services.kernels.handlersr   r~   jupyter_server.auth.authorizerr   r   jupyter_server.auth.identityr   jupyter_serverr   r   /jupyter_server.services.kernels.connection.baser   3jupyter_server.services.kernels.connection.channelsr   r   jupyter_server.utilsr   jupyter_core.utilsr   &jupyter_server.services.config.managerr    jupyterlab_server.themes_handlerr   voila_identity_providerr   r   jupyter_server.services.config	traitletsr   r   r   r   r    r!   r"   r#   r$   r%   traitlets.config.applicationr&   traitlets.config.loaderr'   warningsr(   _versionr)   configurationr*   executer+   exporterr,   r  r-   r.   r/   r0   request_info_handlerr1   shutdown_kernel_handlerr2   static_file_handlerr3   r4   r5   tornado.handlerr6   tornado.treehandlerr7   utilsr8   r9   r:   r;   voila_kernel_managerr<   r$  rB   rE   launch_instancemainr?   rC   rA   <module>r     s)       	     
    I F 9   '    2 D : N B=MET 3+D>: ( :   5 *  ! - " # R R : ? 
 1 8  ?8 i0K i0X I  =<<	=s    AE3 3F
F