Skip to content

Commit b259cbf

Browse files
committed
Rename files to include mwi_ prefix
1 parent ffb3e36 commit b259cbf

21 files changed

+130
-127
lines changed

jupyter_matlab_proxy/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Copyright 2020-2021 The MathWorks, Inc.
22

33
import os
4-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
4+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
55

66

77
def _get_env(port, base_url):
88
return {
9-
mw_env.get_env_name_app_port(): str(port),
10-
mw_env.get_env_name_base_url(): f"{base_url}matlab",
11-
mw_env.get_env_name_app_host(): "127.0.0.1",
12-
mw_env.get_env_name_mhlm_context(): "MATLAB_JUPYTER",
9+
mwi_env.get_env_name_app_port(): str(port),
10+
mwi_env.get_env_name_base_url(): f"{base_url}matlab",
11+
mwi_env.get_env_name_app_host(): "127.0.0.1",
12+
mwi_env.get_env_name_mhlm_context(): "MATLAB_JUPYTER",
1313
}
1414

1515

jupyter_matlab_proxy/app.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import signal
1010
from . import settings
1111
from .app_state import AppState
12-
from .util import mw_logger
13-
from .util.exceptions import LicensingError
14-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
12+
from .util import mwi_logger
13+
from .util.mwi_exceptions import LicensingError
14+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
1515
import pkgutil
1616
import mimetypes
1717

@@ -155,7 +155,7 @@ async def termination_integration_delete(req):
155155
'with pytest.raises()', there by causing the test : test_termination_integration_delete()
156156
to fail. Inorder to avoid this, adding the below if condition to check to skip sys.exit(0) when testing
157157
"""
158-
if not mw_env.is_testing_mode_enabled():
158+
if not mwi_env.is_testing_mode_enabled():
159159
sys.exit(0)
160160

161161

@@ -202,7 +202,7 @@ def make_static_route_table(app):
202202
content_type = mimetypes.guess_type(name)[0]
203203

204204
headers = {"content-type": content_type}
205-
headers.update(app["settings"]["custom_http_headers"])
205+
headers.update(app["settings"]["mwi_custom_http_headers"])
206206

207207
table[f"{base_url}{parent}/{name}"] = {
208208
"mod": mod,
@@ -286,7 +286,7 @@ async def wsforward(ws_from, ws_to):
286286

287287
headers = res.headers.copy()
288288
body = await res.read()
289-
headers.update(req.app["settings"]["custom_http_headers"])
289+
headers.update(req.app["settings"]["mwi_custom_http_headers"])
290290

291291
return web.Response(headers=headers, status=res.status, body=body)
292292
except Exception:
@@ -361,7 +361,7 @@ def create_app():
361361
app = web.Application()
362362

363363
# Get application settings
364-
app["settings"] = settings.get(dev=(mw_env.is_development_mode_enabled()))
364+
app["settings"] = settings.get(dev=(mwi_env.is_development_mode_enabled()))
365365

366366
# TODO Validate any settings
367367

@@ -370,7 +370,7 @@ def create_app():
370370

371371
# In development mode, the node development server proxies requests to this
372372
# development server instead of serving the static files directly
373-
if not mw_env.is_development_mode_enabled():
373+
if not mwi_env.is_development_mode_enabled():
374374
app["static_route_table"] = make_static_route_table(app)
375375
for key in app["static_route_table"].keys():
376376
app.router.add_route("GET", key, static_get)
@@ -401,7 +401,7 @@ def get_supported_termination_signals():
401401

402402
def main():
403403

404-
logger = mw_logger.get(init=True)
404+
logger = mwi_logger.get(init=True)
405405

406406
logger.info("Starting MATLAB proxy-app")
407407

jupyter_matlab_proxy/app_state.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2020-2021 The MathWorks, Inc.
22

33
import asyncio
4-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
4+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
55
import xml.etree.ElementTree as ET
66
import os
77
import json
@@ -13,8 +13,8 @@
1313
import socket
1414
import errno
1515
from collections import deque
16-
from .util import mw, mw_logger, validators
17-
from .util.exceptions import (
16+
from .util import mw, mwi_logger, mwi_validators
17+
from .util.mwi_exceptions import (
1818
LicensingError,
1919
InternalError,
2020
OnlineLicensingError,
@@ -25,7 +25,7 @@
2525
)
2626

2727

28-
logger = mw_logger.get()
28+
logger = mwi_logger.get()
2929

3030

3131
class AppState:
@@ -313,8 +313,8 @@ def reserve_matlab_port(self):
313313
# node application in development mode always uses port 31515 to bypass the
314314
# reverse proxy. Once this is addressed, remove this special case.
315315
if (
316-
mw_env.is_development_mode_enabled()
317-
and not mw_env.is_testing_mode_enabled()
316+
mwi_env.is_development_mode_enabled()
317+
and not mwi_env.is_testing_mode_enabled()
318318
):
319319
self.matlab_port = 31515
320320
else:
@@ -402,7 +402,7 @@ async def start_matlab(self, restart=False):
402402
matlab_env["MW_LOGIN_DISPLAY_NAME"] = self.licensing["display_name"]
403403
matlab_env["MW_LOGIN_USER_ID"] = self.licensing["user_id"]
404404
matlab_env["MW_LOGIN_PROFILE_ID"] = self.licensing["profile_id"]
405-
if os.getenv(mw_env.get_env_name_mhlm_context()) is None:
405+
if os.getenv(mwi_env.get_env_name_mhlm_context()) is None:
406406
matlab_env["MHLM_CONTEXT"] = "MATLAB_JAVASCRIPT_DESKTOP"
407407

408408
elif self.licensing["type"] == "nlm":

jupyter_matlab_proxy/devel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import asyncio, aiohttp
55
from aiohttp import web
66
import socket, time, os, sys
7-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
7+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
88

99
desktop_html = b"""
1010
<h1>Fake MATLAB Web Desktop</h1>
@@ -70,7 +70,7 @@ async def fake_matlab_started(app):
7070

