iris-pex-embedded-python 3.5.1b1__py3-none-any.whl → 3.5.1b3__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 iris-pex-embedded-python might be problematic. Click here for more details.

iop/_debugpy.py CHANGED
@@ -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
  }
iop/cls/IOP/Common.cls CHANGED
@@ -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
@@ -36,7 +36,7 @@ iop/_business_process.py,sha256=2W4tA8kPGrKp2bP0RVkXR8JSiVnSKCUgN24mDmPkJEU,8548
36
36
  iop/_business_service.py,sha256=UGZ-bxbEzec9z6jf-pKIaLo8BL-V1D2aqJGZM9m37qo,3984
37
37
  iop/_cli.py,sha256=FJGPcJKEKKph3XIJgDGUF-QpE_DMt7YSO8G7yYD9UnI,8046
38
38
  iop/_common.py,sha256=W39gb-K7oh93YdxOIIud0TT64Z6dSogVT4Rpda7_IvU,13986
39
- iop/_debugpy.py,sha256=67BC1jxZx4MZfj65trYYnSJ_MVKMTv49n3CqqfgVQdk,4725
39
+ iop/_debugpy.py,sha256=EJ3XK29cDQ1mBklEgUwG6HyHYJAmhVa3-8m_FvtbVOs,6008
40
40
  iop/_decorators.py,sha256=LpK0AK4GIzXbPFSIw_x6zzM3FwsHvFjgQUh-MnqtTE8,2322
41
41
  iop/_director.py,sha256=dJ4uLs5JxBS1wc0OtL25HuaDi3Jh8M9JC5Ra366ic1g,11489
42
42
  iop/_dispatch.py,sha256=eXElnLGLdc6ondZhTQtKfa7URMkT-QnmqOTwXBSXAsY,4650
@@ -51,10 +51,10 @@ iop/_private_session_duplex.py,sha256=c6Q0k-qnZi_JcIOdpUx1Edu44zVbUE2Kf2aCHM8Eq8
51
51
  iop/_private_session_process.py,sha256=rvZFO6nWVwZtaEWJkSHyLTV-vhzDqQhsVi7INQLLwWI,1685
52
52
  iop/_serialization.py,sha256=C9-88bb6vC8A4ugQ3QqjahAbv7NjAD2sZy8_D-X0Ois,7721
53
53
  iop/_utils.py,sha256=yAvssj3O3p9mLVJ_RvDIuawyYNhOIm5WrK0SANaSIwU,21256
54
- iop/cls/IOP/BusinessOperation.cls,sha256=E4rnujZi3QFd3uLtZ5YjLiMU_FWoN1gkBe19kxmYO34,932
54
+ iop/cls/IOP/BusinessOperation.cls,sha256=td4tFxy9KbZ6u5QEr9xCuCNjcqEJavdeYHErNrt-szk,941
55
55
  iop/cls/IOP/BusinessProcess.cls,sha256=XJxzbiV0xokzRm-iI2Be5UIJLE3MlXr7W3WS_LkOCYs,3363
56
56
  iop/cls/IOP/BusinessService.cls,sha256=fplKrbQgA7cQgjKIqDR2IK2iD1iNHmT-QvWrozhE4n4,1189
57
- iop/cls/IOP/Common.cls,sha256=lRnvXarMTyHWgtqtQjF84mAtYYPViiem-m5riB-RYZw,17149
57
+ iop/cls/IOP/Common.cls,sha256=z5pswzclKqPQ7EzObLcfOcKK-M9Dcf3BXrO3PlL81f8,18010
58
58
  iop/cls/IOP/Director.cls,sha256=M43LoTb6lwSr0J81RFxi1YLW1mwda09wQ7Xqr3nBtxo,2008
59
59
  iop/cls/IOP/InboundAdapter.cls,sha256=H-gZfUy8M9YxAZXfp5HVYl3uLo-7Xg9YgojioB_eYMY,619
60
60
  iop/cls/IOP/Message.cls,sha256=6_iZzQaY0cA9FjXg0qECYZC6We8soAIrUwRBrlerC4w,25373
@@ -62,6 +62,7 @@ iop/cls/IOP/OutboundAdapter.cls,sha256=OQoGFHUy2qV_kcsShTlWGOngDrdH5dhwux4eopZyI
62
62
  iop/cls/IOP/PickleMessage.cls,sha256=S3y7AClQ8mAILjxPuHdCjGosBZYzGbUQ5WTv4mYPNMQ,1673
63
63
  iop/cls/IOP/Test.cls,sha256=gAC9PEfMZsvAEWIa241-ug2FWAhITbN1SOispZzJPnI,2094
64
64
  iop/cls/IOP/Utils.cls,sha256=NGnfi2Kif3OyYwR6pm5c_-UKm5vEwQyfzvJpZGxFeeA,18546
65
+ iop/cls/IOP/Wrapper.cls,sha256=37fUol-EcktdfGhpfi4o12p04975lKGaRYEFhw-fuaM,1614
65
66
  iop/cls/IOP/Duplex/Operation.cls,sha256=K_fmgeLjPZQbHgNrc0kd6DUQoW0fDn1VHQjJxHo95Zk,525
66
67
  iop/cls/IOP/Duplex/Process.cls,sha256=xbefZ4z84a_IUhavWN6P_gZBzqkdJ5XRTXxro6iDvAg,6986
67
68
  iop/cls/IOP/Duplex/Service.cls,sha256=sTMOQUCMBgVitmQkM8bbsrmrRtCdj91VlctJ3I7b8WU,161
@@ -78,9 +79,9 @@ iop/cls/IOP/PrivateSession/Message/Start.cls,sha256=RsJLrhglrONBDGT0RqW2K9MDXa98
78
79
  iop/cls/IOP/PrivateSession/Message/Stop.cls,sha256=7g3gKFUjNg0WXBLuWnj-VnCs5G6hSE09YTzGEp0zbGc,1390
79
80
  iop/cls/IOP/Service/WSGI.cls,sha256=VLNCXEwmHW9dBnE51uGE1nvGX6T4HjhqePT3LVhsjAE,10440
80
81
  iop/wsgi/handlers.py,sha256=NrFLo_YbAh-x_PlWhAiWkQnUUN2Ss9HoEm63dDWCBpQ,2947
81
- iris_pex_embedded_python-3.5.1b1.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
82
- iris_pex_embedded_python-3.5.1b1.dist-info/METADATA,sha256=0JwhOA7L2CteIK4EfvFBiEFR3rS6tDO1QAyuHJi77wk,4415
83
- iris_pex_embedded_python-3.5.1b1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
84
- iris_pex_embedded_python-3.5.1b1.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
85
- iris_pex_embedded_python-3.5.1b1.dist-info/top_level.txt,sha256=4p0q6hCATmYIVMVi3I8hOUcJE1kwzyBeHygWv_rGvrU,13
86
- iris_pex_embedded_python-3.5.1b1.dist-info/RECORD,,
82
+ iris_pex_embedded_python-3.5.1b3.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
83
+ iris_pex_embedded_python-3.5.1b3.dist-info/METADATA,sha256=3kiGbRy7HjWhzMGcyNba6jbgEiskLUwtrK5Wm6IxLBM,4415
84
+ iris_pex_embedded_python-3.5.1b3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
85
+ iris_pex_embedded_python-3.5.1b3.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
86
+ iris_pex_embedded_python-3.5.1b3.dist-info/top_level.txt,sha256=4p0q6hCATmYIVMVi3I8hOUcJE1kwzyBeHygWv_rGvrU,13
87
+ iris_pex_embedded_python-3.5.1b3.dist-info/RECORD,,