matlab-proxy 0.16.0__tar.gz → 0.17.0__tar.gz

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 (166) hide show
  1. {matlab-proxy-0.16.0/matlab_proxy.egg-info → matlab-proxy-0.17.0}/PKG-INFO +1 -1
  2. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/index.js +16 -0
  3. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/app.py +33 -17
  4. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/app_state.py +81 -0
  5. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0/matlab_proxy.egg-info}/PKG-INFO +1 -1
  6. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/setup.py +1 -1
  7. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/test_app.py +14 -0
  8. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/test_app_state.py +78 -0
  9. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/LICENSE.md +0 -0
  10. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/MANIFEST.in +0 -0
  11. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/README.md +0 -0
  12. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/.eslintrc.json +0 -0
  13. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/.gitignore +0 -0
  14. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/README.md +0 -0
  15. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/package-lock.json +0 -0
  16. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/package.json +0 -0
  17. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/public/favicon.ico +0 -0
  18. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/public/index.html +0 -0
  19. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/public/manifest.json +0 -0
  20. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/public/robots.txt +0 -0
  21. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/actionCreators/actionCreators.spec.js +0 -0
  22. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/actionCreators/index.js +0 -0
  23. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/actions/index.js +0 -0
  24. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/css/bootstrap.min.css +0 -0
  25. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/css/site7.min.css +0 -0
  26. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/glyphicons-halflings-regular.eot +0 -0
  27. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/glyphicons-halflings-regular.svg +0 -0
  28. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/glyphicons-halflings-regular.ttf +0 -0
  29. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/glyphicons-halflings-regular.woff +0 -0
  30. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/glyphicons-halflings-regular.woff2 +0 -0
  31. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks-eps.svg +0 -0
  32. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks-eps.ttf +0 -0
  33. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks-eps.woff +0 -0
  34. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks-pictograms.svg +0 -0
  35. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks-pictograms.ttf +0 -0
  36. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks-pictograms.woff +0 -0
  37. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks.svg +0 -0
  38. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks.ttf +0 -0
  39. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/fonts/mathworks.woff +0 -0
  40. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/images/bug_reports/workaround.gif +0 -0
  41. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/images/responsive/global/ico-header-account-hover.svg +0 -0
  42. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/images/responsive/global/ico-header-account.svg +0 -0
  43. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/images/responsive/global/ico-header-contact-hover.svg +0 -0
  44. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/images/responsive/global/ico-header-contact.svg +0 -0
  45. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/3p/images/responsive/global/ico-sprite.png +0 -0
  46. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/App.css +0 -0
  47. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/App.spec.js +0 -0
  48. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/App/MATLAB-env-blur.png +0 -0
  49. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Confirmation/Confirmation.spec.js +0 -0
  50. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Confirmation/index.js +0 -0
  51. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/Controls.css +0 -0
  52. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/Controls.spec.js +0 -0
  53. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/feedback.svg +0 -0
  54. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/help.svg +0 -0
  55. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/index.js +0 -0
  56. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/restart.svg +0 -0
  57. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/sign-out.svg +0 -0
  58. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/start.svg +0 -0
  59. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/stop.svg +0 -0
  60. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Controls/terminate.svg +0 -0
  61. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/EntitlementSelector/EntitlementSelector.spec.js +0 -0
  62. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/EntitlementSelector/index.js +0 -0
  63. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Error/Error.css +0 -0
  64. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Error/Error.spec.js +0 -0
  65. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Error/index.js +0 -0
  66. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Help/Help.css +0 -0
  67. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Help/Help.spec.js +0 -0
  68. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Help/index.js +0 -0
  69. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Information/Information.css +0 -0
  70. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Information/Information.spec.js +0 -0
  71. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Information/index.js +0 -0
  72. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/LicensingGatherer/ExistingLicense.css +0 -0
  73. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/LicensingGatherer/ExistingLicense.js +0 -0
  74. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/LicensingGatherer/LicenseGatherer.spec.js +0 -0
  75. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/LicensingGatherer/LicensingGatherer.css +0 -0
  76. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/LicensingGatherer/MHLM.js +0 -0
  77. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/LicensingGatherer/NLM.js +0 -0
  78. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/LicensingGatherer/index.js +0 -0
  79. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/MatlabJsd/MatlabJsd.css +0 -0
  80. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/MatlabJsd/MatlabJsd.spec.js +0 -0
  81. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/MatlabJsd/index.js +0 -0
  82. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Overlay/Overlay.css +0 -0
  83. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Overlay/Overlay.spec.js +0 -0
  84. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/Overlay/index.js +0 -0
  85. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/OverlayTrigger/OverlayTrigger.css +0 -0
  86. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/OverlayTrigger/OverlayTrigger.spec.js +0 -0
  87. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/OverlayTrigger/ResizeOverlayTrigger.spec.js +0 -0
  88. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/OverlayTrigger/arrow.svg +0 -0
  89. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/OverlayTrigger/gripper.svg +0 -0
  90. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/OverlayTrigger/index.js +0 -0
  91. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/OverlayTrigger/trigger-error.svg +0 -0
  92. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/components/OverlayTrigger/trigger-ok.svg +0 -0
  93. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/constants.js +0 -0
  94. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/index.css +0 -0
  95. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/index.js +0 -0
  96. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/jest.config.json +0 -0
  97. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/logo.svg +0 -0
  98. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/reducers/index.js +0 -0
  99. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/reducers/reducers.spec.js +0 -0
  100. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/selectors/index.js +0 -0
  101. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/selectors/selectors.spec.js +0 -0
  102. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/serviceWorker.js +0 -0
  103. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/setupTests.js +0 -0
  104. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/test/utils/react-test.js +0 -0
  105. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/gui/src/test/utils/state.js +0 -0
  106. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/__init__.py +0 -0
  107. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/constants.py +0 -0
  108. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/default_configuration.py +0 -0
  109. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/devel.py +0 -0
  110. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/icons/matlab.svg +0 -0
  111. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/matlab/startup.m +0 -0
  112. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/settings.py +0 -0
  113. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/__init__.py +0 -0
  114. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/event_loop.py +0 -0
  115. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/list_servers.py +0 -0
  116. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mw.py +0 -0
  117. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/__init__.py +0 -0
  118. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/custom_http_headers.py +0 -0
  119. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/download.py +0 -0
  120. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/embedded_connector/__init__.py +0 -0
  121. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/embedded_connector/helpers.py +0 -0
  122. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/embedded_connector/request.py +0 -0
  123. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/environment_variables.py +0 -0
  124. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/exceptions.py +0 -0
  125. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/logger.py +0 -0
  126. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/token_auth.py +0 -0
  127. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/mwi/validators.py +0 -0
  128. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/system.py +0 -0
  129. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy/util/windows.py +0 -0
  130. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy.egg-info/SOURCES.txt +0 -0
  131. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy.egg-info/dependency_links.txt +0 -0
  132. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy.egg-info/entry_points.txt +0 -0
  133. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy.egg-info/not-zip-safe +0 -0
  134. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy.egg-info/requires.txt +0 -0
  135. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/matlab_proxy.egg-info/top_level.txt +0 -0
  136. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/setup.cfg +0 -0
  137. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/__init__.py +0 -0
  138. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/integration_tests_with_license/__init__.py +0 -0
  139. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/integration_tests_with_license/conftest.py +0 -0
  140. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/integration_tests_with_license/test_http_end_points.py +0 -0
  141. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/integration_tests_without_license/__init__.py +0 -0
  142. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/integration_tests_without_license/conftest.py +0 -0
  143. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/integration_tests_without_license/test_matlab_is_down_if_unlicensed.py +0 -0
  144. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/utils/__init__.py +0 -0
  145. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/utils/integration_tests_utils.py +0 -0
  146. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/integration/utils/licensing.py +0 -0
  147. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/__init__.py +0 -0
  148. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/conftest.py +0 -0
  149. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/test_constants.py +0 -0
  150. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/test_ddux.py +0 -0
  151. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/test_devel.py +0 -0
  152. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/test_non_dev_mode.py +0 -0
  153. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/test_settings.py +0 -0
  154. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/__init__.py +0 -0
  155. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/mwi/__init__.py +0 -0
  156. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/mwi/embedded_connector/__init__.py +0 -0
  157. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/mwi/embedded_connector/test_helpers.py +0 -0
  158. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/mwi/embedded_connector/test_request.py +0 -0
  159. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/mwi/test_custom_http_headers.py +0 -0
  160. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/mwi/test_logger.py +0 -0
  161. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/mwi/test_token_auth.py +0 -0
  162. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/mwi/test_validators.py +0 -0
  163. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/test_mw.py +0 -0
  164. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/unit/util/test_util.py +0 -0
  165. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/utils/__init__.py +0 -0
  166. {matlab-proxy-0.16.0 → matlab-proxy-0.17.0}/tests/utils/logging_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: matlab-proxy