7171
# If "123@brokenhost" is specified as the MLM_LICENSE_FILE, exit to simulate an
7272
# error
73-
nlm = os.environ.get(mw_env.get_env_name_network_license_manager())
73+
nlm = os.environ.get(mwi_env.get_env_name_network_license_manager())
7474
if nlm == "123@brokenhost":
7575
# TODO This should output the exact same text as MATLAB would in the same error
7676
# state

jupyter_matlab_proxy/settings.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import uuid
88
import socket
99
import shutil
10-
from .util import custom_http_headers, validators
11-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
10+
from .util import mwi_custom_http_headers, mwi_validators
11+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
1212

1313

1414
def get_matlab_path():
@@ -58,19 +58,19 @@ def get_dev_settings():
5858
],
5959
"create_xvfb_cmd": create_xvfb_cmd,
6060
"matlab_ready_file": matlab_ready_file,
61-
"base_url": os.environ.get(mw_env.get_env_name_base_url(), ""),
62-
"app_port": os.environ.get(mw_env.get_env_name_app_port(), 8000),
63-
"host_interface": os.environ.get(mw_env.get_env_name_app_host(), "127.0.0.1"),
61+
"base_url": os.environ.get(mwi_env.get_env_name_base_url(), ""),
62+
"app_port": os.environ.get(mwi_env.get_env_name_app_port(), 8000),
63+
"host_interface": os.environ.get(mwi_env.get_env_name_app_host(), "127.0.0.1"),
6464
"mwapikey": str(uuid.uuid4()),
6565
"matlab_protocol": "http",
6666
"matlab_display": ":1",
67-
"nlm_conn_str": os.environ.get(mw_env.get_env_name_network_license_manager()),
67+
"nlm_conn_str": os.environ.get(mwi_env.get_env_name_network_license_manager()),
6868
"matlab_config_file": matlab_temp_dir / "proxy_app_config.json",
6969
"ws_env": ws_env,
7070
"mwa_api_endpoint": f"https://login{ws_env_suffix}.mathworks.com/authenticationws/service/v4",
7171
"mhlm_api_endpoint": f"https://licensing{ws_env_suffix}.mathworks.com/mls/service/v1/entitlement/list",
7272
"mwa_login": f"https://login{ws_env_suffix}.mathworks.com",
73-
"custom_http_headers": custom_http_headers.get(),
73+
"mwi_custom_http_headers": mwi_custom_http_headers.get(),
7474
}
7575

