matlab-proxy 0.13.1__py3-none-any.whl → 0.15.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 +66 -5
- 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.0fcee5e5.js → main.14aa7840.js} +3 -3
- matlab_proxy/gui/static/js/main.14aa7840.js.map +1 -0
- matlab_proxy/util/mw.py +4 -4
- matlab_proxy/util/mwi/download.py +145 -0
- matlab_proxy/util/mwi/embedded_connector/helpers.py +1 -1
- matlab_proxy/util/mwi/embedded_connector/request.py +3 -3
- {matlab_proxy-0.13.1.dist-info → matlab_proxy-0.15.0.dist-info}/METADATA +2 -1
- {matlab_proxy-0.13.1.dist-info → matlab_proxy-0.15.0.dist-info}/RECORD +29 -16
- {matlab_proxy-0.13.1.dist-info → matlab_proxy-0.15.0.dist-info}/WHEEL +1 -1
- {matlab_proxy-0.13.1.dist-info → matlab_proxy-0.15.0.dist-info}/top_level.txt +1 -0
- tests/integration/__init__.py +1 -0
- tests/integration/integration_tests_with_license/__init__.py +1 -0
- tests/integration/integration_tests_with_license/conftest.py +47 -0
- tests/integration/integration_tests_with_license/test_http_end_points.py +223 -0
- tests/integration/integration_tests_without_license/__init__.py +1 -0
- tests/integration/integration_tests_without_license/conftest.py +115 -0
- tests/integration/integration_tests_without_license/test_matlab_is_down_if_unlicensed.py +46 -0
- tests/integration/utils/__init__.py +1 -0
- tests/integration/utils/integration_tests_utils.py +352 -0
- tests/integration/utils/licensing.py +152 -0
- tests/utils/__init__.py +1 -0
- tests/utils/logging_util.py +81 -0
- matlab_proxy/gui/static/js/main.0fcee5e5.js.map +0 -1
- /matlab_proxy/gui/static/js/{main.0fcee5e5.js.LICENSE.txt → main.14aa7840.js.LICENSE.txt} +0 -0
- {matlab_proxy-0.13.1.dist-info → matlab_proxy-0.15.0.dist-info}/LICENSE.md +0 -0
- {matlab_proxy-0.13.1.dist-info → matlab_proxy-0.15.0.dist-info}/entry_points.txt +0 -0
matlab_proxy/app.py
CHANGED
|
@@ -18,7 +18,7 @@ from matlab_proxy import constants, settings, util
|
|
|
18
18
|
from matlab_proxy.app_state import AppState
|
|
19
19
|
from matlab_proxy.util import mwi
|
|
20
20
|
from matlab_proxy.util.mwi import environment_variables as mwi_env
|
|
21
|
-
from matlab_proxy.util.mwi import token_auth
|
|
21
|
+
from matlab_proxy.util.mwi import token_auth, download
|
|
22
22
|
from matlab_proxy.util.mwi.exceptions import AppError, InvalidTokenError, LicensingError
|
|
23
23
|
from matlab_proxy.constants import IS_CONCURRENCY_CHECK_ENABLED
|
|
24
24
|
|
|
@@ -546,7 +546,9 @@ async def matlab_view(req):
|
|
|
546
546
|
await ws_server.prepare(req)
|
|
547
547
|
|
|
548
548
|
async with aiohttp.ClientSession(
|
|
549
|
-
|
|
549
|
+
trust_env=True,
|
|
550
|
+
cookies=req.cookies,
|
|
551
|
+
connector=aiohttp.TCPConnector(verify_ssl=False),
|
|
550
552
|
) as client_session:
|
|
551
553
|
try:
|
|
552
554
|
async with client_session.ws_connect(
|
|
@@ -610,25 +612,29 @@ async def matlab_view(req):
|
|
|
610
612
|
else:
|
|
611
613
|
# Proxy, injecting request header
|
|
612
614
|
async with aiohttp.ClientSession(
|
|
615
|
+
trust_env=True,
|
|
613
616
|
connector=aiohttp.TCPConnector(verify_ssl=False),
|
|
614
617
|
) as client_session:
|
|
615
618
|
try:
|
|
616
619
|
req_body = await transform_body(req)
|
|
620
|
+
req_url = await transform_request_url(
|
|
621
|
+
req, matlab_base_url=matlab_base_url
|
|
622
|
+
)
|
|
617
623
|
# Set content length in case of modification
|
|
618
624
|
reqH["Content-Length"] = str(len(req_body))
|
|
619
625
|
reqH["x-forwarded-proto"] = "http"
|
|
620
626
|
|
|
621
627
|
async with client_session.request(
|
|
622
628
|
req.method,
|
|
623
|
-
|
|
629
|
+
req_url,
|
|
624
630
|
headers={**reqH, **{"mwapikey": mwapikey}},
|
|
625
631
|
allow_redirects=False,
|
|
626
632
|
data=req_body,
|
|
633
|
+
params=None,
|
|
627
634
|
) as res:
|
|
628
635
|
headers = res.headers.copy()
|
|
629
636
|
body = await res.read()
|
|
630
637
|
headers.update(req.app["settings"]["mwi_custom_http_headers"])
|
|
631
|
-
|
|
632
638
|
return web.Response(headers=headers, status=res.status, body=body)
|
|
633
639
|
|
|
634
640
|
# Handles any pending HTTP requests from the browser when the MATLAB process is terminated before responding to them.
|
|
@@ -649,6 +655,34 @@ async def matlab_view(req):
|
|
|
649
655
|
raise web.HTTPNotFound()
|
|
650
656
|
|
|
651
657
|
|
|
658
|
+
async def transform_request_url(req, matlab_base_url):
|
|
659
|
+
"""
|
|
660
|
+
Performs any transformations that may be required on the URL.
|
|
661
|
+
|
|
662
|
+
If the request is identified as a download request it transforms the request URL to
|
|
663
|
+
support downloading the file.
|
|
664
|
+
|
|
665
|
+
The original constructed URL is returned, when there are no transformations to be applied.
|
|
666
|
+
|
|
667
|
+
Args:
|
|
668
|
+
req: The request object that contains the relative URL and other request information.
|
|
669
|
+
matlab_base_url: The base URL of the MATLAB service to which the relative URL should be appended.
|
|
670
|
+
|
|
671
|
+
Returns:
|
|
672
|
+
A string representing the transformed URL, or the original URL.
|
|
673
|
+
"""
|
|
674
|
+
original_request_url = f"{matlab_base_url}{req.rel_url}"
|
|
675
|
+
|
|
676
|
+
if download.is_download_request(req):
|
|
677
|
+
download_url = await download.get_download_url(req)
|
|
678
|
+
if download_url:
|
|
679
|
+
transformed_request_url = f"{matlab_base_url}{download_url}"
|
|
680
|
+
logger.debug(f"Transformed Request url: {transformed_request_url}")
|
|
681
|
+
return transformed_request_url
|
|
682
|
+
|
|
683
|
+
return original_request_url
|
|
684
|
+
|
|
685
|
+
|
|
652
686
|
async def transform_body(req):
|
|
653
687
|
"""Transform HTTP POST requests as required by the MATLAB JavaScript Desktop.
|
|
654
688
|
|
|
@@ -846,7 +880,29 @@ def create_app(config_name=matlab_proxy.get_default_config_name()):
|
|
|
846
880
|
return app
|
|
847
881
|
|
|
848
882
|
|
|
883
|
+
def configure_no_proxy_in_env():
|
|
884
|
+
"""Update the environment variable no_proxy to allow communication between processes on the local machine."""
|
|
885
|
+
import os
|
|
886
|
+
|
|
887
|
+
no_proxy_whitelist = ["0.0.0.0", "localhost", "127.0.0.1"]
|
|
888
|
+
|
|
889
|
+
no_proxy_env = os.environ.get("no_proxy")
|
|
890
|
+
if no_proxy_env is None:
|
|
891
|
+
os.environ["no_proxy"] = ",".join(no_proxy_whitelist)
|
|
892
|
+
else:
|
|
893
|
+
# Create set with leading and trailing whitespaces stripped
|
|
894
|
+
existing_no_proxy_env = [
|
|
895
|
+
val.lstrip().rstrip() for val in no_proxy_env.split(",")
|
|
896
|
+
]
|
|
897
|
+
os.environ["no_proxy"] = ",".join(
|
|
898
|
+
set(existing_no_proxy_env + no_proxy_whitelist)
|
|
899
|
+
)
|
|
900
|
+
logger.info(f"Setting no_proxy to: {os.environ.get('no_proxy')}")
|
|
901
|
+
|
|
902
|
+
|
|
849
903
|
def create_and_start_app(config_name):
|
|
904
|
+
configure_no_proxy_in_env()
|
|
905
|
+
|
|
850
906
|
# Create, configure and start the app.
|
|
851
907
|
app = create_app(config_name)
|
|
852
908
|
app = configure_and_start(app)
|
|
@@ -884,7 +940,7 @@ def print_version_and_exit():
|
|
|
884
940
|
"""prints the version of the package and exits"""
|
|
885
941
|
from importlib.metadata import version
|
|
886
942
|
|
|
887
|
-
matlab_proxy_version = version("
|
|
943
|
+
matlab_proxy_version = version(__name__.split(".")[0])
|
|
888
944
|
print(f"{matlab_proxy_version}")
|
|
889
945
|
sys.exit(0)
|
|
890
946
|
|
|
@@ -900,3 +956,8 @@ def main():
|
|
|
900
956
|
desired_configuration_name = util.parse_cli_args()["config"]
|
|
901
957
|
|
|
902
958
|
create_and_start_app(config_name=desired_configuration_name)
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
# In support of enabling debugging in a Python Debugger (VSCode)
|
|
962
|
+
if __name__ == "__main__":
|
|
963
|
+
main()
|
matlab_proxy/constants.py
CHANGED
|
@@ -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.14aa7840.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.14aa7840.js.map": "./static/js/main.14aa7840.js.map"
|
|
39
39
|
},
|
|
40
40
|
"entrypoints": [
|
|
41
41
|
"static/css/main.47712126.css",
|
|
42
|
-
"static/js/main.
|
|
42
|
+
"static/js/main.14aa7840.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.14aa7840.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>
|