iris-pex-embedded-python 3.1.1b3__py3-none-any.whl → 3.1.1b5__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/_business_host.py CHANGED
@@ -266,8 +266,8 @@ class _BusinessHost(_Common):
266
266
  msg = iris.cls('IOP.Message')._New()
267
267
  msg.classname = module + "." + classname
268
268
 
269
- if hasattr(message, 'buffer') and len(json_string) > msg.buffer:
270
- msg.json = _Utils.string_to_stream(json_string)
269
+ if hasattr(msg, 'buffer') and len(json_string) > msg.buffer:
270
+ msg.json = _Utils.string_to_stream(json_string,msg.buffer)
271
271
  else:
272
272
  msg.json = json_string
273
273
 
iop/_director.py CHANGED
@@ -258,9 +258,9 @@ class _Director():
258
258
  message = iris.cls("IOP.Message")._New()
259
259
  message.classname = classname
260
260
  if body:
261
- message.jstr = _Utils.string_to_stream(body)
261
+ message.json = _Utils.string_to_stream(body)
262
262
  else:
263
- message.jstr = _Utils.string_to_stream("{}")
263
+ message.json = _Utils.string_to_stream("{}")
264
264
  # serialize the message
265
265
  business_host = _BusinessHost()
266
266
  serial_message = business_host._dispatch_serializer(message)
iop/_utils.py CHANGED
@@ -1,9 +1,11 @@
1
1
  import os
2
+ import sys
2
3
  import ast
3
4
  import iris
4
5
  import inspect
5
6
  import xmltodict
6
7
  import pkg_resources
8
+ import importlib
7
9
 
8
10
  class _Utils():
9
11
  @staticmethod
@@ -174,7 +176,7 @@ class _Utils():
174
176
  return module
175
177
 
176
178
  @staticmethod
177
- def migrate(filename=None,root_path=None):
179
+ def migrate(filename=None):
178
180
  """
179
181
  Read the settings.py file and register all the components
180
182
  settings.py file has two dictionaries:
@@ -186,18 +188,21 @@ class _Utils():
186
188
  * key: the name of the production
187
189
  * value: a dictionary containing the settings for the production
188
190
  """
191
+ path = None
189
192
  # try to load the settings file
190
193
  if filename:
191
- import sys
192
- path = None
193
194
  # check if the filename is absolute or relative
194
195
  if os.path.isabs(filename):
195
196
  path = os.path.dirname(filename)
196
197
  else:
197
198
  raise ValueError("The filename must be absolute")
198
- # add the path to the system path
199
- sys.path.append(path)
200
- import settings
199
+ # add the path to the system path to the beginning
200
+ sys.path.insert(0,os.path.normpath(path))
201
+ # import settings from the specified file
202
+ settings = _Utils.import_module_from_path('settings',filename)
203
+ else:
204
+ # import settings from the settings module
205
+ import settings
201
206
  # get the path of the settings file
202
207
  path = os.path.dirname(inspect.getfile(settings))
203
208
  try:
@@ -210,8 +215,26 @@ class _Utils():
210
215
  _Utils.set_productions_settings(settings.PRODUCTIONS,path)
211
216
  except AttributeError:
212
217
  print("No productions to register")
218
+ try:
219
+ # remove the path from the system path (with or without the trailing slash)
220
+ sys.path.remove(path+'/')
221
+ sys.path.remove(path)
222
+ except ValueError:
223
+ pass
213
224
 
214
-
225
+ @staticmethod
226
+ def import_module_from_path(module_name, file_path):
227
+ if not os.path.isabs(file_path):
228
+ raise ValueError("The file path must be absolute")
229
+
230
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
231
+ if spec is None:
232
+ raise ImportError(f"Cannot find module named {module_name} at {file_path}")
233
+
234
+ module = importlib.util.module_from_spec(spec)
235
+ sys.modules[module_name] = module
236
+ spec.loader.exec_module(module)
237
+ return module
215
238
 
216
239
  @staticmethod
217
240
  def set_classes_settings(class_items,root_path=None):
@@ -360,17 +383,17 @@ class _Utils():
360
383
  return data
361
384
 