7676

@@ -90,7 +90,7 @@ def get(dev=False):
9090

9191
# If running tests using Pytest, it will set environment variable TEST to true before running tests.
9292
# Will make test env specific changes before returning the settings.
93-
if mw_env.is_testing_mode_enabled():
93+
if mwi_env.is_testing_mode_enabled():
9494

9595
# Set ready_delay value to 0 for faster fake MATLAB startup.
9696
ready_delay = ["--ready-delay", "0"]
@@ -128,20 +128,20 @@ def get(dev=False):
128128
],
129129
"create_xvfb_cmd": create_xvfb_cmd,
130130
"matlab_ready_file": Path(tempfile.gettempdir()) / "connector.securePort",
131-
"base_url": os.environ[mw_env.get_env_name_base_url()],
132-
"app_port": os.environ[mw_env.get_env_name_app_port()],
133-
"host_interface": os.environ.get(mw_env.get_env_name_app_host()),
131+
"base_url": os.environ[mwi_env.get_env_name_base_url()],
132+
"app_port": os.environ[mwi_env.get_env_name_app_port()],
133+
"host_interface": os.environ.get(mwi_env.get_env_name_app_host()),
134134
"mwapikey": str(uuid.uuid4()),
135135
"matlab_protocol": "https",
136-
"nlm_conn_str": validators.validate_mlm_license_file(
137-
os.environ.get(mw_env.get_env_name_network_license_manager())
136+
"nlm_conn_str": mwi_validators.validate_mlm_license_file(
137+
os.environ.get(mwi_env.get_env_name_network_license_manager())
138138
),
139139
"matlab_config_file": Path.home() / ".matlab" / "proxy_app_config.json",
140140
"ws_env": ws_env,
141141
"mwa_api_endpoint": f"https://login{ws_env_suffix}.mathworks.com/authenticationws/service/v4",
142142
"mhlm_api_endpoint": f"https://licensing{ws_env_suffix}.mathworks.com/mls/service/v1/entitlement/list",
143143
"mwa_login": f"https://login{ws_env_suffix}.mathworks.com",
144-
"custom_http_headers": custom_http_headers.get(),
144+
"mwi_custom_http_headers": mwi_custom_http_headers.get(),
145145
}
146146

147147

