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.
Files changed (104) hide show
  1. matlab_proxy/app.py +578 -205
  2. matlab_proxy/app_state.py +1061 -431
  3. matlab_proxy/constants.py +37 -0
  4. matlab_proxy/default_configuration.py +39 -4
  5. matlab_proxy/devel.py +18 -22
  6. matlab_proxy/gui/index.html +20 -1
  7. matlab_proxy/gui/static/css/index.BedVwcEg.css +10 -0
  8. matlab_proxy/gui/static/js/index.pQwV1obF.js +64 -0
  9. matlab_proxy/gui/static/media/MATLAB-env-blur.NupTbPv_.png +0 -0
  10. matlab_proxy/matlab/evaluateUserMatlabCode.m +51 -0
  11. matlab_proxy/matlab/startup.m +3 -28
  12. matlab_proxy/settings.py +543 -112
  13. matlab_proxy/util/__init__.py +187 -59
  14. matlab_proxy/util/cookie_jar.py +72 -0
  15. matlab_proxy/util/event_loop.py +28 -10
  16. matlab_proxy/util/list_servers.py +71 -26
  17. matlab_proxy/util/mw.py +16 -15
  18. matlab_proxy/util/mwi/download.py +136 -0
  19. matlab_proxy/util/mwi/embedded_connector/__init__.py +1 -1
  20. matlab_proxy/util/mwi/embedded_connector/helpers.py +12 -4
  21. matlab_proxy/util/mwi/embedded_connector/request.py +78 -12
  22. matlab_proxy/util/mwi/environment_variables.py +120 -27
  23. matlab_proxy/util/mwi/exceptions.py +63 -9
  24. matlab_proxy/util/mwi/logger.py +141 -27
  25. matlab_proxy/util/mwi/session_name.py +28 -0
  26. matlab_proxy/util/mwi/token_auth.py +264 -121
  27. matlab_proxy/util/mwi/validators.py +231 -88
  28. matlab_proxy/util/system.py +9 -0
  29. matlab_proxy/util/windows.py +32 -6
  30. {matlab_proxy-0.5.3.dist-info → matlab_proxy-0.30.1.dist-info}/METADATA +94 -49
  31. matlab_proxy-0.30.1.dist-info/RECORD +88 -0
  32. {matlab_proxy-0.5.3.dist-info → matlab_proxy-0.30.1.dist-info}/WHEEL +1 -2
  33. {matlab_proxy-0.5.3.dist-info → matlab_proxy-0.30.1.dist-info}/entry_points.txt +1 -1
  34. matlab_proxy_manager/README.md +85 -0
  35. matlab_proxy_manager/__init__.py +6 -0
  36. matlab_proxy_manager/lib/README.md +53 -0
  37. matlab_proxy_manager/lib/__init__.py +1 -0
  38. matlab_proxy_manager/lib/api.py +419 -0
  39. matlab_proxy_manager/storage/README.md +54 -0
  40. matlab_proxy_manager/storage/__init__.py +1 -0
  41. matlab_proxy_manager/storage/file_repository.py +144 -0
  42. matlab_proxy_manager/storage/interface.py +62 -0
  43. matlab_proxy_manager/storage/server.py +172 -0
  44. matlab_proxy_manager/utils/__init__.py +1 -0
  45. matlab_proxy_manager/utils/auth.py +77 -0
  46. matlab_proxy_manager/utils/constants.py +8 -0
  47. matlab_proxy_manager/utils/decorators.py +37 -0
  48. matlab_proxy_manager/utils/environment_variables.py +51 -0
  49. matlab_proxy_manager/utils/exceptions.py +45 -0
  50. matlab_proxy_manager/utils/helpers.py +314 -0
  51. matlab_proxy_manager/utils/logger.py +76 -0
  52. matlab_proxy_manager/web/README.md +37 -0
  53. matlab_proxy_manager/web/__init__.py +1 -0
  54. matlab_proxy_manager/web/app.py +536 -0
  55. matlab_proxy_manager/web/monitor.py +45 -0
  56. matlab_proxy_manager/web/watcher.py +65 -0
  57. matlab_proxy/gui/asset-manifest.json +0 -23
  58. matlab_proxy/gui/authorization.html +0 -115
  59. matlab_proxy/gui/bootstrap.3.4.1.min.css +0 -6
  60. matlab_proxy/gui/navbar.css +0 -8
  61. matlab_proxy/gui/signin.css +0 -42
  62. matlab_proxy/gui/static/css/main.d890078a.chunk.css +0 -13
  63. matlab_proxy/gui/static/css/main.d890078a.chunk.css.map +0 -1
  64. matlab_proxy/gui/static/js/2.13be6544.chunk.js +0 -3
  65. matlab_proxy/gui/static/js/2.13be6544.chunk.js.LICENSE.txt +0 -59
  66. matlab_proxy/gui/static/js/2.13be6544.chunk.js.map +0 -1
  67. matlab_proxy/gui/static/js/main.c311d854.chunk.js +0 -2
  68. matlab_proxy/gui/static/js/main.c311d854.chunk.js.map +0 -1
  69. matlab_proxy/gui/static/js/runtime-main.f70e4d5f.js +0 -2
  70. matlab_proxy/gui/static/js/runtime-main.f70e4d5f.js.map +0 -1
  71. matlab_proxy/gui/static/media/arrow.0c2968b9.svg +0 -4
  72. matlab_proxy/gui/static/media/feedback.6e8d50eb.svg +0 -1
  73. matlab_proxy/gui/static/media/gripper.9defbc5e.svg +0 -1
  74. matlab_proxy/gui/static/media/help.15e5bfab.svg +0 -1
  75. matlab_proxy/gui/static/media/ico-header-contact-hover.0958c442.svg +0 -17
  76. matlab_proxy/gui/static/media/ico-header-contact.ae9169c8.svg +0 -17
  77. matlab_proxy/gui/static/media/restart.7987508a.svg +0 -1
  78. matlab_proxy/gui/static/media/sign-out.08356b67.svg +0 -1
  79. matlab_proxy/gui/static/media/start.50c4596f.svg +0 -1
  80. matlab_proxy/gui/static/media/stop.30c9a9ab.svg +0 -1
  81. matlab_proxy/gui/static/media/terminate.7ea1363e.svg +0 -1
  82. matlab_proxy/gui/token.html +0 -123
  83. matlab_proxy-0.5.3.dist-info/RECORD +0 -84
  84. matlab_proxy-0.5.3.dist-info/top_level.txt +0 -1
  85. /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.82b1212e.woff → glyphicons-halflings-regular.BKjkU69z.woff} +0 -0
  86. /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.5be1347c.eot → glyphicons-halflings-regular.BUJKDMgK.eot} +0 -0
  87. /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.060b2710.svg → glyphicons-halflings-regular.CSehLiBc.svg} +0 -0
  88. /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.4692b9ec.ttf → glyphicons-halflings-regular.DrwTMapi.ttf} +0 -0
  89. /matlab_proxy/gui/static/media/{glyphicons-halflings-regular.be810be3.woff2 → glyphicons-halflings-regular.DzqM6ju8.woff2} +0 -0
  90. /matlab_proxy/gui/static/media/{ico-header-account-hover.89438e91.svg → ico-header-account-hover.-jQHo6Wx.svg} +0 -0
  91. /matlab_proxy/gui/static/media/{ico-header-account.86b10d7b.svg → ico-header-account.CJCFoo5a.svg} +0 -0
  92. /matlab_proxy/gui/static/media/{ico-sprite.cbdb66c0.png → ico-sprite.DXGLgzq9.png} +0 -0
  93. /matlab_proxy/gui/static/media/{mathworks-eps.4d20e0ee.ttf → mathworks-eps.CGNQALa9.ttf} +0 -0
  94. /matlab_proxy/gui/static/media/{mathworks-eps.df1428df.svg → mathworks-eps.DrkCtQtG.svg} +0 -0
  95. /matlab_proxy/gui/static/media/{mathworks-eps.e5c41e84.woff → mathworks-eps.Ds7lQbql.woff} +0 -0
  96. /matlab_proxy/gui/static/media/{mathworks-pictograms.3fc6513a.woff → mathworks-pictograms.BdqxEfBR.woff} +0 -0
  97. /matlab_proxy/gui/static/media/{mathworks-pictograms.f6f087b0.svg → mathworks-pictograms.CCLweoD4.svg} +0 -0
  98. /matlab_proxy/gui/static/media/{mathworks-pictograms.6e128c0e.ttf → mathworks-pictograms.DZhFdRSm.ttf} +0 -0
  99. /matlab_proxy/gui/static/media/{mathworks.80a3218e.svg → mathworks.C-qsbhDy.svg} +0 -0
  100. /matlab_proxy/gui/static/media/{mathworks.c422935b.ttf → mathworks.Ceplx86V.ttf} +0 -0
  101. /matlab_proxy/gui/static/media/{mathworks.37a563ef.woff → mathworks.D08X1Vp8.woff} +0 -0
  102. /matlab_proxy/gui/static/media/{trigger-error.3f1c4ef2.svg → trigger-error.QEdsGL-m.svg} +0 -0
  103. /matlab_proxy/gui/static/media/{trigger-ok.7b9c238b.svg → trigger-ok.Dzg8OIrk.svg} +0 -0
  104. {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 (c) 2020-2022 The MathWorks, Inc.
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
- "doc_url": "https://github.com/mathworks/matlab-proxy/",
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
- "extension_name": matlab_proxy.get_default_config_name(),
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
- "extension_name_short_description": "MATLAB Desktop",
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 wait_for_port(port):
31
- """Waits for the given port to become available
32
-
33
- Args:
34
- port (Integer): Port number to start fake matlab server.
35
- """
36
- while True:
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
- mwi_logs_dir = settings.get(dev=True)["mwi_logs_root_dir"] / str(app["port"])
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"] = mwi_logs_dir / "connector.securePort"
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 = int(os.environ["MW_CONNECTOR_SECURE_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
@@ -1 +1,20 @@
1
- <!doctype html><html lang="en"><script>function isServerAuthenticated(){var e=document.URL,o=e.split("index.html")[0],t=new URL(e).searchParams.get("mwi_auth_token"),n=o+"authenticate_request";t&&(n+="?mwi_auth_token="+t),console.log("auth_endpoint: "+n),fetch(n).then((function(e){e.ok?console.log("This page is authorized!"):(console.log("This page is NOT authorized!"),console.log("Redirecting to :"+o),window.location.replace(o))})).catch((function(e){console.log(e)}))}</script><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"/><link rel="manifest" href="./manifest.json"/><title>MATLAB</title><link href="./static/css/main.d890078a.chunk.css" rel="stylesheet"></head><body onload="isServerAuthenticated()"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,a=r[0],p=r[1],f=r[2],c=0,s=[];c<a.length;c++)l=a[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in p)Object.prototype.hasOwnProperty.call(p,n)&&(e[n]=p[n]);for(i&&i(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,a=1;a<t.length;a++){var p=t[a];0!==o[p]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="./";var a=this["webpackJsonpmatlab-proxy"]=this["webpackJsonpmatlab-proxy"]||[],p=a.push.bind(a);a.push=r,a=a.slice();for(var f=0;f<a.length;f++)r(a[f]);var i=p;t()}([])</script><script src="./static/js/2.13be6544.chunk.js"></script><script src="./static/js/main.c311d854.chunk.js"></script></body></html>
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>