3
- Version: 0.16.0
3
+ Version: 0.17.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.
@@ -175,6 +175,22 @@ function App () {
175
175
  }
176
176
  }
177
177
 
178
+ useEffect(() => {
179
+ const handlePageHide = (event) => {
180
+ // Performs actions before the component unloads
181
+ if (isConcurrencyEnabled && !isSessionConcurrent && hasFetchedServerStatus) {
182
+ // A POST request to clear the active client when the tab/browser is closed
183
+ navigator.sendBeacon('./clear_client_id');
184
+ }
185
+ event.preventDefault();
186
+ event.returnValue = '';
187
+ };
188
+ window.addEventListener('pagehide', handlePageHide);
189
+ return () => {
190
+ window.removeEventListener('pagehide', handlePageHide);
191
+ };
192
+ }, [isConcurrencyEnabled, isSessionConcurrent, hasFetchedServerStatus]);
193
+
178
194
  useEffect(() => {
179
195
  // Initial fetch environment configuration
180
196
  if (!hasFetchedEnvConfig) {
@@ -6,7 +6,6 @@ import mimetypes
6
6
  import pkgutil
7
7
  import secrets
8
8
  import sys
9
- import uuid
10
9
 
11
10
  import aiohttp
12
11
  from aiohttp import client_exceptions, web
@@ -97,16 +96,15 @@ def marshal_error(error):
97
96
 
98
97
 
99
98
  async def create_status_response(
100
- app, loadUrl=None, client_id=None, transfer_session=False, is_desktop=False
99
+ app, loadUrl=None, client_id=None, is_active_client=None
101
100
  ):
102
101
  """Send a generic status response about the state of server, MATLAB, MATLAB Licensing and the client session status.
103
102
 
104
103
  Args:
105
104
  app (aiohttp.web.Application): Web Server
106
105
  loadUrl (String, optional): Represents the root URL. Defaults to None.
107
- client_id (String, optional): Represents the unique client_id when concurrency check is enabled. Defaults to None.
108
- transfer_session (Boolean, optional): Represents whether the connection should be transfered or not when concurrency check is enabled. Defaults to False.
109
- is_desktop (Boolean, optional): Represents whether the request is made by the desktop app or some other kernel. Defaults to False.
106
+ client_id (String, optional): Represents the generated client_id when concurrency check is enabled and client does not have a client_id. Defaults to None.
107
+ is_active_client (Boolean, optional): Represents whether the current client is the active_client when concurrency check is enabled. Defaults to None.
110
108
 
111
109
  Returns:
112
110
  JSONResponse: A JSONResponse object containing the generic state of the server, MATLAB, MATLAB Licensing and the client session status.
@@ -124,17 +122,30 @@ async def create_status_response(
124
122
  "wsEnv": state.settings.get("ws_env", ""),
125
123
  }
126
124
 
127
- if IS_CONCURRENCY_CHECK_ENABLED and is_desktop:
128
- if not client_id:
129
- client_id = str(uuid.uuid4())
130
- status["clientId"] = client_id
125
+ if client_id:
126
+ status["clientId"] = client_id
127
+ if is_active_client is not None:
128
+ status["isActiveClient"] = is_active_client
131
129
 
132
- if not state.active_client or transfer_session:
133
- state.active_client = client_id
130
+ return web.json_response(status)
134
131
 
135
- status["isActiveClient"] = True if state.active_client == client_id else False
136
132
 
137
- return web.json_response(status)
133
+ @token_auth.authenticate_access_decorator
134
+ async def clear_client_id(req):
135
+ """API endpoint to reset the active client
136
+
137
+ Args:
138
+ req (HTTPRequest): HTTPRequest Object
139
+
140
+ Returns:
141
+ Response: an empty response in JSON format
142
+ """
143
+ # Sleep for one second prior to clearing the client id to ensure that any remaining get_status responses are fully processed first.
144
+ await asyncio.sleep(1)
145
+ state = req.app["state"]
146
+ state.active_client = None
147
+ # This response is of no relevance to the front-end as the client has already exited
148
+ return web.json_response({})
138
149
 
139
150
 
140
151
  @token_auth.authenticate_access_decorator
@@ -201,15 +212,17 @@ async def get_status(req):
201
212
  JSONResponse: JSONResponse object containing information about the server, MATLAB and MATLAB Licensing.
202
213
  """
203
214
  # The client sends the CLIENT_ID as a query parameter if the concurrency check has been set to true.
215
+ state = req.app["state"]
204
216
  client_id = req.query.get("MWI_CLIENT_ID", None)
205
217
  transfer_session = json.loads(req.query.get("TRANSFER_SESSION", "false"))
206
218
  is_desktop = req.query.get("IS_DESKTOP", False)
207
219
 
220
+ generated_client_id, is_active_client = state.get_session_status(
221
+ is_desktop, client_id, transfer_session
222
+ )
223
+
208
224
  return await create_status_response(
209
- req.app,
210
- client_id=client_id,
211
- transfer_session=transfer_session,
212
- is_desktop=is_desktop,
225
+ req.app, client_id=generated_client_id, is_active_client=is_active_client
213
226
  )
214
227
 
215
228
 
@@ -773,6 +786,8 @@ async def cleanup_background_tasks(app):
773
786
  # Stop any running async tasks
774
787
  logger = mwi.logger.get()
775
788
  tasks = state.tasks
789
+ if state.task_detect_client_status:
790
+ tasks["detect_client_status"] = state.task_detect_client_status
776
791
  for task_name, task in tasks.items():
777
792
  if not task.cancelled():
778
793
  logger.debug(f"Cancelling MWI task: {task_name} : {task} ")
@@ -868,6 +883,7 @@ def create_app(config_name=matlab_proxy.get_default_config_name()):
868
883
  app.router.add_route("GET", f"{base_url}/get_auth_token", get_auth_token)
869
884
  app.router.add_route("GET", f"{base_url}/get_env_config", get_env_config)
870
885
  app.router.add_route("PUT", f"{base_url}/start_matlab", start_matlab)
886
+ app.router.add_route("POST", f"{base_url}/clear_client_id", clear_client_id)
871
887
  app.router.add_route("DELETE", f"{base_url}/stop_matlab", stop_matlab)
872
888
  app.router.add_route("PUT", f"{base_url}/set_licensing_info", set_licensing_info)
873
889
  app.router.add_route("PUT", f"{base_url}/update_entitlement", update_entitlement)
@@ -9,11 +9,13 @@ import time
9
9
  from collections import deque
10
10
  from datetime import datetime, timedelta, timezone
11
11
  from typing import Final, Optional
12
+ import uuid
12
13
 
13
14
  from matlab_proxy import util
14
15
  from matlab_proxy.constants import (
15
16
  CONNECTOR_SECUREPORT_FILENAME,
16
17
  MATLAB_LOGS_FILE_NAME,
18
+ IS_CONCURRENCY_CHECK_ENABLED,
17
19
  )
18
20
  from matlab_proxy.settings import (
19
21
  get_process_startup_timeout,
@@ -103,6 +105,12 @@ class AppState:
103
105
  # connected to the backend
104
106
  self.active_client = None
105
107
 
108
+ # Used to detect whether the active client is actively sending out request or is inactive
109
+ self.active_client_request_detected = False
110
+
111
+ # An event loop task to handle the detection of client activity
112
+ self.task_detect_client_status = None
113
+
106
114
  def __get_cached_config_file(self):
107
115
  """Get the cached config file
108
116
 
@@ -1304,3 +1312,76 @@ class AppState:
1304
1312
  if err is not None:
1305
1313
  self.error = err
1306
1314
  log_error(logger, err)
1315
+
1316
+ def get_session_status(self, is_desktop, client_id, transfer_session):
1317
+ """
1318
+ Determines the session status for a client, potentially generating a new client ID.
1319
+
1320
+ This function is responsible for managing and tracking the session status of a client.
1321
+ It can generate a new client ID if one is not provided and the conditions are met.
1322
+ It also manages the active client status within the session, especially in scenarios
1323
+ involving desktop clients and when concurrency checks are enabled.
1324
+
1325
+ Args:
1326
+ is_desktop (bool): A flag indicating whether the client is a desktop client.
1327
+ client_id (str or None): The client ID. If None, a new client ID may be generated.
1328
+ transfer_session (bool): Indicates whether the session should be transferred to this client.
1329
+
1330
+ Returns:
1331
+ tuple:
1332
+ - A 2-tuple containing the generated client ID (or None if not generated) and
1333
+ a boolean indicating whether the client is considered the active client.
1334
+ - If concurrency checks are not enabled or the client is not a desktop client, it returns None for both
1335
+ the generated client ID and the active client status.
1336
+ """
1337
+ if IS_CONCURRENCY_CHECK_ENABLED and is_desktop:
1338
+ generated_client_id = None
1339
+ if not client_id:
1340
+ generated_client_id = str(uuid.uuid4())
1341
+ client_id = generated_client_id
1342
+
1343
+ if not self.active_client or transfer_session:
1344
+ self.active_client = client_id
1345
+
1346
+ if not self.task_detect_client_status:
1347
+ # Create the loop to detect the active status of the client
1348
+ loop = util.get_event_loop()
1349
+ self.task_detect_client_status = loop.create_task(
1350
+ self.detect_active_client_status()
1351
+ )
1352
+
1353
+ if self.active_client == client_id:
1354
+ is_active_client = True
1355
+ self.active_client_request_detected = True
1356
+ else:
1357
+ is_active_client = False
1358
+ return generated_client_id, is_active_client
1359
+ return None, None
1360
+
1361
+ async def detect_active_client_status(self, sleep_time=1, max_inactive_count=10):
1362
+ """Detects whether the client is online or not by continuously checking if the active client is making requests
1363
+
1364
+ Args:
1365
+ sleep_time (int): The time in seconds for which the process waits before checking for the next get_status request from the active client.
1366
+ max_inactive_count (int): The maximum number of times the check for the request from the active_client fails before reseting the active client id.
1367
+ """
1368
+ inactive_count = 0
1369
+ while self.active_client:
1370
+ # Check if the get_status request from the active client is received or not
1371
+ await asyncio.sleep(sleep_time)
1372
+ if self.active_client_request_detected:
1373
+ self.active_client_request_detected = False
1374
+ inactive_count = 0
1375
+ else:
1376
+ inactive_count = inactive_count + 1
1377
+ if inactive_count > max_inactive_count:
1378
+ # If no request is received from the active_client for more than 10 seconds then clear the active client id
1379
+ inactive_count = 0
1380
+ self.active_client = None
1381
+ if self.task_detect_client_status:
1382
+ try:
1383
+ # Self cleanup of the task
1384
+ self.task_detect_client_status.cancel()
1385
+ self.task_detect_client_status = None
1386
+ except Exception as e:
1387
+ logger.error("Cleaning of task: 'detect_client_status' failed.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: matlab-proxy
3
- Version: 0.16.0
3
+ Version: 0.17.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.
@@ -70,7 +70,7 @@ long_description = (HERE / "README.md").read_text()
70
70
 
71
71
  setuptools.setup(
72
72
  name="matlab-proxy",
73
- version="0.16.0",
73
+ version="0.17.0",
74
74
  url=config["doc_url"],
75
75
  author="The MathWorks, Inc.",
76
76
  author_email="cloud@mathworks.com",
@@ -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
 
@@ -584,3 +584,81 @@ async def test_start_matlab_without_xvfb(app_state_fixture, mocker):
584
584
  assert app_state_fixture.processes["xvfb"] is None
585
585
  # Check if Matlab started
586
586
  assert app_state_fixture.processes["matlab"] is mock_matlab
587
+
588
+
589
+ @pytest.mark.parametrize(
590
+ "is_desktop, client_id, is_client_id_present, expected_is_active_client",
591
+ [
592
+ (False, None, False, None),
593
+ (False, "mock_id", False, None),
594
+ (True, None, True, True),
595
+ (True, "mock_id", False, True),
596
+ ],
597
+ ids=[
598
+ "request_from_non-desktop_client",
599
+ "request_from_non-desktop_client_having_mock_id",
600
+ "request_from_desktop_client",
601
+ "request_from_desktop_client_having_mock_id",
602
+ ],
603
+ )
604
+ async def test_get_session_status(
605
+ app_state_fixture,
606
+ is_desktop,
607
+ client_id,
608
+ is_client_id_present,
609
+ expected_is_active_client,
610
+ ):
611
+ """Test to check if correnct session response is returned based on various conditions.
612
+
613
+ Args:
614
+ app_state_fixture (AppState): Object of AppState class with defaults set
615
+ is_desktop (bool): A flag indicating whether the client is a desktop client.
616
+ client_id (str or None): The client ID. If None, a new client ID may be generated.
617
+ is_client_id_present (bool): Indicates whether the expected value of client_id is string or not.
618
+ expected_is_active_client (bool): Indicates the expected value of is_active_client
619
+
620
+ """
621
+ # The value of transfer_session is a Don't Care condition as initially the value of client_id is always None.
622
+ output_client_id, output_is_active_client = app_state_fixture.get_session_status(
623
+ is_desktop, client_id, transfer_session=False
624
+ )
625
+ assert isinstance(output_client_id, str) == is_client_id_present, (
626
+ "Expected client_id to be a string got None"
627
+ if is_client_id_present
628
+ else "Expected client_id to be None got a string value"
629
+ )
630
+ assert (
631
+ output_is_active_client == expected_is_active_client
632
+ ), f"Expected is_active_client to be {expected_is_active_client} got {output_is_active_client}"
633
+ # For clean up of task_detect_client_status
634
+ app_state_fixture.active_client = None
635
+
636
+
637
+ async def test_get_session_status_can_transfer_session(app_state_fixture):
638
+ """Test to check whether transer session changes client id to the new id
639
+
640
+ Args:
641
+ app_state_fixture (AppState): Object of AppState class with defaults set
642
+ """
643
+ app_state_fixture.active_client = "mock_id"
644
+ app_state_fixture.get_session_status(
645
+ is_desktop=True, client_id="new_id", transfer_session=True
646
+ )
647
+ assert app_state_fixture.active_client == "new_id"
648
+ # For clean up of task_detect_client_status
649
+ app_state_fixture.active_client = None
650
+
651
+
652
+ async def test_detect_active_client_status_can_reset_active_client(app_state_fixture):
653
+ """Test to check whether the value of active client is being reset due to the client inactivity.
654
+
655
+ Args:
656
+ app_state_fixture (AppState): Object of AppState class with defaults set
657
+ """
658
+ app_state_fixture.active_client = "mock_id"
659
+ await app_state_fixture.detect_active_client_status(
660
+ sleep_time=0, max_inactive_count=0
661
+ )
662
+ assert (
663
+ app_state_fixture.active_client == None
664
+ ), f"Expected the active_client to be None"
File without changes
File without changes
File without changes
File without changes