matlab-proxy 0.11.0__py3-none-any.whl → 0.12.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of matlab-proxy might be problematic. Click here for more details.
- matlab_proxy/app.py +46 -19
- matlab_proxy/app_state.py +5 -1
- matlab_proxy/constants.py +4 -1
- matlab_proxy/gui/asset-manifest.json +3 -3
- matlab_proxy/gui/index.html +1 -1
- matlab_proxy/gui/static/js/{main.152b02bc.js → main.ea1ebdce.js} +3 -3
- matlab_proxy/gui/static/js/main.ea1ebdce.js.map +1 -0
- {matlab_proxy-0.11.0.dist-info → matlab_proxy-0.12.0.dist-info}/METADATA +1 -1
- {matlab_proxy-0.11.0.dist-info → matlab_proxy-0.12.0.dist-info}/RECORD +14 -14
- matlab_proxy/gui/static/js/main.152b02bc.js.map +0 -1
- /matlab_proxy/gui/static/js/{main.152b02bc.js.LICENSE.txt → main.ea1ebdce.js.LICENSE.txt} +0 -0
- {matlab_proxy-0.11.0.dist-info → matlab_proxy-0.12.0.dist-info}/LICENSE.md +0 -0
- {matlab_proxy-0.11.0.dist-info → matlab_proxy-0.12.0.dist-info}/WHEEL +0 -0
- {matlab_proxy-0.11.0.dist-info → matlab_proxy-0.12.0.dist-info}/entry_points.txt +0 -0
- {matlab_proxy-0.11.0.dist-info → matlab_proxy-0.12.0.dist-info}/top_level.txt +0 -0
matlab_proxy/app.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
# Copyright 2020-
|
|
1
|
+
# Copyright 2020-2024 The MathWorks, Inc.
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import json
|
|
5
5
|
import mimetypes
|
|
6
6
|
import pkgutil
|
|
7
7
|
import sys
|
|
8
|
+
import uuid
|
|
8
9
|
|
|
9
10
|
import aiohttp
|
|
10
11
|
from aiohttp import client_exceptions, web
|
|
@@ -19,6 +20,7 @@ from matlab_proxy.util import mwi
|
|
|
19
20
|
from matlab_proxy.util.mwi import environment_variables as mwi_env
|
|
20
21
|
from matlab_proxy.util.mwi import token_auth
|
|
21
22
|
from matlab_proxy.util.mwi.exceptions import AppError, InvalidTokenError, LicensingError
|
|
23
|
+
from matlab_proxy.constants import IS_CONCURRENCY_CHECK_ENABLED
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
mimetypes.add_type("font/woff", ".woff")
|
|
@@ -93,30 +95,45 @@ def marshal_error(error):
|
|
|
93
95
|
return {"message": error.__str__, "logs": "", "type": error.__class__.__name__}
|
|
94
96
|
|
|
95
97
|
|
|
96
|
-
async def create_status_response(
|
|
97
|
-
|
|
98
|
+
async def create_status_response(
|
|
99
|
+
app, loadUrl=None, client_id=None, transfer_session=False, is_desktop=False
|
|
100
|
+
):
|
|
101
|
+
"""Send a generic status response about the state of server, MATLAB, MATLAB Licensing and the client session status.
|
|
98
102
|
|
|
99
103
|
Args:
|
|
100
104
|
app (aiohttp.web.Application): Web Server
|
|
101
105
|
loadUrl (String, optional): Represents the root URL. Defaults to None.
|
|
106
|
+
client_id (String, optional): Represents the unique client_id when concurrency check is enabled. Defaults to None.
|
|
107
|
+
transfer_session (Boolean, optional): Represents whether the connection should be transfered or not when concurrency check is enabled. Defaults to False.
|
|
108
|
+
is_desktop (Boolean, optional): Represents whether the request is made by the desktop app or some other kernel. Defaults to False.
|
|
102
109
|
|
|
103
110
|
Returns:
|
|
104
|
-
JSONResponse: A JSONResponse object containing the generic state of the server, MATLAB and
|
|
111
|
+
JSONResponse: A JSONResponse object containing the generic state of the server, MATLAB, MATLAB Licensing and the client session status.
|
|
105
112
|
"""
|
|
106
113
|
state = app["state"]
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
status = {
|
|
115
|
+
"matlab": {
|
|
116
|
+
"status": await state.get_matlab_state(),
|
|
117
|
+
"version": state.settings["matlab_version"],
|
|
118
|
+
},
|
|
119
|
+
"licensing": marshal_licensing_info(state.licensing),
|
|
120
|
+
"loadUrl": loadUrl,
|
|
121
|
+
"error": marshal_error(state.error),
|
|
122
|
+
"warnings": state.warnings,
|
|
123
|
+
"wsEnv": state.settings.get("ws_env", ""),
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if IS_CONCURRENCY_CHECK_ENABLED and is_desktop:
|
|
127
|
+
if not client_id:
|
|
128
|
+
client_id = str(uuid.uuid4())
|
|
129
|
+
status["clientId"] = client_id
|
|
130
|
+
|
|
131
|
+
if not state.active_client or transfer_session:
|
|
132
|
+
state.active_client = client_id
|
|
133
|
+
|
|
134
|
+
status["isActiveClient"] = True if state.active_client == client_id else False
|
|
135
|
+
|
|
136
|
+
return web.json_response(status)
|
|
120
137
|
|
|
121
138
|
|
|
122
139
|
@token_auth.authenticate_access_decorator
|
|
@@ -155,7 +172,7 @@ async def get_env_config(req):
|
|
|
155
172
|
|
|
156
173
|
config["useMOS"] = mwi_env.Experimental.should_use_mos_html()
|
|
157
174
|
config["useMRE"] = mwi_env.Experimental.should_use_mre_html()
|
|
158
|
-
|
|
175
|
+
config["isConcurrencyEnabled"] = IS_CONCURRENCY_CHECK_ENABLED
|
|
159
176
|
# In a previously authenticated session, if the url is accessed without the token(using session cookie), send the token as well.
|
|
160
177
|
config["authentication"] = {
|
|
161
178
|
"enabled": state.settings["mwi_is_token_auth_enabled"],
|
|
@@ -182,7 +199,17 @@ async def get_status(req):
|
|
|
182
199
|
Returns:
|
|
183
200
|
JSONResponse: JSONResponse object containing information about the server, MATLAB and MATLAB Licensing.
|
|
184
201
|
"""
|
|
185
|
-
|
|
202
|
+
# The client sends the CLIENT_ID as a query parameter if the concurrency check has been set to true.
|
|
203
|
+
client_id = req.query.get("MWI_CLIENT_ID", None)
|
|
204
|
+
transfer_session = json.loads(req.query.get("TRANSFER_SESSION", "false"))
|
|
205
|
+
is_desktop = req.query.get("IS_DESKTOP", False)
|
|
206
|
+
|
|
207
|
+
return await create_status_response(
|
|
208
|
+
req.app,
|
|
209
|
+
client_id=client_id,
|
|
210
|
+
transfer_session=transfer_session,
|
|
211
|
+
is_desktop=is_desktop,
|
|
212
|
+
)
|
|
186
213
|
|
|
187
214
|
|
|
188
215
|
# @token_auth.authenticate_access_decorator
|
matlab_proxy/app_state.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2020-
|
|
1
|
+
# Copyright 2020-2024 The MathWorks, Inc.
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import contextlib
|
|
@@ -100,6 +100,10 @@ class AppState:
|
|
|
100
100
|
# This variable can be either "up" or "down"
|
|
101
101
|
self.embedded_connector_state = "down"
|
|
102
102
|
|
|
103
|
+
# Specific to concurrent session and is used to track the active client/s that are currently
|
|
104
|
+
# connected to the backend
|
|
105
|
+
self.active_client = None
|
|
106
|
+
|
|
103
107
|
def __get_cached_config_file(self):
|
|
104
108
|
"""Get the cached config file
|
|
105
109
|
|
matlab_proxy/constants.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2023 The MathWorks, Inc.
|
|
1
|
+
# Copyright 2023-2024 The MathWorks, Inc.
|
|
2
2
|
from typing import Final, List
|
|
3
3
|
|
|
4
4
|
"""This module defines project-level constants"""
|
|
@@ -22,3 +22,6 @@ SUPPORTED_MATLAB_VERSIONS: Final[List[str]] = [
|
|
|
22
22
|
"R2023a",
|
|
23
23
|
"R2023b",
|
|
24
24
|
]
|
|
25
|
+
|
|
26
|
+
# This constant when set to True restricts the number of active sessions to one
|
|
27
|
+
IS_CONCURRENCY_CHECK_ENABLED: Final[bool] = True
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "./static/css/main.47712126.css",
|
|
4
|
-
"main.js": "./static/js/main.
|
|
4
|
+
"main.js": "./static/js/main.ea1ebdce.js",
|
|
5
5
|
"static/media/mathworks-pictograms.svg?20181009": "./static/media/mathworks-pictograms.f6f087b008b5a9435f26.svg",
|
|
6
6
|
"static/media/MATLAB-env-blur.png": "./static/media/MATLAB-env-blur.4fc94edbc82d3184e5cb.png",
|
|
7
7
|
"static/media/mathworks.svg?20181004": "./static/media/mathworks.80a3218e1ba29f0573fb.svg",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"static/media/gripper.svg": "./static/media/gripper.9defbc5e76d0de8bb6e0.svg",
|
|
36
36
|
"static/media/arrow.svg": "./static/media/arrow.0c2968b90bd9a64c8c3f.svg",
|
|
37
37
|
"main.47712126.css.map": "./static/css/main.47712126.css.map",
|
|
38
|
-
"main.
|
|
38
|
+
"main.ea1ebdce.js.map": "./static/js/main.ea1ebdce.js.map"
|
|
39
39
|
},
|
|
40
40
|
"entrypoints": [
|
|
41
41
|
"static/css/main.47712126.css",
|
|
42
|
-
"static/js/main.
|
|
42
|
+
"static/js/main.ea1ebdce.js"
|
|
43
43
|
]
|
|
44
44
|
}
|
matlab_proxy/gui/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="MATLAB"/><meta name="internal_mw_identifier" content="MWI_MATLAB_PROXY_IDENTIFIER"/><link rel="manifest" href="./manifest.json"/><title>MATLAB</title><script defer="defer" src="./static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="MATLAB"/><meta name="internal_mw_identifier" content="MWI_MATLAB_PROXY_IDENTIFIER"/><link rel="manifest" href="./manifest.json"/><title>MATLAB</title><script defer="defer" src="./static/js/main.ea1ebdce.js"></script><link href="./static/css/main.47712126.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|