matlab-proxy 0.5.3__py3-none-any.whl → 0.30.1__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.
- matlab_proxy/app.py +578 -205
- matlab_proxy/app_state.py +1061 -431
- matlab_proxy/constants.py +37 -0
- matlab_proxy/default_configuration.py +39 -4
- matlab_proxy/devel.py +18 -22
- matlab_proxy/gui/index.html +20 -1
- matlab_proxy/gui/static/css/index.BedVwcEg.css +10 -0
- matlab_proxy/gui/static/js/index.pQwV1obF.js +64 -0
- matlab_proxy/gui/static/media/MATLAB-env-blur.NupTbPv_.png +0 -0
- matlab_proxy/matlab/evaluateUserMatlabCode.m +51 -0
- matlab_proxy/matlab/startup.m +3 -28
- matlab_proxy/settings.py +543 -112
- matlab_proxy/util/__init__.py +187 -59
- matlab_proxy/util/cookie_jar.py +72 -0
- matlab_proxy/util/event_loop.py +28 -10
- matlab_proxy/util/list_servers.py +71 -26
- matlab_proxy/util/mw.py +16 -15
- matlab_proxy/util/mwi/download.py +136 -0
- matlab_proxy/util/mwi/embedded_connector/__init__.py +1 -1
- matlab_proxy/util/mwi/embedded_connector/helpers.py +12 -4
- matlab_proxy/util/mwi/embedded_connector/request.py +78 -12
- matlab_proxy/util/mwi/environment_variables.py +120 -27
- matlab_proxy/util/mwi/exceptions.py +63 -9
- matlab_proxy/util/mwi/logger.py +141 -27
- matlab_proxy/util/mwi/session_name.py +28 -0
- matlab_proxy/util/mwi/token_auth.py +264 -121
- matlab_proxy/util/mwi/validators.py +231 -88
- matlab_proxy/util/system.py +9 -0
- matlab_proxy/util/windows.py +32 -6
- {matlab_proxy-0.5.3.dist-info → matlab_proxy-0.30.1.dist-info}/METADATA +94 -49
- matlab_proxy-0.30.1.dist-info/RECORD +88 -0
- {matlab_proxy-0.5.3.dist-info → matlab_proxy-0.30.1.dist-info}/WHEEL +1 -2
- {matlab_proxy-0.5.3.dist-info → matlab_proxy-0.30.1.dist-info}/entry_points.txt +1 -1
- matlab_proxy_manager/README.md +85 -0
- matlab_proxy_manager/__init__.py +6 -0
- matlab_proxy_manager/lib/README.md +53 -0
- matlab_proxy_manager/lib/__init__.py +1 -0
- matlab_proxy_manager/lib/api.py +419 -0
- matlab_proxy_manager/storage/README.md +54 -0
- matlab_proxy_manager/storage/__init__.py +1 -0
- matlab_proxy_manager/storage/file_repository.py +144 -0
- matlab_proxy_manager/storage/interface.py +62 -0
- matlab_proxy_manager/storage/server.py +172 -0
- matlab_proxy_manager/utils/__init__.py +1 -0
- matlab_proxy_manager/utils/auth.py +77 -0
- matlab_proxy_manager/utils/constants.py +8 -0
- matlab_proxy_manager/utils/decorators.py +37 -0
- matlab_proxy_manager/utils/environment_variables.py +51 -0
- matlab_proxy_manager/utils/exceptions.py +45 -0
- matlab_proxy_manager/utils/helpers.py +314 -0
- matlab_proxy_manager/utils/logger.py +76 -0
- matlab_proxy_manager/web/README.md +37 -0
- matlab_proxy_manager/web/__init__.py +1 -0
- matlab_proxy_manager/web/app.py +536 -0
- matlab_proxy_manager/web/monitor.py +45 -0
- matlab_proxy_manager/web/watcher.py +65 -0
- matlab_proxy/gui/asset-manifest.json +0 -23
- matlab_proxy/gui/authorization.html +0 -115
- matlab_proxy/gui/bootstrap.3.4.1.min.css +0 -6
- matlab_proxy/gui/navbar.css +0 -8
- matlab_proxy/gui/signin.css +0 -42
- matlab_proxy/gui/static/css/main.d890078a.chunk.css +0 -13
- matlab_proxy/gui/static/css/main.d890078a.chunk.css.map +0 -1
- matlab_proxy/gui/static/js/2.13be6544.chunk.js +0 -3
- matlab_proxy/gui/static/js/2.13be6544.chunk.js.LICENSE.txt +0 -59
- matlab_proxy/gui/static/js/2.13be6544.chunk.js.map +0 -1
- matlab_proxy/gui/static/js/main.c311d854.chunk.js +0 -2
- matlab_proxy/gui/static/js/main.c311d854.chunk.js.map +0 -1
- matlab_proxy/gui/static/js/runtime-main.f70e4d5f.js +0 -2
- matlab_proxy/gui/static/js/runtime-main.f70e4d5f.js.map +0 -1
- matlab_proxy/gui/static/media/arrow.0c2968b9.svg +0 -4
- matlab_proxy/gui/static/media/feedback.6e8d50eb.svg +0 -1
- matlab_proxy/gui/static/media/gripper.9defbc5e.svg +0 -1
- matlab_proxy/gui/static/media/help.15e5bfab.svg +0 -1
- matlab_proxy/gui/static/media/ico-header-contact-hover.0958c442.svg +0 -17
- matlab_proxy/gui/static/media/ico-header-contact.ae9169c8.svg +0 -17
- matlab_proxy/gui/static/media/restart.7987508a.svg +0 -1
- matlab_proxy/gui/static/media/sign-out.08356b67.svg +0 -1
- matlab_proxy/gui/static/media/start.50c4596f.svg +0 -1
- matlab_proxy/gui/static/media/stop.30c9a9ab.svg +0 -1
- matlab_proxy/gui/static/media/terminate.7ea1363e.svg +0 -1
- matlab_proxy/gui/token.html +0 -123
- matlab_proxy-0.5.3.dist-info/RECORD +0 -84
- matlab_proxy-0.5.3.dist-info/top_level.txt +0 -1
- /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.82b1212e.woff → glyphicons-halflings-regular.BKjkU69z.woff} +0 -0
- /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.5be1347c.eot → glyphicons-halflings-regular.BUJKDMgK.eot} +0 -0
- /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.060b2710.svg → glyphicons-halflings-regular.CSehLiBc.svg} +0 -0
- /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.4692b9ec.ttf → glyphicons-halflings-regular.DrwTMapi.ttf} +0 -0
- /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.be810be3.woff2 → glyphicons-halflings-regular.DzqM6ju8.woff2} +0 -0
- /matlab_proxy/gui/static/media/{ico-header-account-hover.89438e91.svg → ico-header-account-hover.-jQHo6Wx.svg} +0 -0
- /matlab_proxy/gui/static/media/{ico-header-account.86b10d7b.svg → ico-header-account.CJCFoo5a.svg} +0 -0
- /matlab_proxy/gui/static/media/{ico-sprite.cbdb66c0.png → ico-sprite.DXGLgzq9.png} +0 -0
- /matlab_proxy/gui/static/media/{mathworks-eps.4d20e0ee.ttf → mathworks-eps.CGNQALa9.ttf} +0 -0
- /matlab_proxy/gui/static/media/{mathworks-eps.df1428df.svg → mathworks-eps.DrkCtQtG.svg} +0 -0
- /matlab_proxy/gui/static/media/{mathworks-eps.e5c41e84.woff → mathworks-eps.Ds7lQbql.woff} +0 -0
- /matlab_proxy/gui/static/media/{mathworks-pictograms.3fc6513a.woff → mathworks-pictograms.BdqxEfBR.woff} +0 -0
- /matlab_proxy/gui/static/media/{mathworks-pictograms.f6f087b0.svg → mathworks-pictograms.CCLweoD4.svg} +0 -0
- /matlab_proxy/gui/static/media/{mathworks-pictograms.6e128c0e.ttf → mathworks-pictograms.DZhFdRSm.ttf} +0 -0
- /matlab_proxy/gui/static/media/{mathworks.80a3218e.svg → mathworks.C-qsbhDy.svg} +0 -0
- /matlab_proxy/gui/static/media/{mathworks.c422935b.ttf → mathworks.Ceplx86V.ttf} +0 -0
- /matlab_proxy/gui/static/media/{mathworks.37a563ef.woff → mathworks.D08X1Vp8.woff} +0 -0
- /matlab_proxy/gui/static/media/{trigger-error.3f1c4ef2.svg → trigger-error.QEdsGL-m.svg} +0 -0
- /matlab_proxy/gui/static/media/{trigger-ok.7b9c238b.svg → trigger-ok.Dzg8OIrk.svg} +0 -0
- {matlab_proxy-0.5.3.dist-info → matlab_proxy-0.30.1.dist-info/licenses}/LICENSE.md +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Copyright 2023-2025 The MathWorks, Inc.
|
|
2
|
+
from typing import Final, List
|
|
3
|
+
|
|
4
|
+
"""This module defines project-level constants"""
|
|
5
|
+
|
|
6
|
+
CONNECTOR_SECUREPORT_FILENAME: Final[str] = "connector.securePort"
|
|
7
|
+
VERSION_INFO_FILE_NAME: Final[str] = "VersionInfo.xml"
|
|
8
|
+
MAX_HTTP_REQUEST_SIZE: Final[int] = 500_000_000 # 500MB
|
|
9
|
+
MAX_WEBSOCKET_MESSAGE_SIZE_IN_MB: Final[int] = 500_000_000 # 500MB
|
|
10
|
+
MATLAB_LOGS_FILE_NAME: Final[str] = "matlab_logs.txt"
|
|
11
|
+
USER_CODE_OUTPUT_FILE_NAME: Final[str] = "startup_code_output.txt"
|
|
12
|
+
|
|
13
|
+
# Max startup duration in seconds for processes launched by matlab-proxy
|
|
14
|
+
# This constant is meant for internal use within matlab-proxy
|
|
15
|
+
# Clients of this package should use settings.py::get_process_startup_timeout() function
|
|
16
|
+
DEFAULT_PROCESS_START_TIMEOUT: Final[int] = 600
|
|
17
|
+
|
|
18
|
+
SUPPORTED_MATLAB_VERSIONS: Final[List[str]] = [
|
|
19
|
+
"R2020b",
|
|
20
|
+
"R2021a",
|
|
21
|
+
"R2021b",
|
|
22
|
+
"R2022a",
|
|
23
|
+
"R2022b",
|
|
24
|
+
"R2023a",
|
|
25
|
+
"R2023b",
|
|
26
|
+
"R2024a",
|
|
27
|
+
"R2024b",
|
|
28
|
+
"R2025a",
|
|
29
|
+
"R2025b",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
# This constant when set to True restricts the number of active sessions to one
|
|
33
|
+
IS_CONCURRENCY_CHECK_ENABLED: Final[bool] = True
|
|
34
|
+
MWI_AUTH_TOKEN_NAME_FOR_HTTP = "mwi-auth-token"
|
|
35
|
+
|
|
36
|
+
# Interval in seconds to wait before querying the status of MATLAB.
|
|
37
|
+
CHECK_MATLAB_STATUS_INTERVAL_SECONDS: Final[int] = 1
|
|
@@ -1,18 +1,53 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2020-2025 The MathWorks, Inc.
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
2
5
|
import matlab_proxy
|
|
3
6
|
|
|
7
|
+
|
|
8
|
+
class ConfigKeys(Enum):
|
|
9
|
+
"""Enumeration for configuration keys used in the MATLAB proxy setup."""
|
|
10
|
+
|
|
11
|
+
DOC_URL = "doc_url"
|
|
12
|
+
EXT_NAME = "extension_name"
|
|
13
|
+
EXT_NAME_DESC = "extension_name_short_description"
|
|
14
|
+
SHOW_SHUTDOWN_BUTTON = "should_show_shutdown_button"
|
|
15
|
+
|
|
16
|
+
|
|
4
17
|
# Configure matlab_proxy
|
|
5
18
|
config = {
|
|
6
19
|
# Link the documentation url here. This will show up on the website UI
|
|
7
20
|
# where users can create issue's or make enhancement requests
|
|
8
|
-
|
|
21
|
+
ConfigKeys.DOC_URL.value: "https://github.com/mathworks/matlab-proxy/",
|
|
9
22
|
# Use a single word for extension_name
|
|
10
23
|
# It will be used as a flag when launching the integration.
|
|
11
24
|
# NOTE: This name must be used when setting the entrypoint for matlab_proxy in setup.py
|
|
12
25
|
# Use '-' or '_' seperated values if more than 1 word is used.
|
|
13
26
|
# Ex: Hello-World, Alice_Bob.
|
|
14
|
-
|
|
27
|
+
ConfigKeys.EXT_NAME.value: matlab_proxy.get_default_config_name(),
|
|
15
28
|
# This value will be used in various places on the website UI.
|
|
16
29
|
# Ensure that this is not more than 3 words.
|
|
17
|
-
|
|
30
|
+
ConfigKeys.EXT_NAME_DESC.value: "MATLAB Desktop",
|
|
31
|
+
# Show the shutdown button in the UI for matlab-proxy
|
|
32
|
+
ConfigKeys.SHOW_SHUTDOWN_BUTTON.value: True,
|
|
18
33
|
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def get_required_config() -> List[str]:
|
|
37
|
+
"""Get the list of required configuration keys.
|
|
38
|
+
|
|
39
|
+
This function returns a list of keys that are required for
|
|
40
|
+
the MATLAB proxy configuration. These keys are used to
|
|
41
|
+
ensure that the configuration dictionary contains all the
|
|
42
|
+
necessary entries.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
list: A list of strings representing the required
|
|
46
|
+
configuration keys.
|
|
47
|
+
"""
|
|
48
|
+
required_keys: List[ConfigKeys] = [
|
|
49
|
+
ConfigKeys.DOC_URL,
|
|
50
|
+
ConfigKeys.EXT_NAME,
|
|
51
|
+
ConfigKeys.EXT_NAME_DESC,
|
|
52
|
+
]
|
|
53
|
+
return [key.value for key in required_keys]
|
matlab_proxy/devel.py
CHANGED
|
@@ -11,6 +11,8 @@ from aiohttp import web
|
|
|
11
11
|
|
|
12
12
|
from matlab_proxy import settings
|
|
13
13
|
from matlab_proxy.util.mwi import environment_variables as mwi_env
|
|
14
|
+
from matlab_proxy.constants import CONNECTOR_SECUREPORT_FILENAME
|
|
15
|
+
from matlab_proxy.util.event_loop import *
|
|
14
16
|
|
|
15
17
|
desktop_html = b"""
|
|
16
18
|
<h1>Fake MATLAB Web Desktop</h1>
|
|
@@ -27,23 +29,13 @@ desktop_html = b"""
|
|
|
27
29
|
"""
|
|
28
30
|
|
|
29
31
|
|
|
30
|
-
def
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
print(f"Waiting for port {port} to be available")
|
|
38
|
-
try:
|
|
39
|
-
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
40
|
-
s.bind(("", port))
|
|
41
|
-
except OSError:
|
|
42
|
-
time.sleep(5)
|
|
43
|
-
continue
|
|
44
|
-
# Once successful, close the port and stop waiting
|
|
45
|
-
s.close()
|
|
46
|
-
break
|
|
32
|
+
def assign_free_port():
|
|
33
|
+
"""Finds an available free port"""
|
|
34
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
35
|
+
s.bind(("", 0))
|
|
36
|
+
port = s.getsockname()[1]
|
|
37
|
+
s.close()
|
|
38
|
+
return port
|
|
47
39
|
|
|
48
40
|
|
|
49
41
|
async def web_handler(request):
|
|
@@ -176,10 +168,11 @@ async def fake_matlab_started(app):
|
|
|
176
168
|
|
|
177
169
|
# Real MATLAB always uses $MATLAB_LOG_DIR/connection.securePort as the ready file
|
|
178
170
|
# We mock reading from the environment variable by calling the helper functions
|
|
179
|
-
|
|
180
|
-
mwi_logs_dir.mkdir(parents=True, exist_ok=True)
|
|
171
|
+
matlab_logs_dir = os.getenv(mwi_env.get_env_name_matlab_log_dir())
|
|
181
172
|
|
|
182
|
-
app["matlab_ready_file"] =
|
|
173
|
+
app["matlab_ready_file"] = Path(
|
|
174
|
+
f"{matlab_logs_dir}/{CONNECTOR_SECUREPORT_FILENAME}"
|
|
175
|
+
)
|
|
183
176
|
|
|
184
177
|
ready_delay = app["ready_delay"]
|
|
185
178
|
try:
|
|
@@ -188,6 +181,10 @@ async def fake_matlab_started(app):
|
|
|
188
181
|
f"Creating fake MATLAB Embedded Connector ready file at {app['matlab_ready_file']}"
|
|
189
182
|
)
|
|
190
183
|
app["matlab_ready_file"].touch()
|
|
184
|
+
|
|
185
|
+
# Populate ready file with the embedded connector port information
|
|
186
|
+
with open(app["matlab_ready_file"], "w") as f:
|
|
187
|
+
f.write(str(app["port"]))
|
|
191
188
|
except asyncio.CancelledError:
|
|
192
189
|
pass
|
|
193
190
|
|
|
@@ -223,8 +220,7 @@ def matlab(args):
|
|
|
223
220
|
Args:
|
|
224
221
|
args (Dict): Contains data on how to start web server.
|
|
225
222
|
"""
|
|
226
|
-
port =
|
|
227
|
-
wait_for_port(port)
|
|
223
|
+
port = assign_free_port()
|
|
228
224
|
print(f"Serving fake MATLAB Embedded Connector at port {port}")
|
|
229
225
|
app = web.Application()
|
|
230
226
|
app["ready_delay"] = args.ready_delay
|
matlab_proxy/gui/index.html
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- Copyright 2025 The MathWorks, Inc. -->
|
|
2
|
+
|
|
3
|
+
<!doctype html>
|
|
4
|
+
<html lang="en">
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="UTF-8" />
|
|
7
|
+
<link rel="icon" href="./favicon.ico" />
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
+
<meta name="theme-color" content="#000000" />
|
|
10
|
+
<meta name="description" content="MATLAB" />
|
|
11
|
+
<meta name="internal_mw_identifier" content="MWI_MATLAB_PROXY_IDENTIFIER" />
|
|
12
|
+
<link rel="manifest" href="./manifest.json" />
|
|
13
|
+
<title>MATLAB</title>
|
|
14
|
+
<script type="module" crossorigin src="./static/js/index.pQwV1obF.js"></script>
|
|
15
|
+
<link rel="stylesheet" crossorigin href="./static/css/index.BedVwcEg.css">
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<div id="root"></div>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|