iris-pex-embedded-python 3.5.1b1__tar.gz → 3.5.1b3__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.

Potentially problematic release.


This version of iris-pex-embedded-python might be problematic. Click here for more details.

Files changed (93) hide show
  1. {iris_pex_embedded_python-3.5.1b1/src/iris_pex_embedded_python.egg-info → iris_pex_embedded_python-3.5.1b3}/PKG-INFO +1 -1
  2. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/pyproject.toml +1 -1
  3. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_debugpy.py +43 -1
  4. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/BusinessOperation.cls +4 -4
  5. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Common.cls +79 -44
  6. iris_pex_embedded_python-3.5.1b3/src/iop/cls/IOP/Wrapper.cls +58 -0
  7. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3/src/iris_pex_embedded_python.egg-info}/PKG-INFO +1 -1
  8. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iris_pex_embedded_python.egg-info/SOURCES.txt +1 -0
  9. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/LICENSE +0 -0
  10. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/README.md +0 -0
  11. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/setup.cfg +0 -0
  12. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/setup.py +0 -0
  13. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/__init__.py +0 -0
  14. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/BusinessOperation.cls +0 -0
  15. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/BusinessProcess.cls +0 -0
  16. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/BusinessService.cls +0 -0
  17. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/Common.cls +0 -0
  18. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/Director.cls +0 -0
  19. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/Duplex/Operation.cls +0 -0
  20. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/Duplex/Process.cls +0 -0
  21. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/Duplex/Service.cls +0 -0
  22. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/InboundAdapter.cls +0 -0
  23. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/Message.cls +0 -0
  24. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/OutboundAdapter.cls +0 -0
  25. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/PickleMessage.cls +0 -0
  26. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/PrivateSession/Duplex.cls +0 -0
  27. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/PrivateSession/Message/Ack.cls +0 -0
  28. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/PrivateSession/Message/Poll.cls +0 -0
  29. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/PrivateSession/Message/Start.cls +0 -0
  30. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/PrivateSession/Message/Stop.cls +0 -0
  31. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/Test.cls +0 -0
  32. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/PEX/Utils.cls +0 -0
  33. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/cls/Grongier/Service/WSGI.cls +0 -0
  34. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/pex/__init__.py +0 -0
  35. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/pex/__main__.py +0 -0
  36. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/pex/_business_host.py +0 -0
  37. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/pex/_cli.py +0 -0
  38. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/pex/_common.py +0 -0
  39. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/pex/_director.py +0 -0
  40. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/pex/_utils.py +0 -0
  41. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/grongier/pex/wsgi/handlers.py +0 -0
  42. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/__init__.py +0 -0
  43. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/__main__.py +0 -0
  44. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_async_request.py +0 -0
  45. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_business_host.py +0 -0
  46. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_business_operation.py +0 -0
  47. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_business_process.py +0 -0
  48. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_business_service.py +0 -0
  49. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_cli.py +0 -0
  50. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_common.py +0 -0
  51. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_decorators.py +0 -0
  52. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_director.py +0 -0
  53. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_dispatch.py +0 -0
  54. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_generator_request.py +0 -0
  55. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_inbound_adapter.py +0 -0
  56. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_iris.py +0 -0
  57. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_log_manager.py +0 -0
  58. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_message.py +0 -0
  59. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_message_validator.py +0 -0
  60. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_outbound_adapter.py +0 -0
  61. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_private_session_duplex.py +0 -0
  62. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_private_session_process.py +0 -0
  63. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_serialization.py +0 -0
  64. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/_utils.py +0 -0
  65. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/BusinessProcess.cls +0 -0
  66. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/BusinessService.cls +0 -0
  67. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Director.cls +0 -0
  68. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Duplex/Operation.cls +0 -0
  69. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Duplex/Process.cls +0 -0
  70. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Duplex/Service.cls +0 -0
  71. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Generator/Message/Ack.cls +0 -0
  72. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Generator/Message/Poll.cls +0 -0
  73. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Generator/Message/Start.cls +0 -0
  74. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Generator/Message/StartPickle.cls +0 -0
  75. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Generator/Message/Stop.cls +0 -0
  76. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/InboundAdapter.cls +0 -0
  77. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Message/JSONSchema.cls +0 -0
  78. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Message.cls +0 -0
  79. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/OutboundAdapter.cls +0 -0
  80. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/PickleMessage.cls +0 -0
  81. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/PrivateSession/Duplex.cls +0 -0
  82. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/PrivateSession/Message/Ack.cls +0 -0
  83. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/PrivateSession/Message/Poll.cls +0 -0
  84. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/PrivateSession/Message/Start.cls +0 -0
  85. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/PrivateSession/Message/Stop.cls +0 -0
  86. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Service/WSGI.cls +0 -0
  87. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Test.cls +0 -0
  88. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/cls/IOP/Utils.cls +0 -0
  89. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iop/wsgi/handlers.py +0 -0
  90. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iris_pex_embedded_python.egg-info/dependency_links.txt +0 -0
  91. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iris_pex_embedded_python.egg-info/entry_points.txt +0 -0
  92. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iris_pex_embedded_python.egg-info/requires.txt +0 -0
  93. {iris_pex_embedded_python-3.5.1b1 → iris_pex_embedded_python-3.5.1b3}/src/iris_pex_embedded_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris_pex_embedded_python
