
    Gh                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
  SSKJr  SSKJrJr  SSKJrJr  SSKJr  SSKJr  SS	KJr  SS
KJrJr  SSKJrJr  SSKJ r   \RB                  " \RD                  " \#5      5      r$\%" \5      r&SSS00S4\&S'   SSS00S4\&S'   SSS00S4\&S'   \%" \5      r'S\'S'    " S S\RP                  5      r)S r*S r+S r,S r-S  r. " S! S\5      r/S" r0S# r1\2S$:X  aR  S%S&/r3\3 H7  r4\4\Rj                  ;   d  M  S'\/l6        \Rj                  Ro                  \45        M9     \/Rq                  5         gg)(z
This module is meant to run JupyterLab in a headless browser, making sure
the application launches and starts up without errors.
    N)ThreadPoolExecutor)path)aliasesflags)pathname2urlurljoin)IOLoop)StreamClosedError)WebSocketClosedError)BoolUnicode   )LabAppget_app_dir)TestEnv
BrowserApp	core_modeTzStart the app in core mode.z	core-modedev_modezStart the app in dev mode.zdev-modewatchzStart the app in watch mode.zBrowserApp.app_dirzapp-dirc                   D   ^  \ rS rSrSrU 4S jrU 4S jrU 4S jrSrU =r	$ )LogErrorHandler(   z.A handler that exits with 1 on a logged error.c                    > [         TU ]  [        R                  S9  U R	                  [
        R                  5        SU l        g )N)streamF)super__init__sysstderrsetLevelloggingERRORerroredself	__class__s    kC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\jupyterlab/browser_check.pyr   LogErrorHandler.__init__+   s.    