jupyter_matlab_proxy/util/mw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import xml.etree.ElementTree as ET
44
import aiohttp, os, asyncio, select, logging
5-
from .exceptions import (
5+
from .mwi_exceptions import (
66
OnlineLicensingError,
77
EntitlementError,
88
NetworkLicensingError,
99
MatlabError,
1010
)
11-
from . import mw_logger
11+
from . import mwi_logger
1212

13-
logger = mw_logger.get()
13+
logger = mwi_logger.get()
1414

1515

1616
def __get_licensing_url():

jupyter_matlab_proxy/util/custom_http_headers.py renamed to jupyter_matlab_proxy/util/mwi_custom_http_headers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import os, json, sys
44
from json.decoder import JSONDecodeError
5-
from . import mw_logger
6-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
5+
from . import mwi_logger
6+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
77

8-
logger = mw_logger.get()
8+
logger = mwi_logger.get()
99

1010

1111
def get():
@@ -181,7 +181,7 @@ def __get_custom_header_env_var():
181181
Returns:
182182
String: Environment variable containing path to the file containing custom headers.
183183
"""
184-
return mw_env.get_env_name_custom_http_headers()
184+
return mwi_env.get_env_name_custom_http_headers()
185185

186186

187187
def __get_exception_statement():

jupyter_matlab_proxy/util/mw_logger.py renamed to jupyter_matlab_proxy/util/mwi_logger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import logging
66
import os
7-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
7+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
88

99

1010
def get(init=False):
@@ -68,8 +68,8 @@ def get_environment_variable_names():
6868
{tuple}: name of environment variable to control log level,
6969
name of environment variable to control logging to file
7070
"""
71-
__log_file_environment_variable_name = mw_env.get_env_name_log_file()
72-
__log_level_environment_variable_name = mw_env.get_env_name_logging_level()
71+
__log_file_environment_variable_name = mwi_env.get_env_name_log_file()
72+
__log_level_environment_variable_name = mwi_env.get_env_name_logging_level()
7373
return __log_level_environment_variable_name, __log_file_environment_variable_name
7474

7575

jupyter_matlab_proxy/util/validators.py renamed to jupyter_matlab_proxy/util/mwi_validators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def validate_mlm_license_file(nlm_conn_str):
2020
"""
2121
import re
2222
import os
23-
from . import mw_logger
24-
from .exceptions import NetworkLicensingError
23+
from . import mwi_logger
24+
from .mwi_exceptions import NetworkLicensingError
2525

26-
logger = mw_logger.get()
26+
logger = mwi_logger.get()
2727

2828
if nlm_conn_str is None:
2929
return None

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import os, pytest, shutil
44
from jupyter_matlab_proxy import settings
5-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
5+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
66

77

88
def pytest_generate_tests(metafunc):
9-
os.environ[mw_env.get_env_name_development()] = "true"
9+
os.environ[mwi_env.get_env_name_development()] = "true"
1010

1111

1212
def __get_matlab_config_file():

tests/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from unittest.mock import patch
55
from aiohttp import web
66
from jupyter_matlab_proxy import app, settings
7-
from jupyter_matlab_proxy.util.exceptions import MatlabInstallError
7+
from jupyter_matlab_proxy.util.mwi_exceptions import MatlabInstallError
88
from subprocess import Popen, PIPE
99
from jupyter_matlab_proxy.app_state import AppState
1010
from distutils.dir_util import copy_tree

tests/test_devel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest, asyncio, socket, os, tempfile, requests, pty, time, subprocess, sys
44
from pathlib import Path
5-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
5+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
66
from collections import namedtuple
77

88
"""
@@ -38,7 +38,7 @@ def valid_nlm_fixture(monkeypatch):
3838
monkeypatch : A built-in pytest fixture
3939
"""
4040

41-
monkeypatch.setenv(mw_env.get_env_name_network_license_manager(), "abc@nlm")
41+
monkeypatch.setenv(mwi_env.get_env_name_network_license_manager(), "abc@nlm")
4242

4343

4444
@pytest.fixture(name="invalid_nlm")
@@ -52,7 +52,7 @@ def invalid_nlm_fixture(monkeypatch):
5252
monkeypatch : A built-in pytest fixture
5353
"""
5454

55-
monkeypatch.setenv(mw_env.get_env_name_network_license_manager(), "123@brokenhost")
55+
monkeypatch.setenv(mwi_env.get_env_name_network_license_manager(), "123@brokenhost")
5656

5757

5858
@pytest.fixture(name="matlab_process_setup")

tests/test_jupyter_server_proxy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import jupyter_matlab_proxy
44
import os
55
from pathlib import Path
6-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
6+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
77

88

99
def test_get_env():
1010
port = 10000
1111
base_url = "/foo/"
1212
r = jupyter_matlab_proxy._get_env(port, base_url)
13-
assert r[mw_env.get_env_name_app_port()] == str(port)
14-
assert r[mw_env.get_env_name_base_url()] == f"{base_url}matlab"
13+
assert r[mwi_env.get_env_name_app_port()] == str(port)
14+
assert r[mwi_env.get_env_name_base_url()] == f"{base_url}matlab"
1515

1616

1717
def test_setup_matlab():

tests/test_non_dev_mode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from distutils.dir_util import copy_tree
66
from pathlib import Path
77
import jupyter_matlab_proxy
8-
from jupyter_matlab_proxy import mw_environment_variables as mw_env
8+
from jupyter_matlab_proxy import mwi_environment_variables as mwi_env
99
from tests.test_app import FakeServer
1010

1111
"""
@@ -22,7 +22,7 @@ def matlab_port_fixture(monkeypatch):
2222
Args:
2323
monkeypatch : A built-in pytest fixture
2424
"""
25-
monkeypatch.setenv(mw_env.get_env_name_development(), "false")
25+
monkeypatch.setenv(mwi_env.get_env_name_development(), "false")
2626

2727

2828
@pytest.fixture(name="build_frontend")

0 commit comments

Comments
 (0)