362
385
  @staticmethod
363
- def stream_to_string(stream)-> str:
386
+ def stream_to_string(stream,buffer=1000000)-> str:
364
387
  string = ""
365
388
  stream.Rewind()
366
389
  while not stream.AtEnd:
367
- string += stream.Read(4092)
390
+ string += stream.Read(buffer)
368
391
  return string
369
392
 
370
393
  @staticmethod
371
- def string_to_stream(string:str):
394
+ def string_to_stream(string:str,buffer=1000000):
372
395
  stream = iris.cls('%Stream.GlobalCharacter')._New()
373
- n = 4092
396
+ n = buffer
374
397
  chunks = [string[i:i+n] for i in range(0, len(string), n)]
375
398
  for chunk in chunks:
376
399
  stream.Write(chunk)
iop/cls/IOP/Message.cls CHANGED
@@ -5,7 +5,7 @@
5
5
  Class IOP.Message Extends (Ens.MessageBody, %CSP.Page, %XML.Adaptor)
6
6
  {
7
7
 
8
- Parameter BUFFER = 64000;
8
+ Parameter BUFFER = 1000000;
9
9
 
10
10
  Property buffer As %String(MAXLEN = "") [ Calculated, Transient ];
11
11
 
@@ -15,9 +15,9 @@ Property jsonObject As %DynamicObject(XMLPROJECTION = "None");
15
15
 
16
16
  Property json As %String(MAXLEN = "");
17
17
 
18
- Property jsonStream As %Stream.GlobalCharacter [ Internal, ReadOnly ];
18
+ Property jsonStream As %Stream.GlobalCharacter [ Internal, Private ];
19
19
 
20
- Property jsonString As %String(MAXLEN = 64000) [ Internal, ReadOnly ];
20
+ Property jsonString As %String(MAXLEN = 1000000) [ Internal, Private ];
21
21
 
22
22
  Property jstr As %Stream.GlobalCharacter [ Internal, Private ];
23
23
 
@@ -80,13 +80,25 @@ Method jsonSet(pInput) As %Status
80
80
  , :$$$NULLOREF)
81
81
  Quit:tOldStream=pInput $$$OK
82
82
  Do:..type'="" Clear() Set i%type=""
83
- If $ISOBJECT(pInput) && pInput.%Extends("%Stream.GlobalCharacter") {
84
- Set r%jsonStream=pInput, i%type="Stream"
85
- }
86
- If $IsObject(pInput) && 'pInput.%Extends("%Stream.GlobalCharacter") {
87
- Throw ##class(%Exception.General).%New("Invalid input type, must be a %Stream.GlobalCharacter")
83
+
84
+ If $ISOBJECT(pInput) {
85
+ if pInput.%Extends("%Stream.GlobalCharacter") {
86
+ Set ..jsonStream=pInput, i%type="Stream"
87
+ }
88
+ else {
89
+ Throw ##class(%Exception.General).%New("Invalid input type, must be a %Stream.GlobalCharacter or a %String")
90
+ }
88
91
  }