+gmm$    c                    > [        US5      (       a6  UR                  b)  [        UR                  S   [        [        45      (       a  g[
        TU ]  U5      $ )Nexc_infor   F)hasattrr*   
isinstancer
   r   r   filterr$   recordr%   s     r&   r-   LogErrorHandler.filter0   sK     FJ''+6??1-0ACW/XYYw~f%%r(   c                 2   > SU l         [        TU ]	  U5        g )NT)r"   r   emitr.   s     r&   r2   LogErrorHandler.emit=   s    Vr(   )r"   )
__name__
__module____qualname____firstlineno____doc__r   r-   r2   __static_attributes____classcell__r%   s   @r&   r   r   (   s    8
& r(   r   c                 V    [         R                  " 5       R                  [        X5        g)zSynchronous entry point to run a test function.
func is a function that accepts an app url as a parameter and returns a result.
func can be synchronous or asynchronous.  If it is synchronous, it will be run
in a thread, so asynchronous is preferred.
N)r	   currentspawn_callbackrun_test_async)appfuncs     r&   run_testrB   B   s     NN##NC>r(   c                   #    [        5       nU R                  R                  U5        [        5       nUR	                  5         U R                  R                  S5        [        U S5      (       a   [        S[        U R                  5      5      nOU R                  n[        R                  " U5      (       a	  U" U5      nOcU R                  R                  S5        [        R                  " 5       n[        5       nUR!                  XqU5      n[        R"                  " U/5      n UI Sh  vN   U R                  R                  S5        Sn
UR,                  (       a  S	n
U R                  R'                  S
5        OU R                  R                  S5        U R                  R                  S5         U R.                  R1                  5         U R2                  R1                  5         UR1                  5         [4        R6                  " S5        [8        R:                  " U
5        g N! [$         aJ  n	U R                  R'                  S5        U R                  R)                  [+        U	5      5         Sn	A	GNESn	A	ff = f! [$         a0  n	U R                  R)                  [+        U	5      5        S	n
 Sn	A	NSn	A	ff = f! [4        R6                  " S5        [8        R:                  " U
5        f = f7f)zRun a test against the application.
func is a function that accepts an app url as a parameter and returns a result.
func can be synchronous or asynchronous.  If it is synchronous, it will be run
in a thread, so asynchronous is preferred.
zRunning async testbrowser_open_filezfile:z&Using thread pool executor to run testNz!Caught exception during the test:zTest Completer   r   zExiting with 1 due to errorszExiting normallyzStopping server...   )r   log
addHandlerr   startinfor+   r   r   rD   display_urlinspectiscoroutinefunctionasyncioget_event_loopr   run_in_executorwait	Exceptioncriticalerrorstrr"   http_serverstopio_looptimesleepos_exit)r@   rA   handler	env_patchurltestloopexecutortaskeresults              r&   r?   r?   K   s     GGGw	IOOGGLL%& s'((g|C,A,ABCoo ""4((Cy=>%%'%'##HC8||TF#


 GGLL!F78'(GGLL%&	
 	

1
1 	 <=c!f$  c!f 	

1
sz   DK'"H" 'H (H" ,BK'/AI9 3-K' H" "
I6,?I1+K'1I66K'9
J3&J.)J6 .J33J6 6.K$$K'c                   #    [         R                  " U 0 UD6I Sh  vN nUR                  5       I Sh  vN u  p4UR                  S:w  a-  [	        [        U 5      S-   [        UR                  5      -   5      eX44$  N^ NH7f)zRun an asynchronous commandNr   z exited with )rM   create_subprocess_execcommunicate
returncodeRuntimeErrorrT   )cmdkwargsprocstdoutr   s        r&   run_async_processrn      so     //???D++--NF!3s8o5DOO8LLMM>	 @-s    A?A;A?A=AA?=A?c                   #    [         R                  R                  SS5      nUS;  a  Sn[        R                  " [        5       S5      n[        R                  " [        R                  " US5      5      (       dm  [        R                  " U5      (       d*  [         R                  " [        R                  " U5      5        [        / SQUS9I Sh  vN   [        / S	QUS9I Sh  vN   [        S
SSU/US9I Sh  vN   [        R                  " [        R                  " [        S5      [        R                  " US5      5        [        SSU /US9I Sh  vN   g N Nw Nc N7f)-Run the browser test and return an exit code.JLAB_BROWSER_TYPEchromium>   webkitfirefoxrr   browser_testnode_modulesnpminitz-ycwdNrx   installzplaywright@^1.9.2npx
playwrightr}   browser-test.jsnode)rZ   environgetospjoinr   existsmakedirsrn   shutilcopyherer^   browsertargets      r&   run_browserr      s     jjnn0*=G77XXkm^4F::chhv~677zz&!!KK() 56BBB GVTTT
UL)WE6
RRR
KK01388FDU3VW
V%6<&
III	 	CTRIsI   CE EE "E#E 8E9AE EE E E E c                 d   [         R                  R                  SS5      nUS;  a  Sn[        R                  " [        5       S5      n[        R                  " [        R                  " US5      5      (       dD  [         R                  " U5        [        R                  " / SQUS9  [        R                  " / SQUS9  [        R                  " S	S
SU/US9  [        R                  " [        R                  " [        S5      [        R                  " US5      5        [        R                  " SSU /US9$ )rp   rq   rr   >   rs   rt   rr   ru   rv   rw   rz   r|   r~   r   r}   r   r   )rZ   r   r   r   r   r   r   r   
subprocesscallr   r   r   
check_callr   s      r&   run_browser_syncr      s    jjnn0*=G77XXkm^4F::chhv~677
F-6:?VLOOUL)W=6J
KK01388FDU3VW  &*;S!AvNNr(   c                   t   ^  \ rS rSrSr\ rSrSS0r\" SSSS	9r	S
r
\r\r\" S5      rU 4S jrU 4S jrSrU =r$ )r      zAn app the launches JupyterLab and waits for it to start up, checking for
JS console errors, JS errors, and Python logged errors.
Fbase_urlz/foo/z
/lab?resetTz'The default URL to redirect to from `/`)confighelpz	127.0.0.1c                    > U R                   R                  S0 5        SU R                   S   S'   SU R                   S   S'   SU R                   S   S'   [        TU ]  5         g )Npage_config_dataTbrowserTestFbuildAvailableexposeAppInBrowser)settings
setdefaultr   initialize_settingsr#   s    r&   r   BrowserApp.initialize_settings   sa      !3R8;?()-8>C()*:;BF()*>?#%r(   c                    > S nU R                   (       a   [        R                  S:X  a  [        O[        n[        U R                  U5        [        TU ]!  5         g )Nc                      g)Nr    )argsrk   s     r&   rA   ,BrowserApp.initialize_handlers.<locals>.func   s    r(   nt)	test_browserrZ   namer   r   rB   	serverappr   initialize_handlers)r$   rA   r%   s     r&   r   BrowserApp.initialize_handlers   s>    	 ')ww$#KD&#%r(   r   )r4   r5   r6   r7   r8   r   open_browserserverapp_configr   default_urlip
test_flagsr   test_aliasesr   r   r   r   r   r9   r:   r;   s   @r&   r   r      sU     DL"G,,t:cdK	BEG:L&& &r(   c                      [         [        S./$ )N)moduler@   )r4   r   r   r(   r&    _jupyter_server_extension_pointsr      s    
344r(   c                      SS0/$ )Nr   zjupyterlab.browser_checkr   r   r(   r&   _jupyter_server_extension_pathsr      s    1233r(   __main__z--no-browser-testz--no-chrome-testF)9r8   rM   rK   r    rZ   r   r   r   rX   concurrent.futuresr   r   r   jupyter_server.serverappr   r   jupyter_server.utilsr   r   tornado.ioloopr	   tornado.iostreamr
   tornado.websocketr   	traitletsr   r   labappr   r   tests.test_appr   abspathdirname__file__r   dictr   r   StreamHandlerr   rB   r?   rn   r   r   r   r   r   r4   skip_optionsoptionargvr   removelaunch_instancer   r(   r&   <module>r      s]  
    	   
  1  3 6 ! . 2 # ' #
{{3;;x()%[
(;*=>@]^
; '*d);<>Z[
: $wo68VW
7 G}.Y g++ 4?8vJ"O & &B54 z');<LSXX&+J#HHOOF# 
   r(   