@@ -441,7 +441,9 @@ def display_output(self, out):
441
441
response = out ["content" ]
442
442
self .send_response (self .iopub_socket , msg_type , response )
443
443
444
- async def perform_startup_checks (self , iframe_src : str = None ):
444
+ async def perform_startup_checks (
445
+ self , jupyter_base_url : str = None , matlab_proxy_base_url : str = None
446
+ ):
445
447
"""
446
448
One time checks triggered during the first execution request. Displays
447
449
login window if matlab is not licensed using matlab-proxy.
@@ -470,19 +472,32 @@ async def perform_startup_checks(self, iframe_src: str = None):
470
472
# as src for iframe to avoid hardcoding any hostname/domain information. This is done to
471
473
# ensure the kernel works in Jupyter deployments. VS Code however does not work the same way
472
474
# as other browser based Jupyter clients.
473
- #
474
- # TODO: Find a workaround for users to be able to use our Jupyter kernel in VS Code.
475
475
if not is_matlab_licensed :
476
+ if not jupyter_base_url :
477
+ # happens for non-jupyter environments (like VSCode), we expect licensing to
478
+ # be completed before hand
479
+ self .log .debug (
480
+ "MATLAB is not licensed and is in a non-jupyter environment. licensing via other means required."
481
+ )
482
+ raise MATLABConnectionError (
483
+ """
484
+ Error: Cannot start MATLAB as no licensing information was found.
485
+ Resolution: Set the environment variable MLM_LICENSE_FILE to provide a network license manager,
486
+ or set MWI_USE_EXISTING_LICENSE to True if the installed MATLAB is already licensed.
487
+ See https://github.com/mathworks/matlab-proxy/blob/main/Advanced-Usage.md for more information.
488
+ To use Online licensing, start a MATLAB Kernel in a Jupyter notebook and login using the web interface
489
+ shown upon execution of any code.
490
+ """
491
+ )
476
492
self .log .debug (
477
493
"MATLAB is not licensed. Displaying HTML output to enable licensing."
478
494
)
479
- self .log .debug (f"{ iframe_src = } " )
480
495
self .display_output (
481
496
{
482
497
"type" : "display_data" ,
483
498
"content" : {
484
499
"data" : {
485
- "text/html" : f'<iframe src={ iframe_src } width=700 height=600"></iframe>'
500
+ "text/html" : f'<iframe src={ jupyter_base_url } { matlab_proxy_base_url } width=700 height=600"></iframe>'
486
501
},
487
502
"metadata" : {},
488
503
},
0 commit comments