iris-pex-embedded-python 3.5.1b2__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
iop/cls/IOP/Common.cls CHANGED
@@ -164,58 +164,22 @@ Method Connect() As %Status
164
164
  {
165
165
  set tSC = $$$OK
166
166
  try {
167
+ // Initialize Python class instance
168
+ $$$ThrowOnError(..InitializePythonClass())
167
169
 
168
- set container = $this
169
-
170
- // Before anything, try to check if the module is already present in the sys.modules
171
- set sys = ##class(%SYS.Python).Import("sys")
172
- set moduleName = ..%module
173
- set module = sys.modules.get(moduleName, $$$NULLOREF)
174
- if $isObject(module) {
175
- $$$LOGINFO("Module "_moduleName_" is already imported in sys.modules")
176
- // If the module is already present, we can skip the import
177
- set builtins = ##class(%SYS.Python).Import("builtins")
178
- set class = builtins.getattr(module, ..%classname)
179
- set ..%class = class."__new__"(class)
180
- }
181
- else {
182
-
183
- //set classpass
184
- if ..%classpaths '="" {
185
- set delimiter = $s($system.Version.GetOS()="Windows":";",1:":")
186
- set extraClasspaths = $tr(container.%classpaths,delimiter,"|")
187
- for i=1:1:$l(extraClasspaths,"|") {
188
- set onePath = $p(extraClasspaths,"|",i)
189
- set onePath = ##class(%File).NormalizeDirectory(onePath)
190
- do ..SetPythonPath(onePath)
191
- }
192
- }
193
-
194
- if $isObject(..%class)=0 {
195
- set builtins = ##class(%SYS.Python).Import("builtins")
196
- set module = ##class(%SYS.Python).Import(..%module)
197
- set class = builtins.getattr(module, ..%classname)
198
- set ..%class = class."__new__"(class)
199
- }
200
- }
201
-
202
- ;
203
- if ..%Extends("IOP.InboundAdapter") || ..%Extends("IOP.OutboundAdapter") {
204
- do ..%class."_set_iris_handles"($this,..BusinessHost)
205
- } elseif $this.%Extends("IOP.BusinessProcess") {
206
- do ..%class."_set_iris_handles"($this,$$$NULLOREF)
207
- } else {
208
- do ..%class."_set_iris_handles"($this,..Adapter)
209
- }
210
- ;
170
+ // Set IRIS handles based on component type
171
+ do ..SetIrisHandles()
172
+
173
+ // Apply property values to Python instance
211
174
  do ..SetPropertyValues()
212
- ;
175
+
176
+ // Notify Python class of connection
213
177
  try {
214
178
  do ..%class."_dispatch_on_connected"($this)
215
179
  } catch ex {
216
180
  $$$LOGWARNING(ex.DisplayString())
217
181
  }
218
- ;
182
+
219
183
  } catch ex {
220
184
  set msg = $System.Status.GetOneStatusText(ex.AsStatus(),1)
221
185
  set tSC = $$$ERROR($$$EnsErrGeneral,msg)
@@ -545,4 +509,61 @@ Method OnMsgGeneratorPoll(
545
509
  quit tSC
546
510
  }
547
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
+
548
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.1b2
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
@@ -54,7 +54,7 @@ iop/_utils.py,sha256=yAvssj3O3p9mLVJ_RvDIuawyYNhOIm5WrK0SANaSIwU,21256
54
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=GsFrrWY732-2Hzu5iiRS1C2Am_w2oDZmv-ZYa4Zeqy8,17769
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.1b2.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
82
- iris_pex_embedded_python-3.5.1b2.dist-info/METADATA,sha256=80F-3Ci14m0KlmqHejgX3iYgi_gk6fjLx5adBUfQE34,4415
83
- iris_pex_embedded_python-3.5.1b2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
84
- iris_pex_embedded_python-3.5.1b2.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
85
- iris_pex_embedded_python-3.5.1b2.dist-info/top_level.txt,sha256=4p0q6hCATmYIVMVi3I8hOUcJE1kwzyBeHygWv_rGvrU,13
86
- iris_pex_embedded_python-3.5.1b2.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,,