matlab-proxy 0.16.0__py3-none-any.whl → 0.18.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 +40 -24
- matlab_proxy/app_state.py +108 -4
- matlab_proxy/constants.py +1 -0
- matlab_proxy/gui/asset-manifest.json +3 -3
- matlab_proxy/gui/index.html +1 -1
- matlab_proxy/gui/static/js/{main.522d83ba.js → main.5b5ca2f2.js} +3 -3
- matlab_proxy/gui/static/js/main.5b5ca2f2.js.map +1 -0
- matlab_proxy/matlab/evaluateUserMatlabCode.m +51 -0
- matlab_proxy/matlab/startup.m +2 -2
- matlab_proxy/settings.py +18 -2
- matlab_proxy/util/__init__.py +16 -7
- matlab_proxy/util/mwi/environment_variables.py +5 -0
- matlab_proxy/util/mwi/validators.py +13 -11
- matlab_proxy/util/windows.py +6 -2
- {matlab_proxy-0.16.0.dist-info → matlab_proxy-0.18.0.dist-info}/METADATA +4 -2
- {matlab_proxy-0.16.0.dist-info → matlab_proxy-0.18.0.dist-info}/RECORD +25 -24
- tests/unit/test_app.py +14 -0
- tests/unit/test_app_state.py +112 -0
- tests/unit/test_settings.py +35 -0
- tests/unit/util/test_util.py +4 -1
- matlab_proxy/gui/static/js/main.522d83ba.js.map +0 -1
- /matlab_proxy/gui/static/js/{main.522d83ba.js.LICENSE.txt → main.5b5ca2f2.js.LICENSE.txt} +0 -0
- {matlab_proxy-0.16.0.dist-info → matlab_proxy-0.18.0.dist-info}/LICENSE.md +0 -0
- {matlab_proxy-0.16.0.dist-info → matlab_proxy-0.18.0.dist-info}/WHEEL +0 -0
- {matlab_proxy-0.16.0.dist-info → matlab_proxy-0.18.0.dist-info}/entry_points.txt +0 -0
- {matlab_proxy-0.16.0.dist-info → matlab_proxy-0.18.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
% Copyright 2024 The MathWorks, Inc.
|
|
2
|
+
|
|
3
|
+
% Note:
|
|
4
|
+
% Any extra variable we are creating begins with `mwiInternal` to prevent
|
|
5
|
+
% potential conflicts with variables created by user code evaluated using evalc.
|
|
6
|
+
% Since evalc("user code") is executed in the base workspace, it might create
|
|
7
|
+
% variables that could overwrite our internal variables. To avoid polluting the
|
|
8
|
+
% user's workspace when MATLAB starts, we ensure to clear any internal variable
|
|
9
|
+
% that we create in the base workspace. We do not need to be concerned about
|
|
10
|
+
% variables in the function's workspace.
|
|
11
|
+
|
|
12
|
+
if ~isempty(getenv('MWI_MATLAB_STARTUP_SCRIPT')) && ~all(isspace(getenv('MWI_MATLAB_STARTUP_SCRIPT')))
|
|
13
|
+
try
|
|
14
|
+
% Evaluate the code from the environment variable and capture the output
|
|
15
|
+
mwiInternalResults = evalc(getenv('MWI_MATLAB_STARTUP_SCRIPT'));
|
|
16
|
+
% Write the results to the file
|
|
17
|
+
logOutputOrError(mwiInternalResults);
|
|
18
|
+
clear mwiInternalResults;
|
|
19
|
+
catch mwiInternalException
|
|
20
|
+
% Log the error message to the file
|
|
21
|
+
logOutputOrError(" ", mwiInternalException);
|
|
22
|
+
clear mwiInternalResults mwiInternalException;
|
|
23
|
+
error("Unable to run the startup code you specified. For details of the error, see the output file at " + fullfile(getenv('MATLAB_LOG_DIR'), "startup_code_output.txt"));
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
function logOutputOrError(userCodeResults, mwiInternalException)
|
|
29
|
+
% Logs the results of the user code execution if successful, otherwise logs the
|
|
30
|
+
% error information. It then closes the file handle.
|
|
31
|
+
%
|
|
32
|
+
% Inputs:
|
|
33
|
+
% userCodeResults - String containing the output from the user code.
|
|
34
|
+
% mwiInternalException - (Optional) MException object containing error details.
|
|
35
|
+
filePath = fullfile(getenv('MATLAB_LOG_DIR'), "startup_code_output.txt");
|
|
36
|
+
[fileHandle, ~] = fopen(filePath, 'w');
|
|
37
|
+
if nargin < 2
|
|
38
|
+
% Log the successful output of the user code
|
|
39
|
+
fprintf(fileHandle, " ");
|
|
40
|
+
fprintf(fileHandle, userCodeResults);
|
|
41
|
+
else
|
|
42
|
+
% Log the error information
|
|
43
|
+
fprintf(fileHandle, 'An error occurred in the following code:\n');
|
|
44
|
+
fprintf(fileHandle, getenv('MWI_MATLAB_STARTUP_SCRIPT'));
|
|
45
|
+
fprintf(fileHandle, '\n\nMessage: %s\n', mwiInternalException.message);
|
|
46
|
+
fprintf(fileHandle, '\nError Identifier: %s\n', mwiInternalException.identifier);
|
|
47
|
+
end
|
|
48
|
+
% Close the file handle
|
|
49
|
+
fclose(fileHandle);
|
|
50
|
+
end
|
|
51
|
+
|
matlab_proxy/matlab/startup.m
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
% Copyright
|
|
1
|
+
% Copyright 2020-2024 The MathWorks, Inc.
|
|
2
2
|
|
|
3
3
|
% Configure logged in user if possible
|
|
4
4
|
if ~isempty(getenv('MW_LOGIN_USER_ID'))
|
|
@@ -34,4 +34,4 @@ end
|
|
|
34
34
|
matlab_settings.matlab.addons.explorer.isExplorerSupported.TemporaryValue = false;
|
|
35
35
|
|
|
36
36
|
clear
|
|
37
|
-
clc
|
|
37
|
+
clc
|
matlab_proxy/settings.py
CHANGED
|
@@ -366,7 +366,10 @@ def get_matlab_settings():
|
|
|
366
366
|
flag_to_hide_desktop = ["-nodesktop"]
|
|
367
367
|
if system.is_windows():
|
|
368
368
|
flag_to_hide_desktop.extend(["-noDisplayDesktop", "-wait", "-log"])
|
|
369
|
-
|
|
369
|
+
|
|
370
|
+
matlab_code_dir = Path(__file__).resolve().parent / "matlab"
|
|
371
|
+
matlab_startup_file = str(matlab_code_dir / "startup.m")
|
|
372
|
+
matlab_code_file = str(matlab_code_dir / "evaluateUserMatlabCode.m")
|
|
370
373
|
|
|
371
374
|
matlab_version = get_matlab_version(matlab_root_path)
|
|
372
375
|
|
|
@@ -388,6 +391,18 @@ def get_matlab_settings():
|
|
|
388
391
|
profile_matlab_startup = (
|
|
389
392
|
"-timing" if mwi_env.Experimental.is_matlab_startup_profiling_enabled() else ""
|
|
390
393
|
)
|
|
394
|
+
|
|
395
|
+
has_custom_code_to_execute = (
|
|
396
|
+
len(os.getenv(mwi_env.get_env_name_custom_matlab_code(), "").strip()) > 0
|
|
397
|
+
)
|
|
398
|
+
mp_code_to_execute = f"try; run('{matlab_startup_file}'); catch MATLABProxyInitializationError; disp(MATLABProxyInitializationError.message); end;"
|
|
399
|
+
custom_code_to_execute = f"try; run('{matlab_code_file}'); catch MATLABCustomStartupCodeError; disp(MATLABCustomStartupCodeError.message); end;"
|
|
400
|
+
code_to_execute = (
|
|
401
|
+
mp_code_to_execute + custom_code_to_execute
|
|
402
|
+
if has_custom_code_to_execute
|
|
403
|
+
else mp_code_to_execute
|
|
404
|
+
)
|
|
405
|
+
|
|
391
406
|
return {
|
|
392
407
|
"matlab_path": matlab_root_path,
|
|
393
408
|
"matlab_version": matlab_version,
|
|
@@ -402,13 +417,14 @@ def get_matlab_settings():
|
|
|
402
417
|
*mpa_flags,
|
|
403
418
|
profile_matlab_startup,
|
|
404
419
|
"-r",
|
|
405
|
-
|
|
420
|
+
code_to_execute,
|
|
406
421
|
],
|
|
407
422
|
"ws_env": ws_env,
|
|
408
423
|
"mwa_api_endpoint": f"https://login{ws_env_suffix}.mathworks.com/authenticationws/service/v4",
|
|
409
424
|
"mhlm_api_endpoint": f"https://licensing{ws_env_suffix}.mathworks.com/mls/service/v1/entitlement/list",
|
|
410
425
|
"mwa_login": f"https://login{ws_env_suffix}.mathworks.com",
|
|
411
426
|
"nlm_conn_str": nlm_conn_str,
|
|
427
|
+
"has_custom_code_to_execute": has_custom_code_to_execute,
|
|
412
428
|
}
|
|
413
429
|
|
|
414
430
|
|
matlab_proxy/util/__init__.py
CHANGED
|
@@ -11,6 +11,9 @@ import matlab_proxy
|
|
|
11
11
|
from matlab_proxy.util import mwi, system
|
|
12
12
|
from matlab_proxy.util.event_loop import *
|
|
13
13
|
from matlab_proxy.util.mwi import environment_variables as mwi_env
|
|
14
|
+
from matlab_proxy.util.mwi.exceptions import (
|
|
15
|
+
UIVisibleFatalError,
|
|
16
|
+
)
|
|
14
17
|
|
|
15
18
|
logger = mwi.logger.get()
|
|
16
19
|
|
|
@@ -181,7 +184,7 @@ def prettify(boundary_filler=" ", text_arr=[]):
|
|
|
181
184
|
return result
|
|
182
185
|
|
|
183
186
|
|
|
184
|
-
def get_child_processes(parent_process):
|
|
187
|
+
def get_child_processes(parent_process, max_attempts=10, sleep_interval=1):
|
|
185
188
|
"""Get list of child processes from a parent process.
|
|
186
189
|
|
|
187
190
|
Args:
|
|
@@ -199,7 +202,6 @@ def get_child_processes(parent_process):
|
|
|
199
202
|
# to get hold child processes
|
|
200
203
|
parent_process_psutil = psutil.Process(parent_process.pid)
|
|
201
204
|
|
|
202
|
-
max_attempts = 10
|
|
203
205
|
child_processes = None
|
|
204
206
|
for _ in range(max_attempts):
|
|
205
207
|
try:
|
|
@@ -212,17 +214,24 @@ def get_child_processes(parent_process):
|
|
|
212
214
|
|
|
213
215
|
if not child_processes:
|
|
214
216
|
logger.debug("Waiting for the child processes to be created...")
|
|
217
|
+
time.sleep(sleep_interval)
|
|
215
218
|
continue
|
|
216
219
|
|
|
220
|
+
else:
|
|
221
|
+
logger.debug(f"Found the child process: {child_processes[0]}")
|
|
222
|
+
break
|
|
223
|
+
|
|
217
224
|
except AssertionError as err:
|
|
218
225
|
raise err
|
|
219
226
|
|
|
220
|
-
if child_processes:
|
|
221
|
-
break
|
|
222
|
-
time.sleep(0.1)
|
|
223
|
-
|
|
224
227
|
if not child_processes:
|
|
225
|
-
|
|
228
|
+
logger.debug(
|
|
229
|
+
f"MATLAB process was not found while searching for the child processes."
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
raise UIVisibleFatalError(
|
|
233
|
+
"Unable to create MATLAB process. Click Start MATLAB to try again."
|
|
234
|
+
)
|
|
226
235
|
|
|
227
236
|
return child_processes
|
|
228
237
|
|
|
@@ -162,6 +162,11 @@ def get_env_name_process_startup_timeout():
|
|
|
162
162
|
return "MWI_PROCESS_START_TIMEOUT"
|
|
163
163
|
|
|
164
164
|
|
|
165
|
+
def get_env_name_custom_matlab_code():
|
|
166
|
+
"""User specified MATLAB code that will be executed by matlab-proxy upon its start"""
|
|
167
|
+
return "MWI_MATLAB_STARTUP_SCRIPT"
|
|
168
|
+
|
|
169
|
+
|
|
165
170
|
class Experimental:
|
|
166
171
|
"""This class houses functions which are undocumented APIs and Environment variables.
|
|
167
172
|
Note: Never add any state to this class. Its only intended for use as an abstraction layer
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
# Copyright 2020-2024 The MathWorks, Inc.
|
|
2
2
|
"""This file contains validators for various runtime artifacts.
|
|
3
|
-
A validator is defined as a function which verifies the input and
|
|
4
|
-
returns it unchanged if validation passes.
|
|
3
|
+
A validator is defined as a function which verifies the input and
|
|
4
|
+
returns it unchanged if validation passes.
|
|
5
5
|
Returning inputs allows validators to be used inline with the input.
|
|
6
6
|
|
|
7
|
-
Example:
|
|
7
|
+
Example:
|
|
8
8
|
Original code: if( input ):
|
|
9
9
|
With validator: if (valid(input)):
|
|
10
10
|
|
|
11
11
|
Exceptions are thrown to signal failure.
|
|
12
12
|
"""
|
|
13
|
+
|
|
13
14
|
import errno
|
|
14
15
|
import os
|
|
15
|
-
from pathlib import Path
|
|
16
|
-
import pkg_resources
|
|
17
16
|
import socket
|
|
17
|
+
from pathlib import Path
|
|
18
18
|
from typing import List
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
import matlab_proxy
|
|
22
21
|
from matlab_proxy import util
|
|
23
|
-
from matlab_proxy.util import system
|
|
24
22
|
from matlab_proxy.constants import VERSION_INFO_FILE_NAME
|
|
23
|
+
from matlab_proxy.util import system
|
|
25
24
|
|
|
26
25
|
from . import environment_variables as mwi_env
|
|
27
26
|
from . import logger as mwi_logger
|
|
28
|
-
from .exceptions import
|
|
27
|
+
from .exceptions import FatalError, MatlabInstallError
|
|
29
28
|
|
|
30
29
|
logger = mwi_logger.get()
|
|
31
30
|
|
|
@@ -213,10 +212,13 @@ def __get_configs():
|
|
|
213
212
|
Dict: Contains all the values present in 'matlab_web_desktop_configs' entry_point from all the packages
|
|
214
213
|
installed in the current environment.
|
|
215
214
|
"""
|
|
215
|
+
import importlib_metadata
|
|
216
|
+
|
|
217
|
+
matlab_proxy_eps = importlib_metadata.entry_points(
|
|
218
|
+
group=matlab_proxy.get_entrypoint_name()
|
|
219
|
+
)
|
|
216
220
|
configs = {}
|
|
217
|
-
for entry_point in
|
|
218
|
-
matlab_proxy.get_entrypoint_name()
|
|
219
|
-
):
|
|
221
|
+
for entry_point in matlab_proxy_eps:
|
|
220
222
|
configs[entry_point.name.lower()] = entry_point.load()
|
|
221
223
|
|
|
222
224
|
return configs
|
matlab_proxy/util/windows.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
# Copyright 2022-
|
|
1
|
+
# Copyright 2022-2024 The MathWorks, Inc.
|
|
2
2
|
import asyncio
|
|
3
3
|
|
|
4
4
|
from matlab_proxy import util
|
|
5
5
|
from matlab_proxy.util import mwi
|
|
6
6
|
from matlab_proxy.util.mwi import environment_variables as mwi_env
|
|
7
|
+
from matlab_proxy.util.mwi.exceptions import (
|
|
8
|
+
UIVisibleFatalError,
|
|
9
|
+
)
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
""" This file contains methods specific to non-posix / windows OS.
|
|
@@ -77,8 +80,9 @@ async def start_matlab(matlab_cmd, matlab_env):
|
|
|
77
80
|
"MATLAB.exe" == matlab.name()
|
|
78
81
|
), "Expecting the child process name to be MATLAB.exe"
|
|
79
82
|
|
|
80
|
-
except AssertionError as err:
|
|
83
|
+
except (AssertionError, UIVisibleFatalError) as err:
|
|
81
84
|
raise err
|
|
85
|
+
|
|
82
86
|
except psutil.NoSuchProcess:
|
|
83
87
|
# We reach here when the intermediate process launched by matlab-proxy died
|
|
84
88
|
# before we can query for its child processes. Hence, to find the actual MATLAB
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: matlab-proxy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.18.0
|
|
4
4
|
Summary: Python® package enables you to launch MATLAB® and access it from a web browser.
|
|
5
5
|
Home-page: https://github.com/mathworks/matlab-proxy/
|
|
6
6
|
Author: The MathWorks, Inc.
|
|
@@ -18,8 +18,10 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
18
18
|
Requires-Python: ~=3.8
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
Requires-Dist: aiohttp >=3.7.4
|
|
21
|
-
Requires-Dist: psutil
|
|
22
21
|
Requires-Dist: aiohttp-session[secure]
|
|
22
|
+
Requires-Dist: importlib-metadata
|
|
23
|
+
Requires-Dist: importlib-resources
|
|
24
|
+
Requires-Dist: psutil
|
|
23
25
|
Provides-Extra: dev
|
|
24
26
|
Requires-Dist: aiohttp-devtools ; extra == 'dev'
|
|
25
27
|
Requires-Dist: black ; extra == 'dev'
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
matlab_proxy/__init__.py,sha256=6cwi8buKCMtw9OeWaOYUHEoqwl5MyJ_s6GxgNuqPuNg,1673
|
|
2
|
-
matlab_proxy/app.py,sha256
|
|
3
|
-
matlab_proxy/app_state.py,sha256=
|
|
4
|
-
matlab_proxy/constants.py,sha256=
|
|
2
|
+
matlab_proxy/app.py,sha256=fcZGlpW8Ox1ahHIhDBnL_iBkF-tFejTRr61L8WgGFgM,34429
|
|
3
|
+
matlab_proxy/app_state.py,sha256=i5AVaNroFSld4Y36BNil5lwS0PNrHnceYq7swXY5AI4,60502
|
|
4
|
+
matlab_proxy/constants.py,sha256=CrbIA098b5LMsqxY7nbap0_tqA2tIrIckGAffTgIkrA,1039
|
|
5
5
|
matlab_proxy/default_configuration.py,sha256=DxQaHzAivzstiPl_nDfxs8SOyP9oaK9v3RP4LtroJl4,843
|
|
6
6
|
matlab_proxy/devel.py,sha256=nR6XPVBUEdQ-RZGtYvX1YHTp8gj9cuw5Hp8ahasMBc8,14310
|
|
7
|
-
matlab_proxy/settings.py,sha256=
|
|
7
|
+
matlab_proxy/settings.py,sha256=I4nvFZzACKx-JBlAFCFWHA60gg66bR4hrXj1f5awfbA,25616
|
|
8
8
|
matlab_proxy/gui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
matlab_proxy/gui/asset-manifest.json,sha256=
|
|
9
|
+
matlab_proxy/gui/asset-manifest.json,sha256=XqmLvi3DDOGSbBxNZwjuaNJXoYjZiG2HasxvZnEzPEo,3516
|
|
10
10
|
matlab_proxy/gui/favicon.ico,sha256=7w7Ki1uQP2Rgwc64dOV4-NrTu97I3WsZw8OvRSoY1A0,130876
|
|
11
|
-
matlab_proxy/gui/index.html,sha256=
|
|
11
|
+
matlab_proxy/gui/index.html,sha256=lWKKMXjAyOc-vk6t4rasj49sa2UgXAAlMdWYCd5V8N8,637
|
|
12
12
|
matlab_proxy/gui/manifest.json,sha256=NwDbrALM5auYyj2bbEf4aGwAUDqNl1FzMFQpPiG2Ty4,286
|
|
13
13
|
matlab_proxy/gui/robots.txt,sha256=kNJLw79pisHhc3OVAimMzKcq3x9WT6sF9IS4xI0crdI,67
|
|
14
14
|
matlab_proxy/gui/static/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -16,9 +16,9 @@ matlab_proxy/gui/static/css/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
16
16
|
matlab_proxy/gui/static/css/main.47712126.css,sha256=OT5ccyC0a6fVg956C-8b6uDVbZZVgcpXbHjdO6v4ZBI,274313
|
|
17
17
|
matlab_proxy/gui/static/css/main.47712126.css.map,sha256=RdfmXfQvzvvh4XZuDWShm8CD8pA2Gb2K6MtMzrgJyKM,350495
|
|
18
18
|
matlab_proxy/gui/static/js/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
matlab_proxy/gui/static/js/main.
|
|
20
|
-
matlab_proxy/gui/static/js/main.
|
|
21
|
-
matlab_proxy/gui/static/js/main.
|
|
19
|
+
matlab_proxy/gui/static/js/main.5b5ca2f2.js,sha256=XvoCZpW63pLcHvS9meZxIId_yQPC3w5SuGIij5VwOEc,294436
|
|
20
|
+
matlab_proxy/gui/static/js/main.5b5ca2f2.js.LICENSE.txt,sha256=3cj3DrwM51esz1ogL9VVU1ZyXyXJ6u-Ec2CI9CCcI_A,1689
|
|
21
|
+
matlab_proxy/gui/static/js/main.5b5ca2f2.js.map,sha256=mCDweY7BuQ4Ld5c6Z521rjPGrIlIzG2b_DjxsW_eo6M,938339
|
|
22
22
|
matlab_proxy/gui/static/media/MATLAB-env-blur.4fc94edbc82d3184e5cb.png,sha256=QpmQTLDvBu2-b7ev83Rvpt0Q72R6wdQGkuJMPPpjv7M,220290
|
|
23
23
|
matlab_proxy/gui/static/media/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
24
|
matlab_proxy/gui/static/media/arrow.0c2968b90bd9a64c8c3f.svg,sha256=XtmvDWzGZnwCZm08TKBnqt5hc1wphJnNupG0Fx_faAY,327
|
|
@@ -52,21 +52,22 @@ matlab_proxy/gui/static/media/terminate.7ea1363ee0fa72344ef6.svg,sha256=LDLYNWk_
|
|
|
52
52
|
matlab_proxy/gui/static/media/trigger-error.3f1c4ef23ab8f3e60b0e.svg,sha256=3zzT0uTrl4M_HlAjjVy_9F6fJDY9TifdQCFYX36LCOY,5017
|
|
53
53
|
matlab_proxy/gui/static/media/trigger-ok.7b9c238be42f685c4fa7.svg,sha256=mD-7N9cc4ARdMBFcplnogJv6nA4Yh3jQuYbZDUi18LU,4997
|
|
54
54
|
matlab_proxy/icons/matlab.svg,sha256=xh5uYebQd8I-ISvenjU9A-PkClzW_lU9wvm3doXOFKM,13366
|
|
55
|
-
matlab_proxy/matlab/
|
|
56
|
-
matlab_proxy/
|
|
55
|
+
matlab_proxy/matlab/evaluateUserMatlabCode.m,sha256=R8w6nPdGtadR4UUFJaspcrGQL7cJwUItdrfc531w3bM,2420
|
|
56
|
+
matlab_proxy/matlab/startup.m,sha256=1hIvfWgBDcvM3wW__X2yaQ6cBwKjdh5eO0zycbJB78k,1555
|
|
57
|
+
matlab_proxy/util/__init__.py,sha256=rhBsXJT-5v67FuJ9Rz23yDT7afYfwrS5y_oMQSTbCwg,8456
|
|
57
58
|
matlab_proxy/util/event_loop.py,sha256=Zqd282jlvPHHyc4kg8IjIzlzh9zLM_SAc5xjqUOrm04,1144
|
|
58
59
|
matlab_proxy/util/list_servers.py,sha256=M93coVZjyQCdIvCCxsNOU_XDWNjBSysOJ5tWXaTjP8Y,1369
|
|
59
60
|
matlab_proxy/util/mw.py,sha256=dLGSdfcTZiwKR1MMZA-39o-8na13IEPZOGBqcaHmKVI,11086
|
|
60
61
|
matlab_proxy/util/system.py,sha256=XoT3Rv5MwPkdfhk2oMvUwxxlzZmADMlxzi9IRQyGgbA,1692
|
|
61
|
-
matlab_proxy/util/windows.py,sha256=
|
|
62
|
+
matlab_proxy/util/windows.py,sha256=J5O-wihOxEex43_AzwvFylNlN4hcZdO6KD5cpLv1FX8,3538
|
|
62
63
|
matlab_proxy/util/mwi/__init__.py,sha256=zI-X1lafr8H3j17PyA0oSZ0q5nINfK-WDA7VmJKmSAQ,158
|
|
63
64
|
matlab_proxy/util/mwi/custom_http_headers.py,sha256=kfDjSnEXEVzoF2pZuEn76LKayeD2WKoQEDu2Y9EMOAo,7154
|
|
64
65
|
matlab_proxy/util/mwi/download.py,sha256=-GJj3yOsL4vF_9baqRXkgBI-vu_OwjZMQVkJXFS8GMc,4965
|
|
65
|
-
matlab_proxy/util/mwi/environment_variables.py,sha256=
|
|
66
|
+
matlab_proxy/util/mwi/environment_variables.py,sha256=SC5pMCs2EVWd9NrvA8yYbCOm998SXDhQCIG1h8Ilysc,7309
|
|
66
67
|
matlab_proxy/util/mwi/exceptions.py,sha256=93HrHbOq24KI4Md2el23XN01wIqVShEK29Pbt2V0Jr8,4628
|
|
67
68
|
matlab_proxy/util/mwi/logger.py,sha256=e7wTPclrtJ-aX5mPk_pUJMX7-1QD_snGBW1P2ks-ETE,3311
|
|
68
69
|
matlab_proxy/util/mwi/token_auth.py,sha256=UbIWqo7qADaZdijFvorLYsZbxzaB8TycGP8nk305ru0,9997
|
|
69
|
-
matlab_proxy/util/mwi/validators.py,sha256=
|
|
70
|
+
matlab_proxy/util/mwi/validators.py,sha256=QEaP0N6U8BF4MglxrkM1phK0lWNiWBK7JdJbcfFRACY,11765
|
|
70
71
|
matlab_proxy/util/mwi/embedded_connector/__init__.py,sha256=SVSckEJ4zQQ2KkNPT_un8ndMAImcMOTrai7ShAbmFY4,114
|
|
71
72
|
matlab_proxy/util/mwi/embedded_connector/helpers.py,sha256=p6TedefbvhlZT64IMwFjrb0panWCXf-T3XPoztDbxM0,3391
|
|
72
73
|
matlab_proxy/util/mwi/embedded_connector/request.py,sha256=-6DL9K8JWjX5u5XVOEGaqBUIwQ-oCVW30-VP3qk_rzw,3730
|
|
@@ -82,16 +83,16 @@ tests/integration/utils/integration_tests_utils.py,sha256=IbJ9CedFHiz3k85FBY-8Gw
|
|
|
82
83
|
tests/integration/utils/licensing.py,sha256=rEBjvMXO8R3mL6KnePu2lojmOsjD4GXl9frf9N0Wacs,4842
|
|
83
84
|
tests/unit/__init__.py,sha256=KfwQxxM5a1kMRtNbhz8tb7YfHp8e2d0tNLB55wYvDS8,37
|
|
84
85
|
tests/unit/conftest.py,sha256=Hfxq3h8IZuLJkRMh5jdEFiq78CIAdKvm-6KryRDZ0FY,1918
|
|
85
|
-
tests/unit/test_app.py,sha256=
|
|
86
|
-
tests/unit/test_app_state.py,sha256=
|
|
86
|
+
tests/unit/test_app.py,sha256=xiiEQu1iNK0h3Yuwn3c-hgvNhC1EXKFgTbE_7U3mSrs,37731
|
|
87
|
+
tests/unit/test_app_state.py,sha256=qD2I7qfUwME_M8lCMsg62Kmky5xdCBav3r3em39Zkt0,22906
|
|
87
88
|
tests/unit/test_constants.py,sha256=ieDKc7bL8zWsd_D4dv2n8iftXr2h-bkS5p6zVan0BtQ,125
|
|
88
89
|
tests/unit/test_ddux.py,sha256=a2J2iM8j_nnfJVuMI38p5AjwrRdoMj3N88gFgS2I4hg,713
|
|
89
90
|
tests/unit/test_devel.py,sha256=A-1iVhSSwmywaW65QIRcUS2Fk7nJxceCcCm7CJtNdEc,7982
|
|
90
91
|
tests/unit/test_non_dev_mode.py,sha256=0v27y27SLOWvw6jf_GhLLNg-RMsZS_OyGAnqoQYPpSA,5515
|
|
91
|
-
tests/unit/test_settings.py,sha256=
|
|
92
|
+
tests/unit/test_settings.py,sha256=eBlV-ME_O8oLoOjJqqYTDTXJs-0smnM0oIMwHZEjUbo,17727
|
|
92
93
|
tests/unit/util/__init__.py,sha256=GInSQBb2SoVD5LZfmSCQa9-UZJT_UP-jNfrojkgCybU,87
|
|
93
94
|
tests/unit/util/test_mw.py,sha256=YC4mjn6G6_XuHELt8uW9F6g2K0_fWtQl1R0kWFvWbAo,18565
|
|
94
|
-
tests/unit/util/test_util.py,sha256=
|
|
95
|
+
tests/unit/util/test_util.py,sha256=vqTPgmaKDWhVBRnCKtCNg-OtyR5bP8jeH9DnpcbfVTk,5141
|
|
95
96
|
tests/unit/util/mwi/__init__.py,sha256=pl5jqyCHEwZEviiL8OC-SHulb1rBecstQCFF6qVjL9Y,37
|
|
96
97
|
tests/unit/util/mwi/test_custom_http_headers.py,sha256=UfrhclS0j6WhShtg1ki2oF1kK8JqRC29uevH4tuDqF4,11182
|
|
97
98
|
tests/unit/util/mwi/test_logger.py,sha256=zWImNitMYKPJunXWJjEDEtCEKwBz615PC844ZLwoxIg,1845
|
|
@@ -102,9 +103,9 @@ tests/unit/util/mwi/embedded_connector/test_helpers.py,sha256=vYTWNUTuDeaygo16JG
|
|
|
102
103
|
tests/unit/util/mwi/embedded_connector/test_request.py,sha256=PR-jddnXDEiip-lD7A_QSvRwEkwo3eQ8owZlk-r9vnk,1867
|
|
103
104
|
tests/utils/__init__.py,sha256=ttzJ8xKWGxOJZz56qOiWOn6sp5LGomkZMn_w4KJLRMU,42
|
|
104
105
|
tests/utils/logging_util.py,sha256=VBy_NRvwau3C_CVTBjK5RMROrQimnJYHO2U0aKSZiRw,2234
|
|
105
|
-
matlab_proxy-0.
|
|
106
|
-
matlab_proxy-0.
|
|
107
|
-
matlab_proxy-0.
|
|
108
|
-
matlab_proxy-0.
|
|
109
|
-
matlab_proxy-0.
|
|
110
|
-
matlab_proxy-0.
|
|
106
|
+
matlab_proxy-0.18.0.dist-info/LICENSE.md,sha256=oF0h3UdSF-rlUiMGYwi086ZHqelzz7yOOk9HFDv9ELo,2344
|
|
107
|
+
matlab_proxy-0.18.0.dist-info/METADATA,sha256=9FmzMjPlFh73Jyg-jwhxTDMu_HIfVJJgfAeaMt02lH4,10177
|
|
108
|
+
matlab_proxy-0.18.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
109
|
+
matlab_proxy-0.18.0.dist-info/entry_points.txt,sha256=DbBLYgnRt8UGiOpd0zHigRTyyMdZYhMdvCvSYP7wPN0,244
|
|
110
|
+
matlab_proxy-0.18.0.dist-info/top_level.txt,sha256=9uVTjsUCAS4TwsxueTBxrBg3PdBiTSsYowAkHPv9VY0,19
|
|
111
|
+
matlab_proxy-0.18.0.dist-info/RECORD,,
|
tests/unit/test_app.py
CHANGED
|
@@ -284,6 +284,20 @@ async def test_get_status_route(test_server):
|
|
|
284
284
|
assert resp.status == HTTPStatus.OK
|
|
285
285
|
|
|
286
286
|
|
|
287
|
+
async def test_clear_client_id_route(test_server):
|
|
288
|
+
"""Test to check endpoint: "/clear_client_id"
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
test_server (aiohttp_client): A aiohttp_client server for sending POST request.
|
|
292
|
+
"""
|
|
293
|
+
|
|
294
|
+
state = test_server.server.app["state"]
|
|
295
|
+
state.active_client = "mock_client_id"
|
|
296
|
+
resp = await test_server.post("/clear_client_id")
|
|
297
|
+
assert resp.status == HTTPStatus.OK
|
|
298
|
+
assert state.active_client is None
|
|
299
|
+
|
|
300
|
+
|
|
287
301
|
async def test_get_env_config(test_server):
|
|
288
302
|
"""Test to check endpoint : "/get_env_config"
|
|
289
303
|
|
tests/unit/test_app_state.py
CHANGED
|
@@ -7,6 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
from typing import Optional
|
|
8
8
|
|
|
9
9
|
import pytest
|
|
10
|
+
from matlab_proxy import settings
|
|
10
11
|
|
|
11
12
|
from matlab_proxy import settings
|
|
12
13
|
from matlab_proxy.app_state import AppState
|
|
@@ -14,6 +15,11 @@ from matlab_proxy.constants import MWI_AUTH_TOKEN_NAME_FOR_HTTP
|
|
|
14
15
|
from matlab_proxy.util.mwi.exceptions import LicensingError, MatlabError
|
|
15
16
|
from tests.unit.util import MockResponse
|
|
16
17
|
|
|
18
|
+
from matlab_proxy.constants import (
|
|
19
|
+
CONNECTOR_SECUREPORT_FILENAME,
|
|
20
|
+
USER_CODE_OUTPUT_FILE_NAME,
|
|
21
|
+
)
|
|
22
|
+
|
|
17
23
|
|
|
18
24
|
@pytest.fixture
|
|
19
25
|
def sample_settings_fixture(tmp_path):
|
|
@@ -35,6 +41,7 @@ def sample_settings_fixture(tmp_path):
|
|
|
35
41
|
"mwi_logs_root_dir": Path(settings.get_mwi_config_folder(dev=True)),
|
|
36
42
|
"app_port": 12345,
|
|
37
43
|
"mwapikey": "asdf",
|
|
44
|
+
"has_custom_code_to_execute": False,
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
|
|
@@ -584,3 +591,108 @@ async def test_start_matlab_without_xvfb(app_state_fixture, mocker):
|
|
|
584
591
|
assert app_state_fixture.processes["xvfb"] is None
|
|
585
592
|
# Check if Matlab started
|
|
586
593
|
assert app_state_fixture.processes["matlab"] is mock_matlab
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
@pytest.mark.parametrize(
|
|
597
|
+
"is_desktop, client_id, is_client_id_present, expected_is_active_client",
|
|
598
|
+
[
|
|
599
|
+
(False, None, False, None),
|
|
600
|
+
(False, "mock_id", False, None),
|
|
601
|
+
(True, None, True, True),
|
|
602
|
+
(True, "mock_id", False, True),
|
|
603
|
+
],
|
|
604
|
+
ids=[
|
|
605
|
+
"request_from_non-desktop_client",
|
|
606
|
+
"request_from_non-desktop_client_having_mock_id",
|
|
607
|
+
"request_from_desktop_client",
|
|
608
|
+
"request_from_desktop_client_having_mock_id",
|
|
609
|
+
],
|
|
610
|
+
)
|
|
611
|
+
async def test_get_session_status(
|
|
612
|
+
app_state_fixture,
|
|
613
|
+
is_desktop,
|
|
614
|
+
client_id,
|
|
615
|
+
is_client_id_present,
|
|
616
|
+
expected_is_active_client,
|
|
617
|
+
):
|
|
618
|
+
"""Test to check if correnct session response is returned based on various conditions.
|
|
619
|
+
|
|
620
|
+
Args:
|
|
621
|
+
app_state_fixture (AppState): Object of AppState class with defaults set
|
|
622
|
+
is_desktop (bool): A flag indicating whether the client is a desktop client.
|
|
623
|
+
client_id (str or None): The client ID. If None, a new client ID may be generated.
|
|
624
|
+
is_client_id_present (bool): Indicates whether the expected value of client_id is string or not.
|
|
625
|
+
expected_is_active_client (bool): Indicates the expected value of is_active_client
|
|
626
|
+
|
|
627
|
+
"""
|
|
628
|
+
# The value of transfer_session is a Don't Care condition as initially the value of client_id is always None.
|
|
629
|
+
output_client_id, output_is_active_client = app_state_fixture.get_session_status(
|
|
630
|
+
is_desktop, client_id, transfer_session=False
|
|
631
|
+
)
|
|
632
|
+
assert isinstance(output_client_id, str) == is_client_id_present, (
|
|
633
|
+
"Expected client_id to be a string got None"
|
|
634
|
+
if is_client_id_present
|
|
635
|
+
else "Expected client_id to be None got a string value"
|
|
636
|
+
)
|
|
637
|
+
assert (
|
|
638
|
+
output_is_active_client == expected_is_active_client
|
|
639
|
+
), f"Expected is_active_client to be {expected_is_active_client} got {output_is_active_client}"
|
|
640
|
+
# For clean up of task_detect_client_status
|
|
641
|
+
app_state_fixture.active_client = None
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
async def test_get_session_status_can_transfer_session(app_state_fixture):
|
|
645
|
+
"""Test to check whether transer session changes client id to the new id
|
|
646
|
+
|
|
647
|
+
Args:
|
|
648
|
+
app_state_fixture (AppState): Object of AppState class with defaults set
|
|
649
|
+
"""
|
|
650
|
+
app_state_fixture.active_client = "mock_id"
|
|
651
|
+
app_state_fixture.get_session_status(
|
|
652
|
+
is_desktop=True, client_id="new_id", transfer_session=True
|
|
653
|
+
)
|
|
654
|
+
assert app_state_fixture.active_client == "new_id"
|
|
655
|
+
# For clean up of task_detect_client_status
|
|
656
|
+
app_state_fixture.active_client = None
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
async def test_detect_active_client_status_can_reset_active_client(app_state_fixture):
|
|
660
|
+
"""Test to check whether the value of active client is being reset due to the client inactivity.
|
|
661
|
+
|
|
662
|
+
Args:
|
|
663
|
+
app_state_fixture (AppState): Object of AppState class with defaults set
|
|
664
|
+
"""
|
|
665
|
+
app_state_fixture.active_client = "mock_id"
|
|
666
|
+
await app_state_fixture.detect_active_client_status(
|
|
667
|
+
sleep_time=0, max_inactive_count=0
|
|
668
|
+
)
|
|
669
|
+
assert (
|
|
670
|
+
app_state_fixture.active_client == None
|
|
671
|
+
), f"Expected the active_client to be None"
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
@pytest.mark.parametrize(
|
|
675
|
+
"session_file_count, has_custom_code_to_execute", [(2, True), (1, False)]
|
|
676
|
+
)
|
|
677
|
+
def test_create_logs_dir_for_MATLAB(
|
|
678
|
+
app_state_fixture, session_file_count, has_custom_code_to_execute
|
|
679
|
+
):
|
|
680
|
+
"""Test to check create_logs_dir_for_MATLAB()
|
|
681
|
+
|
|
682
|
+
Args:
|
|
683
|
+
app_state_fixture (AppState): Object of AppState class with defaults set
|
|
684
|
+
"""
|
|
685
|
+
# Arrange
|
|
686
|
+
app_state_fixture.settings["has_custom_code_to_execute"] = (
|
|
687
|
+
has_custom_code_to_execute
|
|
688
|
+
)
|
|
689
|
+
|
|
690
|
+
# Act
|
|
691
|
+
app_state_fixture.create_logs_dir_for_MATLAB()
|
|
692
|
+
|
|
693
|
+
# Assert
|
|
694
|
+
for _, session_file_path in app_state_fixture.matlab_session_files.items():
|
|
695
|
+
# Check session files are present in mwi logs directory
|
|
696
|
+
assert app_state_fixture.mwi_logs_dir == Path(session_file_path).parent
|
|
697
|
+
|
|
698
|
+
assert len(app_state_fixture.matlab_session_files) == session_file_count
|
tests/unit/test_settings.py
CHANGED
|
@@ -458,3 +458,38 @@ def test_get_ssl_context_with_invalid_custom_ssl_files_raises_exception(
|
|
|
458
458
|
|
|
459
459
|
with pytest.raises(Exception, match=exception_msg):
|
|
460
460
|
settings._validate_ssl_files_and_get_ssl_context(mwi_certs_dir)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
@pytest.mark.parametrize(
|
|
464
|
+
"expected_value_for_has_custom_code, custom_code, has_custom_code_exception_matlab_cmd",
|
|
465
|
+
[(False, "", False), (True, "run(disp('MATLAB'))", True)],
|
|
466
|
+
ids=["No custom code to execute", "Has custom code to execute"],
|
|
467
|
+
)
|
|
468
|
+
def test_get_matlab_settings_custom_code(
|
|
469
|
+
monkeypatch,
|
|
470
|
+
mocker,
|
|
471
|
+
expected_value_for_has_custom_code,
|
|
472
|
+
custom_code,
|
|
473
|
+
has_custom_code_exception_matlab_cmd,
|
|
474
|
+
):
|
|
475
|
+
# Arrange
|
|
476
|
+
monkeypatch.setenv(mwi_env.get_env_name_custom_matlab_code(), custom_code)
|
|
477
|
+
mocker.patch(
|
|
478
|
+
"matlab_proxy.settings.get_matlab_executable_and_root_path",
|
|
479
|
+
return_value=("matlab", None),
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
# Act
|
|
483
|
+
matlab_settings = settings.get_matlab_settings()
|
|
484
|
+
exception_present_in_matlab_cmd = (
|
|
485
|
+
"MATLABCustomStartupCodeError" in matlab_settings["matlab_cmd"][-1]
|
|
486
|
+
)
|
|
487
|
+
print(matlab_settings)
|
|
488
|
+
|
|
489
|
+
# Assert
|
|
490
|
+
assert (
|
|
491
|
+
matlab_settings["has_custom_code_to_execute"]
|
|
492
|
+
== expected_value_for_has_custom_code
|
|
493
|
+
)
|
|
494
|
+
|
|
495
|
+
assert exception_present_in_matlab_cmd == has_custom_code_exception_matlab_cmd
|
tests/unit/util/test_util.py
CHANGED
|
@@ -6,6 +6,9 @@ import psutil
|
|
|
6
6
|
|
|
7
7
|
from matlab_proxy.util import get_child_processes, system, add_signal_handlers, prettify
|
|
8
8
|
from matlab_proxy.util import system
|
|
9
|
+
from matlab_proxy.util.mwi.exceptions import (
|
|
10
|
+
UIVisibleFatalError,
|
|
11
|
+
)
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
def test_get_supported_termination_signals():
|
|
@@ -90,7 +93,7 @@ def test_get_child_processes_no_children(mocker):
|
|
|
90
93
|
mock_parent_process_psutil.children.return_value = []
|
|
91
94
|
|
|
92
95
|
# Call the function with the mocked parent process
|
|
93
|
-
with pytest.raises(
|
|
96
|
+
with pytest.raises(UIVisibleFatalError):
|
|
94
97
|
get_child_processes(parent_process)
|
|
95
98
|
|
|
96
99
|
|