3
- Version: 3.5.1b1
3
+ Version: 3.5.1b3
4
4
  Summary: Iris Interoperability based on Embedded Python
5
5
  Author-email: grongier <guillaume.rongier@intersystems.com>
6
6
  License: MIT License
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
3
3
 
4
4
  [project]
5
5
  name = "iris_pex_embedded_python"
6
- version = "3.5.1b1"
6
+ version = "3.5.1b3"
7
7
  description = "Iris Interoperability based on Embedded Python"
8
8
  readme = "README.md"
9
9
  authors = [
@@ -142,4 +142,46 @@ def debugpython(self, host_object: Any) -> None:
142
142
  else:
143
143
  self.log_alert(f"Debugpy connection timed out after {host_object._timeout} seconds")
144
144
  except Exception as e:
145
- self.log_alert(f"Error enabling debugpy: {e}")
145
+ self.log_alert(f"Error enabling debugpy: {e}")
146
+
147
+ def debugpy_in_iris(iris_dir, port) -> bool:
148
+
149
+ if not hasattr(os, '__file__'):
150
+ setattr(os, '__file__', __file__)
151
+
152
+ if not is_debugpy_installed():
153
+ print("debugpy is not installed.")
154
+ return False
155
+ if not iris_dir:
156
+ print("IRIS directory is not specified.")
157
+ return False
158
+
159
+ import debugpy
160
+ python_path = _get_python_interpreter_path(mgr_dir_to_install_dir(iris_dir))
161
+ if not python_path:
162
+ return False
163
+ debugpy.configure(_get_debugpy_config(python_path))
164
+
165
+ try:
166
+ enable_debugpy(port=port)
167
+ except Exception as e:
168
+ print(f"Failed to enable debugpy: {e}")
169
+ return False
170
+
171
+ print(f"Debugpy is waiting for connection on port {port}...")
172
+ if wait_for_debugpy_connected(timeout=30, port=port):
173
+ print(f"Debugpy is connected on port {port}")
174
+ return True
175
+ else:
176
+ print(f"Debugpy connection timed out after 30 seconds on port {port}")
177
+ return False
178
+
179
+ def mgr_dir_to_install_dir(mgr_dir: str) -> Optional[str]:
180
+ """Convert manager directory to install directory."""
181
+ import os
182
+ if not mgr_dir:
183
+ return None
184
+ install_dir = os.path.dirname(os.path.dirname(mgr_dir))
185
+ if os.path.exists(install_dir):
186
+ return install_dir
187
+ return None
@@ -7,13 +7,13 @@ Class IOP.BusinessOperation Extends (Ens.BusinessOperation, IOP.Common) [ Inheri
7
7
 
8
8
  Parameter SETTINGS = "%classname:Python BusinessOperation,%module:Python BusinessOperation,%settings:Python BusinessOperation,%classpaths:Python BusinessOperation";
9
9
 
10
- Method OnMessage(
11
- request As %Library.Persistent,
12
- Output response As %Library.Persistent) As %Status
10
+ Method MessageHandler(
11
+ pRequest As %Library.Persistent,
12
+ Output pResponse As %Library.Persistent) As %Status
13
13
  {
14
14
  set tSC = $$$OK
15
15
  try {
16
- set response = ..%class."_dispatch_on_message"(request)
16
+ set pResponse = ..%class."_dispatch_on_message"(pRequest)
17
17
  } catch ex {
18
18
  set tSC = ..DisplayTraceback(ex)
19
19
  }
@@ -104,7 +104,6 @@ Method OnInit() As %Status
104
104
  set tSC = $$$OK
105
105
 
106
106
  try {
107
- LOCK +^PythonSettings:5
108
107
 
109
108
  if ..%Venv {
110
109
  $$$ThrowOnError(##class(IOP.Utils).SetPythonSettings(..%PythonRuntimeLibrary, ..%PythonPath, ..%PythonRuntimeLibraryVersion))
@@ -115,7 +114,6 @@ Method OnInit() As %Status
115
114
  do $system.Python.Debugging(..%traceback)
116
115
 
117
116
  $$$ThrowOnError(..Connect())
118
- LOCK -^PythonSettings
119
117
 
120
118
  do ..%class."_debugpy"($this)
121
119
 
@@ -124,7 +122,7 @@ Method OnInit() As %Status
124
122
 
125
123
  set tSC = ..DisplayTraceback(ex)
126
124
  }
127
- LOCK -^PythonSettings
125
+
128
126
  quit tSC
129
127
  }
130
128
 
@@ -147,61 +145,41 @@ ClassMethod SetPythonPath(pClasspaths)
147
145
  {
148
146
  set sys = ##class(%SYS.Python).Import("sys")
149
147
 
150
- for i=0:1:(sys.path."__len__"()-1) {
151
- Try {
152
- if sys.path."__getitem__"(i) = pClasspaths {
153
- do sys.path."__delitem__"(i)
154
- }
155
- }
156
- Catch ex {
157
- // do nothing
148
+ // Add the classpaths to the Python sys.path only if they are not already present
149
+ // Check if the path is already in sys.path
150
+ set found = 0
151
+ for j=1:1:sys.path."__len__"() {
152
+ if sys.path."__getitem__"(j-1) = pClasspaths {
153
+ set found = 1
154
+ quit
158
155
  }
159
-
160
156
  }
161
- do sys.path.insert(0, pClasspaths)
157
+ if found = 0 {
158
+ // If not found, add to sys.path
159
+ do sys.path."append"(pClasspaths)
160
+ }
162
161
  }
163
162
 
164
163
  Method Connect() As %Status
165
164
  {
166
165
  set tSC = $$$OK
167
166
  try {
167
+ // Initialize Python class instance
168
+ $$$ThrowOnError(..InitializePythonClass())
168
169
 
169
- set container = $this
170
+ // Set IRIS handles based on component type
171
+ do ..SetIrisHandles()
170
172
 
171
- //set classpass
172
- if ..%classpaths '="" {
173
- set delimiter = $s($system.Version.GetOS()="Windows":";",1:":")
174
- set extraClasspaths = $tr(container.%classpaths,delimiter,"|")
175
- for i=1:1:$l(extraClasspaths,"|") {
176
- set onePath = $p(extraClasspaths,"|",i)
177
- set onePath = ##class(%File).NormalizeDirectory(onePath)
178
- do ..SetPythonPath(onePath)
179
- }
180
- }
181
- if $isObject(..%class)=0 {
182
- set importlib = ##class(%SYS.Python).Import("importlib")
183
- set builtins = ##class(%SYS.Python).Import("builtins")
184
- set module = importlib."import_module"(..%module)
185
- set class = builtins.getattr(module, ..%classname)
186
- set ..%class = class."__new__"(class)
187
- }
188
- ;
189
- if ..%Extends("IOP.InboundAdapter") || ..%Extends("IOP.OutboundAdapter") {
190
- do ..%class."_set_iris_handles"($this,..BusinessHost)
191
- } elseif $this.%Extends("IOP.BusinessProcess") {
192
- do ..%class."_set_iris_handles"($this,$$$NULLOREF)
193
- } else {
194
- do ..%class."_set_iris_handles"($this,..Adapter)
195
- }
196
- ;
173
+ // Apply property values to Python instance
197
174
  do ..SetPropertyValues()
198
- ;
175
+
176
+ // Notify Python class of connection
199
177
  try {
200
178
  do ..%class."_dispatch_on_connected"($this)
201
179
  } catch ex {
202
180
  $$$LOGWARNING(ex.DisplayString())
203
181
  }
204
- ;
182
+
205
183
  } catch ex {
206
184
  set msg = $System.Status.GetOneStatusText(ex.AsStatus(),1)
207
185
  set tSC = $$$ERROR($$$EnsErrGeneral,msg)
@@ -352,9 +330,9 @@ ClassMethod OnGetConnections(
352
330
  if onePath'="" do sys.path.append(onePath)
353
331
  }
354
332
  }
355
- set importlib = ##class(%SYS.Python).Import("importlib")
333
+
356
334
  set builtins = ##class(%SYS.Python).Import("builtins")
357
- set module = importlib."import_module"(tModule)
335
+ set module = ##class(%SYS.Python).Import(tModule)
358
336
  set class = builtins.getattr(module, tClassname)
359
337
  set tClass = class."__new__"(class)
360
338
 
@@ -531,4 +509,61 @@ Method OnMsgGeneratorPoll(
531
509
  quit tSC
532
510
  }
533
511
 
512
+ Method InitializePythonClass() As %Status [ Private ]
513
+ {
514
+ set tSC = $$$OK
515
+ try {
516
+ // Check if module is already imported
517
+ set sys = ##class(%SYS.Python).Import("sys")
518
+ set module = sys.modules.get(..%module, $$$NULLOREF)
519
+
520
+ if $isObject(module) {
521
+ $$$LOGINFO("Module "_..%module_" is already imported in sys.modules")
522
+ set ..%class = ..CreateClassInstance(module)
523
+ } else {
524
+ // Setup classpaths if specified
525
+ if ..%classpaths '= "" {
526
+ do ..SetupClasspaths()
527
+ }
528
+
529
+ // Import module and create class instance
530
+ set module = ##class(%SYS.Python).Import(..%module)
531
+ set ..%class = ..CreateClassInstance(module)
532
+ }
533
+ } catch ex {
534
+ set tSC = ex.AsStatus()
535
+ }
536
+ quit tSC
537
+ }
538
+
539
+ Method CreateClassInstance(module As %SYS.Python) As %SYS.Python [ Private ]
540
+ {
541
+ set builtins = ##class(%SYS.Python).Import("builtins")
542
+ set class = builtins.getattr(module, ..%classname)
543
+ quit class."__new__"(class)
544
+ }
545
+
546
+ Method SetupClasspaths() [ Private ]
547
+ {
548
+ set delimiter = $s($system.Version.GetOS()="Windows":";",1:":")
549
+ set extraClasspaths = $tr(..%classpaths, delimiter, "|")
550
+
551
+ for i=1:1:$l(extraClasspaths,"|") {
552
+ set onePath = $p(extraClasspaths,"|",i)
553
+ set onePath = ##class(%File).NormalizeDirectory(onePath)
554
+ do ..SetPythonPath(onePath)
555
+ }
556
+ }
557
+
558
+ Method SetIrisHandles() [ Private ]
559
+ {
560
+ if ..%Extends("IOP.InboundAdapter") || ..%Extends("IOP.OutboundAdapter") {
561
+ do ..%class."_set_iris_handles"($this, ..BusinessHost)
562
+ } elseif $this.%Extends("IOP.BusinessProcess") {
563
+ do ..%class."_set_iris_handles"($this, $$$NULLOREF)
564
+ } else {
565
+ do ..%class."_set_iris_handles"($this, ..Adapter)
566
+ }
567
+ }
568
+
534
569
  }
@@ -0,0 +1,58 @@
1
+ Class IOP.Wrapper Extends %RegisteredObject
2
+ {
3
+
4
+ ClassMethod Import(
5
+ moduleName As %String,
6
+ path As %String = "",
7
+ debugPort As %Integer = 0) As %Status
8
+ {
9
+ set tSC = $$$OK
10
+ Try {
11
+ do ##class(IOP.Common).SetPythonPath(path)
12
+ // For traceback debugging
13
+ do $system.Python.Debugging(1)
14
+ if debugPort > 0 {
15
+
16
+ set debugpy = ##class(%SYS.Python).Import("iop._debugpy")
17
+ do debugpy."debugpy_in_iris"($zu(12),debugPort)
18
+ }
19
+
20
+ // Import the module
21
+ set tModule = ##class(%SYS.Python).Import(moduleName)
22
+
23
+ }
24
+ Catch ex {
25
+ Set tSC= ##class(IOP.Wrapper).DisplayTraceback(ex)
26
+ throw ex
27
+ }
28
+ return tModule
29
+ }
30
+
31
+ ClassMethod DisplayTraceback(ex) As %Status
32
+ {
33
+ set tSC = ex.AsStatus()
34
+
35
+ // Import Modules
36
+ set sys = ##class(%SYS.Python).Import("sys")
37
+ set tracebackModule = ##class(%SYS.Python).Import("traceback")
38
+ set builtins = ##class(%SYS.Python).Import("builtins")
39
+ // Get the last traceback
40
+ set traceback = sys."last_traceback"
41
+ set exType = sys."last_type"."__name__"
42
+ set exValue = sys."last_value"."__str__"()
43
+ // Check if traceback is an object
44
+ if $isObject(traceback) {
45
+ // Format the traceback
46
+ set tb = tracebackModule."format_exception"(sys."last_type", sys."last_value", traceback)
47
+ set tbString = ""
48
+ for i=0:1:(tb."__len__"()-1) {
49
+ set tbString = tbString _ $c(10)_$c(13) _ tb."__getitem__"(i)
50
+ }
51
+ w tbString
52
+ set tSC = $$$ERROR("Exception in Python - "_exType_" - "_exValue)
53
+ }
54
+
55
+ return tSC
56
+ }
57
+
58
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris_pex_embedded_python
3
- Version: 3.5.1b1
3
+ Version: 3.5.1b3
4
4
  Summary: Iris Interoperability based on Embedded Python
5
5
  Author-email: grongier <guillaume.rongier@intersystems.com>
6
6
  License: MIT License
@@ -66,6 +66,7 @@ src/iop/cls/IOP/OutboundAdapter.cls
66
66
  src/iop/cls/IOP/PickleMessage.cls
67
67
  src/iop/cls/IOP/Test.cls
68
68
  src/iop/cls/IOP/Utils.cls
69
+ src/iop/cls/IOP/Wrapper.cls
69
70
  src/iop/cls/IOP/Duplex/Operation.cls
70
71
  src/iop/cls/IOP/Duplex/Process.cls
71
72
  src/iop/cls/IOP/Duplex/Service.cls