89
- Else {
92
+ Else {
93
+ if $LENGTH(pInput)>..#BUFFER {
94
+ // write in a stream
95
+ Set stream = ##class(%Stream.GlobalCharacter).%New()
96
+ for i=1:..#BUFFER:$LENGTH(pInput) {
97
+ Set sc = stream.Write($EXTRACT(pInput,i,(i+..#BUFFER)))
98
+ Quit:$$$ISERR(sc)
99
+ }
100
+ Set ..jsonStream=stream, i%type="Stream"
101
+ }
90
102
  Set i%jsonString=pInput, i%type="String"
91
103
  }
92
104
  Quit $$$OK
iop/cls/IOP/Test.cls CHANGED
@@ -3,7 +3,7 @@ Class IOP.Test Extends %Persistent
3
3
  {
4
4
 
5
5
  /// Description
6
- ClassMethod TEST() As %Status
6
+ ClassMethod TestJsonStringMessage() As %Status
7
7
  {
8
8
  set msg = ##class(IOP.Message).%New()
9
9
  set msg.classname = "IOP.Message"
@@ -13,6 +13,18 @@ ClassMethod TEST() As %Status
13
13
  QUIT $$$OK
14
14
  }
15
15
 
16
+ ClassMethod TestJsonStreamMessage() As %Status
17
+ {
18
+ set msg = ##class(IOP.Message).%New()
19
+ set msg.classname = "IOP.Message"
20
+ set stream = ##class(%Stream.GlobalCharacter).%New()
21
+ set sc = stream.Write("{""name"":""John""}")
22
+ set msg.json = stream
23
+ set tset = msg.json
24
+ set tst = msg.jstr
25
+ QUIT $$$OK
26
+ }
27
+
16
28
  /// Register
17
29
  ClassMethod Register() As %Status
18
30
  {
iop/cls/IOP/Utils.cls CHANGED
@@ -104,12 +104,10 @@ ClassMethod GetRemoteClassInfo(
104
104
  pModule As %String,
105
105
  pClasspaths As %String,
106
106
  ByRef pClassDetails,
107
- ByRef pRemoteSettings) As %Status [ Internal, Private ]
107
+ ByRef pRemoteSettings) As %Status [ Internal ]
108
108
  {
109
109
  #dim tSC As %Status = $$$OK
110
110
  #dim ex As %Exception.AbstractException
111
- #dim tGateway As %External.Gateway
112
- #dim tGatewayProxy As %Net.Remote.Object
113
111
 
114
112
  Try {
115
113
  if pClasspaths '="" {
@@ -120,14 +118,19 @@ ClassMethod GetRemoteClassInfo(
120
118
  set onePath = $p(extraClasspaths,"|",i)
121
119
  set onePath = ##class(%File).NormalizeDirectory(onePath)
122
120
  if onePath?1"$$IRISHOME"1P.E set onePath = $e($system.Util.InstallDirectory(),1,*-1)_$e(onePath,11,*)
123
- if onePath'="" do sys.path.append(onePath)
121
+ if onePath'="" do ##class(IOP.Common).SetPythonPath(onePath)
124
122
  }
125
123
  }
126
- ;
127
124
 
128
125
  set importlib = ##class(%SYS.Python).Import("importlib")
129
126
  set builtins = ##class(%SYS.Python).Import("builtins")
130
- set module = importlib."import_module"(pModule)
127
+ set sys = ##class(%SYS.Python).Import("sys")
128
+ // Load the module form a specific path
129
+ set spec = importlib.util."spec_from_file_location"(pModule, onePath_pModule_".py")
130
+ set module = importlib.util."module_from_spec"(spec)
131
+ do sys.modules."__setitem__"(pModule, module)
132
+ do spec.loader."exec_module"(module)
133
+ // Get the class
131
134
  set class = builtins.getattr(module, pRemoteClassname)
132
135
  set tClass = class."__new__"(class)
133
136
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iris_pex_embedded_python
3
- Version: 3.1.1b3
3
+ Version: 3.1.1b5
4
4
  Summary: Iris Interoperability based on Embedded Python
5
5
  Author-email: grongier <guillaume.rongier@intersystems.com>
6
6
  License: MIT License
@@ -43,9 +43,9 @@ Classifier: Programming Language :: Python :: 3.11
43
43
  Classifier: Topic :: Utilities
44
44
  Description-Content-Type: text/markdown
45
45
  License-File: LICENSE
46
- Requires-Dist: dacite >=1.6.0
47
- Requires-Dist: xmltodict >=0.12.0
48
- Requires-Dist: iris-embedded-python-wrapper >=0.0.6
46
+ Requires-Dist: dacite>=1.6.0
47
+ Requires-Dist: xmltodict>=0.12.0
48
+ Requires-Dist: iris-embedded-python-wrapper>=0.0.6
49
49
 
50
50
  # 1. interoperability-embedded-python
51
51
 
@@ -92,31 +92,31 @@ intersystems_iris/pex/_OutboundAdapter.py,sha256=ao2Ubbta2DcrQGdzDUD_j1Zsk8bvUfc
92
92
  intersystems_iris/pex/__init__.py,sha256=l_I1dpnluWawbFrGMDC0GLHpuHwjbpd-nho8otFX6TE,1379
93
93
  iop/__init__.py,sha256=zHFF0Znipx1fwHYUEBZjNOYoZH1ro7z4IgYDU32kdn0,1067
94
94
  iop/__main__.py,sha256=pQzVtkDhAeI6dpNRC632dVk2SGZZIEDwDufdgZe8VWs,98
95
- iop/_business_host.py,sha256=2_3deKEOQxXuy8dw0rT8l_GoLQls5mS0SA4SuHPzd94,28237
95
+ iop/_business_host.py,sha256=_U7f2Fy-7_qzBz4OQTAieVvEhBaT1Z0E77QoYPU0i-U,28244
96
96
  iop/_business_operation.py,sha256=P824IzO89LCKnoNHZk64OZBDHcomHpjhKmMT89bS6TI,3500
97
97
  iop/_business_process.py,sha256=F4NIQcwQ5u8yiAPpaN14OAXxbKJsRAGm5S4lrbgA3oI,13296
98
98
  iop/_business_service.py,sha256=sX8J-2-0Go6uIuPYa0A5N9Nn9rY5lV6a05v4q78qDC8,3726
99
99
  iop/_cli.py,sha256=yg4wv1FkhgjmoZuTMUr61Ff21PegJDH_cpZeHcF8hQE,6207
100
100
  iop/_common.py,sha256=uKJdfCSPOjVQOg8GVuUj4ywfAn_2sPB3C82HbWw_5bI,15384
101
- iop/_director.py,sha256=CSNQPS4JPB3O4mXzsBj5L0Dcdciu1dm8ZtoHtnZCBTY,11041
101
+ iop/_director.py,sha256=t4hBkYRUFwkNFNK6pCmrVVsPELlGYqvSsSNBPIJe1e8,11041
102
102
  iop/_inbound_adapter.py,sha256=PS5ToqhrYcXq9ZdLbCBqAfVp8kCeRACm_KF66pwBO9U,1652
103
103
  iop/_message.py,sha256=BmwBXriykU66bwAgRbdkMpjfJRVWoNRX2eDc9TXfXzA,325
104
104
  iop/_outbound_adapter.py,sha256=YTAhLrRf9chEAd53mV6KKbpaHOKNOKJHoGgj5wakRR0,726
105
105
  iop/_pickle_message.py,sha256=noKfc2VkXufV3fqjKvNHN_oANQ1YN9ffCaSV0XSTAIE,331
106
106
  iop/_private_session_duplex.py,sha256=klzWKwRRBoKUSz85D3DNYuCpDcZe_kWLNCWq5JtR0yc,5044
107
107
  iop/_private_session_process.py,sha256=pGjWFOQhWpQxUVpTtvNKTPvDxgzjfw0VC4Aqj3KUq8w,1704
108
- iop/_utils.py,sha256=3rhO33PLZ1ESJiboQFwfIGUvHV7RBSbq6A2CPyMaojA,16269
108
+ iop/_utils.py,sha256=-s1i_bZlmrcXm732A3VjzRNaZWf6vVT31v04-gMmNDQ,17291
109
109
  iop/cls/IOP/BusinessOperation.cls,sha256=lrymqZ8wHl5kJjXwdjbQVs5sScV__yIWGh-oGbiB_X0,914
110
110
  iop/cls/IOP/BusinessProcess.cls,sha256=s3t38w1ykHqM26ETcbCYLt0ocjZyVVahm-_USZkuJ1E,2855
111
111
  iop/cls/IOP/BusinessService.cls,sha256=7ebn32J9PiZXUgXuh5Xxm_7X6zHBiqkJr9c_dWxbPO8,1021
112
112
  iop/cls/IOP/Common.cls,sha256=vYTnsL-ch-vTjpigBtwOHgrnOQMmuTkqXT9F-vWE650,11068
113
113
  iop/cls/IOP/Director.cls,sha256=DlxyFvsJjB1FVImFVNkRpQy7XXIMRoDZOLpEdMlwgOU,1885
114
114
  iop/cls/IOP/InboundAdapter.cls,sha256=GeoCm6q5HcLJ5e4VxgqXiErJXqolBbpKwpunaNzpvjU,610
115
- iop/cls/IOP/Message.cls,sha256=DXXYF57YS-IQAyru8MQiEBo9UE3vgn6518_yVl2BepE,9660
115
+ iop/cls/IOP/Message.cls,sha256=n0r0FslXdDfPcHIiAlW7n596DDsDSNlTX8UTPaMnSV8,9911
116
116
  iop/cls/IOP/OutboundAdapter.cls,sha256=9eOwy5ojwcTzwrHs6LNrFQvUD8aqcoNCZrILN1ycdDM,958
117
117
  iop/cls/IOP/PickleMessage.cls,sha256=S3y7AClQ8mAILjxPuHdCjGosBZYzGbUQ5WTv4mYPNMQ,1673
118
- iop/cls/IOP/Test.cls,sha256=I11dVr44_XKgg-i_JvgPq9AeHwNnlfD226bgM5MSx7E,1775
119
- iop/cls/IOP/Utils.cls,sha256=VwIeWxbeC6LkoDuBN0vhias-pkeLp7mbcC_4MPnzQ8g,13757
118
+ iop/cls/IOP/Test.cls,sha256=gAC9PEfMZsvAEWIa241-ug2FWAhITbN1SOispZzJPnI,2094
119
+ iop/cls/IOP/Utils.cls,sha256=UgSEH2gqiNKYK_NAc2QUXF0A0VXHK-vbwWsHplHV2T8,13994
120
120
  iop/cls/IOP/Duplex/Operation.cls,sha256=K_fmgeLjPZQbHgNrc0kd6DUQoW0fDn1VHQjJxHo95Zk,525
121
121
  iop/cls/IOP/Duplex/Process.cls,sha256=xbefZ4z84a_IUhavWN6P_gZBzqkdJ5XRTXxro6iDvAg,6986
122
122
  iop/cls/IOP/Duplex/Service.cls,sha256=sTMOQUCMBgVitmQkM8bbsrmrRtCdj91VlctJ3I7b8WU,161
@@ -135,9 +135,9 @@ iris/iris_ipm.pyi,sha256=j7CNUZcjeDu5sgeWUZJO_Qi4vQmHh6aD-jPWv8OdoUs,374
135
135
  iris/iris_utils.py,sha256=kg80O3yRpHIutM-mCyr4xCeTvKWPE-Kai-b6Dxw4vQ4,9882
136
136
  irisnative/_IRISNative.py,sha256=HQ4nBhc8t8_5OtxdMG-kx1aa-T1znf2I8obZOPLOPzg,665
137
137
  irisnative/__init__.py,sha256=6YmvBLQSURsCPKaNg7LK-xpo4ipDjrlhKuwdfdNb3Kg,341
138
- iris_pex_embedded_python-3.1.1b3.dist-info/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
139
- iris_pex_embedded_python-3.1.1b3.dist-info/METADATA,sha256=2Ywol4UK76ZeD2opOXPB3Iy_J0X1sIVfbZNycsb1SzI,49482
140
- iris_pex_embedded_python-3.1.1b3.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
141
- iris_pex_embedded_python-3.1.1b3.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
142
- iris_pex_embedded_python-3.1.1b3.dist-info/top_level.txt,sha256=jkWtvFKOp1Q-uO_VpGpfx5TcW7DS39z1liOAVp6zLig,47
143
- iris_pex_embedded_python-3.1.1b3.dist-info/RECORD,,
138
+ iris_pex_embedded_python-3.1.1b5.dist-info/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
139
+ iris_pex_embedded_python-3.1.1b5.dist-info/METADATA,sha256=GzBu0XnguRuxK2p5an6oGvofByiY5ZQBQdLiBFD1vSc,49479
140
+ iris_pex_embedded_python-3.1.1b5.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
141
+ iris_pex_embedded_python-3.1.1b5.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
142
+ iris_pex_embedded_python-3.1.1b5.dist-info/top_level.txt,sha256=jkWtvFKOp1Q-uO_VpGpfx5TcW7DS39z1liOAVp6zLig,47
143
+ iris_pex_embedded_python-3.1.1b5.dist-info/RECORD,,