sqlalchemy-iris 0.5.0b3__py3-none-any.whl → 0.6.0b1__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.
Files changed (77) hide show
  1. intersystems_iris/_BufferReader.py +10 -0
  2. intersystems_iris/_BufferWriter.py +32 -0
  3. intersystems_iris/_ConnectionInformation.py +54 -0
  4. intersystems_iris/_ConnectionParameters.py +18 -0
  5. intersystems_iris/_Constant.py +38 -0
  6. intersystems_iris/_DBList.py +499 -0
  7. intersystems_iris/_Device.py +69 -0
  8. intersystems_iris/_GatewayContext.py +25 -0
  9. intersystems_iris/_GatewayException.py +4 -0
  10. intersystems_iris/_GatewayUtility.py +74 -0
  11. intersystems_iris/_IRIS.py +1294 -0
  12. intersystems_iris/_IRISConnection.py +516 -0
  13. intersystems_iris/_IRISEmbedded.py +85 -0
  14. intersystems_iris/_IRISGlobalNode.py +273 -0
  15. intersystems_iris/_IRISGlobalNodeView.py +25 -0
  16. intersystems_iris/_IRISIterator.py +143 -0
  17. intersystems_iris/_IRISList.py +360 -0
  18. intersystems_iris/_IRISNative.py +208 -0
  19. intersystems_iris/_IRISOREF.py +4 -0
  20. intersystems_iris/_IRISObject.py +424 -0
  21. intersystems_iris/_IRISReference.py +133 -0
  22. intersystems_iris/_InStream.py +149 -0
  23. intersystems_iris/_LegacyIterator.py +135 -0
  24. intersystems_iris/_ListItem.py +15 -0
  25. intersystems_iris/_ListReader.py +84 -0
  26. intersystems_iris/_ListWriter.py +157 -0
  27. intersystems_iris/_LogFileStream.py +115 -0
  28. intersystems_iris/_MessageHeader.py +51 -0
  29. intersystems_iris/_OutStream.py +25 -0
  30. intersystems_iris/_PrintStream.py +65 -0
  31. intersystems_iris/_PythonGateway.py +850 -0
  32. intersystems_iris/_SharedMemorySocket.py +87 -0
  33. intersystems_iris/__init__.py +79 -0
  34. intersystems_iris/__main__.py +7 -0
  35. intersystems_iris/dbapi/_Column.py +56 -0
  36. intersystems_iris/dbapi/_DBAPI.py +2295 -0
  37. intersystems_iris/dbapi/_Descriptor.py +46 -0
  38. intersystems_iris/dbapi/_IRISStream.py +63 -0
  39. intersystems_iris/dbapi/_Message.py +158 -0
  40. intersystems_iris/dbapi/_Parameter.py +138 -0
  41. intersystems_iris/dbapi/_ParameterCollection.py +133 -0
  42. intersystems_iris/dbapi/_ResultSetRow.py +314 -0
  43. intersystems_iris/dbapi/_SQLType.py +32 -0
  44. intersystems_iris/dbapi/__init__.py +0 -0
  45. intersystems_iris/dbapi/preparser/_PreParser.py +1658 -0
  46. intersystems_iris/dbapi/preparser/_Scanner.py +391 -0
  47. intersystems_iris/dbapi/preparser/_Token.py +81 -0
  48. intersystems_iris/dbapi/preparser/_TokenList.py +251 -0
  49. intersystems_iris/dbapi/preparser/__init__.py +0 -0
  50. intersystems_iris/pex/_BusinessHost.py +101 -0
  51. intersystems_iris/pex/_BusinessOperation.py +105 -0
  52. intersystems_iris/pex/_BusinessProcess.py +214 -0
  53. intersystems_iris/pex/_BusinessService.py +95 -0
  54. intersystems_iris/pex/_Common.py +228 -0
  55. intersystems_iris/pex/_Director.py +24 -0
  56. intersystems_iris/pex/_IRISBusinessOperation.py +5 -0
  57. intersystems_iris/pex/_IRISBusinessService.py +18 -0
  58. intersystems_iris/pex/_IRISInboundAdapter.py +5 -0
  59. intersystems_iris/pex/_IRISOutboundAdapter.py +17 -0
  60. intersystems_iris/pex/_InboundAdapter.py +57 -0
  61. intersystems_iris/pex/_Message.py +6 -0
  62. intersystems_iris/pex/_OutboundAdapter.py +46 -0
  63. intersystems_iris/pex/__init__.py +25 -0
  64. iris/__init__.py +25 -0
  65. iris/iris_site.py +13 -0
  66. iris/irisbuiltins.py +97 -0
  67. iris/irisloader.py +199 -0
  68. irisnative/_IRISNative.py +9 -0
  69. irisnative/__init__.py +10 -0
  70. {sqlalchemy_iris-0.5.0b3.dist-info → sqlalchemy_iris-0.6.0b1.dist-info}/METADATA +1 -1
  71. sqlalchemy_iris-0.6.0b1.dist-info/RECORD +83 -0
  72. sqlalchemy_iris-0.6.0b1.dist-info/top_level.txt +4 -0
  73. sqlalchemy_iris-0.5.0b3.dist-info/RECORD +0 -14
  74. sqlalchemy_iris-0.5.0b3.dist-info/top_level.txt +0 -1
  75. {sqlalchemy_iris-0.5.0b3.dist-info → sqlalchemy_iris-0.6.0b1.dist-info}/LICENSE +0 -0
  76. {sqlalchemy_iris-0.5.0b3.dist-info → sqlalchemy_iris-0.6.0b1.dist-info}/WHEEL +0 -0
  77. {sqlalchemy_iris-0.5.0b3.dist-info → sqlalchemy_iris-0.6.0b1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,424 @@
1
+ import decimal
2
+ import weakref
3
+ import intersystems_iris._IRIS
4
+
5
+ class _IRISObject(object):
6
+ '''
7
+ Class for Python proxy objects created on behalf of IRIS objects.
8
+ '''
9
+
10
+ def __init__(self, connection, oref):
11
+ self._connection = connection
12
+ self._iris = intersystems_iris.IRIS(connection)
13
+ self._oref = oref
14
+ self._closed = False
15
+ self._connection._iris_object_proxy_map[oref] = weakref.ref(self)
16
+
17
+ def getOREF(self):
18
+ '''
19
+ Returns the IRIS object OREF as a string.
20
+
21
+ getOREF()
22
+
23
+ Return Value
24
+ ------------
25
+ Returns str.
26
+ '''
27
+ return self._oref
28
+
29
+ def get(self, propertyName):
30
+ '''
31
+ Fetches the value of a property of the IRISObject object.
32
+
33
+ get(propertyName)
34
+
35
+ Parameters
36
+ ----------
37
+ propertyName : name of a property
38
+
39
+ Return Value
40
+ ------------
41
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns bytes, Decimal, float, int, or str.
42
+ '''
43
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
44
+ return self._iris._execute(object, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
45
+
46
+ def getObject(self, propertyName):
47
+ '''
48
+ Fetches the value of a property of the IRISObject object.
49
+
50
+ getObject(propertyName)
51
+
52
+ Parameters
53
+ ----------
54
+ propertyName : name of a property
55
+
56
+ Return Value
57
+ ------------
58
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns bytes, Decimal, float, int, or str.
59
+ '''
60
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
61
+ return self._iris._execute(object, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
62
+
63
+ def getBoolean(self, propertyName):
64
+ '''
65
+ Fetches the value of a property of the IRISObject object as a boolean.
66
+
67
+ getBoolean(propertyName)
68
+
69
+ Parameters
70
+ ----------
71
+ propertyName : name of a property
72
+
73
+ Return Value
74
+ ------------
75
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns a bool.
76
+ '''
77
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
78
+ return self._iris._execute(bool, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
79
+
80
+ def getBytes(self, propertyName):
81
+ '''
82
+ Fetches the value of a property of the IRISObject object as bytes.
83
+
84
+ getBytes(propertyName)
85
+
86
+ Parameters
87
+ ----------
88
+ propertyName : name of a property
89
+
90
+ Return Value
91
+ ------------
92
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns bytes.
93
+ '''
94
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
95
+ return self._iris._execute(bytes, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
96
+
97
+ def getDecimal(self, propertyName):
98
+ '''
99
+ Fetches the value of a property of the IRISObject object as a Decimal.
100
+
101
+ getDecimal(propertyName)
102
+
103
+ Parameters
104
+ ----------
105
+ propertyName : name of a property
106
+
107
+ Return Value
108
+ ------------
109
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns a Decimal.
110
+ '''
111
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
112
+ return self._iris._execute(decimal.Decimal, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
113
+
114
+ def getFloat(self, propertyName):
115
+ '''
116
+ Fetches the value of a property of the IRISObject object as a float.
117
+
118
+ getFloat(propertyName)
119
+
120
+ Parameters
121
+ ----------
122
+ propertyName : name of a property
123
+
124
+ Return Value
125
+ ------------
126
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns a float.
127
+ '''
128
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
129
+ return self._iris._execute(float, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
130
+
131
+ def getInteger(self, propertyName):
132
+ '''
133
+ Fetches the value of a property of the IRISObject object as an integer.
134
+
135
+ getInteger(propertyName)
136
+
137
+ Parameters
138
+ ----------
139
+ propertyName : name of a property
140
+
141
+ Return Value
142
+ ------------
143
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns an int.
144
+ '''
145
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
146
+ return self._iris._execute(int, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
147
+
148
+ def getString(self, propertyName):
149
+ '''
150
+ Fetches the value of a property of the IRISObject object as a string.
151
+
152
+ getString(propertyName)
153
+
154
+ Parameters
155
+ ----------
156
+ propertyName : name of a property
157
+
158
+ Return Value
159
+ ------------
160
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns a str.
161
+ '''
162
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
163
+ return self._iris._execute(str, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
164
+
165
+ def getIRISList(self, propertyName):
166
+ '''
167
+ Fetches the value of a property of the IRISObject object as an IRISList.
168
+
169
+ getIRISList(propertyName)
170
+
171
+ Parameters
172
+ ----------
173
+ propertyName : name of a property
174
+
175
+ Return Value
176
+ ------------
177
+ Returns None for IRIS empty string ($$$NULLOREF); otherwise, returns an IRISList.
178
+ '''
179
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
180
+ return self._iris._execute(intersystems_iris.IRISList, intersystems_iris.IRIS.GET_PROPERTY, self, propertyName, None)
181
+
182
+ def set(self, propertyName, propertyValue):
183
+ '''
184
+ Set the value of a property of the IRISObject object.
185
+
186
+ set(propertyName, propertyValue)
187
+
188
+ Parameters
189
+ ----------
190
+ propertyName : name of a property
191
+ propertyValue : new value of the property
192
+
193
+ Return Value
194
+ ------------
195
+ Returns None.
196
+ '''
197
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
198
+ self._iris._execute(None, intersystems_iris.IRIS.SET_PROPERTY, self, propertyName, None, propertyValue, honorByReference = False)
199
+ return
200
+
201
+ def invoke(self, methodName, *args):
202
+ '''
203
+ Invoke a method of the IRISObject object that returns a value.
204
+
205
+ invoke(methodName, args...)
206
+
207
+ Parameters
208
+ ----------
209
+ methodName : name of a method.
210
+ args... : zero or more arguments to be passed to the function, optional, variable length.
211
+ None is projected as empty string ($$$NULLOREF) in IRIS.
212
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
213
+ all other types are projected as proxy objects.
214
+
215
+ Return Value
216
+ ------------
217
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns bytes, Decimal, float, int, or str.
218
+ '''
219
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
220
+ return self._iris._execute(object, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
221
+
222
+ def invokeObject(self, methodName, *args):
223
+ '''
224
+ Invoke a method of the IRISObject object that returns a value.
225
+
226
+ invokeObject(methodName, args...)
227
+
228
+ Parameters
229
+ ----------
230
+ methodName : name of a method.
231
+ args... : zero or more arguments to be passed to the function, optional, variable length.
232
+ None is projected as empty string ($$$NULLOREF) in IRIS.
233
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
234
+ all other types are projected as proxy objects.
235
+
236
+ Return Value
237
+ ------------
238
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns bytes, Decimal, float, int, or str.
239
+ '''
240
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
241
+ return self._iris._execute(object, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
242
+
243
+ def invokeBoolean(self, methodName, *args):
244
+ '''
245
+ Invoke a method of the IRISObject object that returns a value as a boolean.
246
+
247
+ invokeBoolean(methodName, args...)
248
+
249
+ Parameters
250
+ ----------
251
+ methodName : name of a method.
252
+ args... : zero or more arguments to be passed to the function, optional, variable length.
253
+ None is projected as empty string ($$$NULLOREF) in IRIS.
254
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
255
+ all other types are projected as proxy objects.
256
+
257
+ Return Value
258
+ ------------
259
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns a bool.
260
+ '''
261
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
262
+ return self._iris._execute(bool, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
263
+
264
+ def invokeBytes(self, methodName, *args):
265
+ '''
266
+ Invoke a method of the IRISObject object that returns a value as bytes.
267
+
268
+ invokeBytes(methodName, args...)
269
+
270
+ Parameters
271
+ ----------
272
+ methodName : name of a method.
273
+ args... : zero or more arguments to be passed to the function, optional, variable length.
274
+ None is projected as empty string ($$$NULLOREF) in IRIS.
275
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
276
+ all other types are projected as proxy objects.
277
+
278
+ Return Value
279
+ ------------
280
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns bytes.
281
+ '''
282
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
283
+ return self._iris._execute(bytes, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
284
+
285
+ def invokeDecimal(self, methodName, *args):
286
+ '''
287
+ Invoke a method of the IRISObject object that returns a value as a Decimal.
288
+
289
+ invokeDecimal(methodName, args...)
290
+
291
+ Parameters
292
+ ----------
293
+ methodName : name of a method.
294
+ args... : zero or more arguments to be passed to the function, optional, variable length.
295
+ None is projected as empty string ($$$NULLOREF) in IRIS.
296
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
297
+ all other types are projected as proxy objects.
298
+
299
+ Return Value
300
+ ------------
301
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns a Decimal.
302
+ '''
303
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
304
+ return self._iris._execute(decimal.Decimal, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
305
+
306
+ def invokeFloat(self, methodName, *args):
307
+ '''
308
+ Invoke a method of the IRISObject object that returns a value as a float.
309
+
310
+ invokeFloat(methodName, args...)
311
+
312
+ Parameters
313
+ ----------
314
+ methodName : name of a method.
315
+ args... : zero or more arguments to be passed to the function, optional, variable length.
316
+ None is projected as empty string ($$$NULLOREF) in IRIS.
317
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
318
+ all other types are projected as proxy objects.
319
+
320
+ Return Value
321
+ ------------
322
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns a float.
323
+ '''
324
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
325
+ return self._iris._execute(float, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
326
+
327
+ def invokeInteger(self, methodName, *args):
328
+ '''
329
+ Invoke a method of the IRISObject object that returns a value as an integer.
330
+
331
+ invokeInteger(methodName, args...)
332
+
333
+ Parameters
334
+ ----------
335
+ methodName : name of a method.
336
+ args... : zero or more arguments to be passed to the function, optional, variable length.
337
+ None is projected as empty string ($$$NULLOREF) in IRIS.
338
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
339
+ all other types are projected as proxy objects.
340
+
341
+ Return Value
342
+ ------------
343
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns a int.
344
+ '''
345
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
346
+ return self._iris._execute(int, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
347
+
348
+ def invokeString(self, methodName, *args):
349
+ '''
350
+ Invoke a method of the IRISObject object that returns a value as a string.
351
+
352
+ invokeString(methodName, args...)
353
+
354
+ Parameters
355
+ ----------
356
+ methodName : name of a method.
357
+ args... : zero or more arguments to be passed to the function, optional, variable length.
358
+ None is projected as empty string ($$$NULLOREF) in IRIS.
359
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
360
+ all other types are projected as proxy objects.
361
+
362
+ Return Value
363
+ ------------
364
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns a str.
365
+ '''
366
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
367
+ return self._iris._execute(str, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
368
+
369
+ def invokeIRISList(self, methodName, *args):
370
+ '''
371
+ Invoke a method of the IRISObject object that returns a value as an IRISList.
372
+
373
+ invokeIRISList(methodName, args...)
374
+
375
+ Parameters
376
+ ----------
377
+ methodName : name of a method.
378
+ args... : zero or more arguments to be passed to the function, optional, variable length.
379
+ None is projected as empty string ($$$NULLOREF) in IRIS.
380
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
381
+ all other types are projected as proxy objects.
382
+
383
+ Return Value
384
+ ------------
385
+ Returns None if IRIS empty string ($$$NULLOREF) is returned; otherwise, returns an IRISList.
386
+ '''
387
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
388
+ return self._iris._execute(intersystems_iris.IRISList, intersystems_iris.IRIS.VALUE_METHOD, self, methodName, args)
389
+
390
+ def invokeVoid(self, methodName, *args):
391
+ '''
392
+ Invoke a method of the IRISObject object that does not return a value.
393
+
394
+ invokeVoid(methodName, args...)
395
+
396
+ Parameters
397
+ ----------
398
+ methodName : name of a method.
399
+ args... : zero or more arguments to be passed to the function, optional, variable length.
400
+ None is projected as empty string ($$$NULLOREF) in IRIS.
401
+ bool, bytes, Decimal, float, int, str, and IRISList are projected as literals in IRIS.
402
+ all other types are projected as proxy objects.
403
+
404
+ Return Value
405
+ ------------
406
+ Returns None.
407
+ '''
408
+ if ( self._closed ): raise RuntimeError("IRISObject is closed")
409
+ self._iris._execute(None, intersystems_iris.IRIS.VOID_METHOD, self, methodName, args)
410
+ return
411
+
412
+ def getConnection():
413
+ return self._connection
414
+
415
+ def close(self):
416
+ if not self._closed:
417
+ with self._connection._lock_closed_oref:
418
+ del self._connection._iris_object_proxy_map[self._oref]
419
+ self._connection._iris_object_proxy_closed.append(self._oref)
420
+ self._closed = True
421
+
422
+ def __del__(self):
423
+ if not self._closed:
424
+ self.close()
@@ -0,0 +1,133 @@
1
+ import decimal
2
+ import intersystems_iris._IRISList
3
+ import intersystems_iris._IRISObject
4
+
5
+ class _IRISReference(object):
6
+ '''
7
+ Used to call method/routine for pass-by-reference arguments
8
+
9
+ iris.IRISReference(value, type)
10
+
11
+ Parameters
12
+ ----------
13
+ type : Python type used as a type hint for unmarshaling modified value of the argument. Supported types are bool, bytes, bytearray, Decimal, float, int, str or IRISList. if none is specified, Python Gateway uses the type that matches the original IRIS type.
14
+ '''
15
+
16
+ def __init__(self, value, type = None):
17
+ self._value = value
18
+ self._type = type
19
+ self._locale = "latin-1"
20
+ self._is_unicode = True
21
+
22
+ def setValue(self, value):
23
+ '''set the value of this IRISReference object.'''
24
+ self._value = value
25
+ return
26
+
27
+ def getValue(self):
28
+ '''Get the value of this IRISReference object.'''
29
+ return self.getObject()
30
+
31
+ def getObject(self):
32
+ '''Get the value of this IRISReference object.'''
33
+ if self._type == None:
34
+ return self._value
35
+ elif self._type == bool:
36
+ return self.getBoolean()
37
+ elif self._type == bytes:
38
+ return self.getBytes()
39
+ elif self._type == decimal.Decimal:
40
+ return self.getDecimal()
41
+ elif self._type == float:
42
+ return self.getFloat()
43
+ elif self._type == int:
44
+ return self.getInteger()
45
+ elif self._type == str:
46
+ return self.getString()
47
+ elif self._type == intersystems_iris.IRISList:
48
+ return self.getIRISList()
49
+ else:
50
+ return self._value
51
+
52
+ def getBoolean(self):
53
+ '''Get the value of this IRISReference object as a bool.'''
54
+ if self._value is None: return None
55
+ list = intersystems_iris.IRISList(None, self._locale, self._is_unicode)
56
+ if isinstance(self._value, intersystems_iris.IRISObject):
57
+ list.add(self._value._oref)
58
+ else:
59
+ list.add(self._value)
60
+ return list.getBoolean(1)
61
+
62
+ def getBytes(self):
63
+ '''Get the value of this IRISReference object as bytes.'''
64
+ if self._value is None: return None
65
+ list = intersystems_iris.IRISList(None, self._locale, self._is_unicode)
66
+ if isinstance(self._value, intersystems_iris.IRISObject):
67
+ list.add(self._value._oref)
68
+ else:
69
+ list.add(self._value)
70
+ return list.getBytes(1)
71
+
72
+ def getDecimal(self):
73
+ '''Get the value of this IRISReference object as a Decimal.'''
74
+ if self._value is None: return None
75
+ list = intersystems_iris.IRISList(None, self._locale, self._is_unicode)
76
+ if isinstance(self._value, intersystems_iris.IRISObject):
77
+ list.add(self._value._oref)
78
+ else:
79
+ list.add(self._value)
80
+ return list.getDecimal(1)
81
+
82
+ def getFloat(self):
83
+ '''Get the value of this IRISReference object as a float.'''
84
+ if self._value is None: return None
85
+ list = intersystems_iris.IRISList(None, self._locale, self._is_unicode)
86
+ if isinstance(self._value, intersystems_iris.IRISObject):
87
+ list.add(self._value._oref)
88
+ else:
89
+ list.add(self._value)
90
+ return list.getFloat(1)
91
+
92
+ def getInteger(self):
93
+ '''Get the value of this IRISReference object as a int.'''
94
+ if self._value is None: return None
95
+ list = intersystems_iris.IRISList(None, self._locale, self._is_unicode)
96
+ if isinstance(self._value, intersystems_iris.IRISObject):
97
+ list.add(self._value._oref)
98
+ else:
99
+ list.add(self._value)
100
+ return list.getInteger(1)
101
+
102
+ def getString(self):
103
+ '''Get the value of this IRISReference object as a str.'''
104
+ if self._value is None: return None
105
+ list = intersystems_iris.IRISList(None, self._locale, self._is_unicode)
106
+ if isinstance(self._value, intersystems_iris.IRISObject):
107
+ list.add(self._value._oref)
108
+ else:
109
+ list.add(self._value)
110
+ return list.getString(1)
111
+
112
+ def getIRISList(self):
113
+ '''Get the value of this IRISReference object as an IRISList.'''
114
+ if self._value is None: return None
115
+ return intersystems_iris.IRISList(self.getBytes(), self._locale, self._is_unicode)
116
+
117
+ def get_value(self):
118
+ '''This method is deprecated. Use getObject() instead.'''
119
+ return self.getObject()
120
+
121
+ def set_value(self, value):
122
+ '''This method is deprecated. Use setValue() instead.'''
123
+ self.setValue(value)
124
+ return
125
+
126
+ def get_type(self):
127
+ '''This method is deprecated. Use an appropriate typed getter instead.'''
128
+ return self._type
129
+
130
+ def set_type(self, type):
131
+ '''This method is deprecated. Use an appropriate typed getter instead.'''
132
+ self._type = type
133
+ return
@@ -0,0 +1,149 @@
1
+ import hashlib
2
+ from ._BufferReader import _BufferReader
3
+ from ._LogFileStream import _LogFileStream
4
+ from ._MessageHeader import _MessageHeader
5
+ from ._Device import _Device
6
+
7
+
8
+ class _InStream(object):
9
+
10
+ SEND_DATA = 0
11
+ BYTE_STREAM = 1
12
+ FETCH_DATA = 2
13
+ OOB_FETCH = 3
14
+ GATEWAY = 4
15
+ IRISNATIVE = 5
16
+
17
+ def __init__(self, connection):
18
+ self._connection = connection
19
+ self._device = connection._device
20
+ self._log_stream = connection._log_stream
21
+ self.wire = None
22
+
23
+ def _read_message_gateway(self, expected_message_id=-1):
24
+ is_for_gateway = self.__read_message_internal(expected_message_id, -1, _InStream.GATEWAY)
25
+ if expected_message_id != -1 and is_for_gateway:
26
+ raise Exception("Invalid message received")
27
+ if expected_message_id == -1 and not is_for_gateway:
28
+ raise Exception("Invalid message received")
29
+ code = self.wire.header._get_function_code()
30
+ return ((0xFF00 & code) >> 8) - 48
31
+
32
+ def _read_message_sysio(self, expected_message_id, allowedErrors):
33
+ while True:
34
+ is_for_gateway = self.__read_message_internal(expected_message_id, -1, _InStream.IRISNATIVE)
35
+ if is_for_gateway:
36
+ self._connection._get_gateway()._dispatch_reentrancy(self)
37
+ continue
38
+ code = self.wire.header._get_function_code() - 51712
39
+ if code != 0 and (allowedErrors == None or code not in allowedErrors):
40
+ error_message = self.wire._get()
41
+ raise RuntimeError(error_message)
42
+ return code
43
+
44
+ def _read_message_sql(self, expected_message_id, expected_statement_id=-1, type=0, allowedErrors=None):
45
+ while True:
46
+ is_for_gateway = self.__read_message_internal(expected_message_id, expected_statement_id, type)
47
+ if is_for_gateway:
48
+ self._connection._get_gateway()._dispatch_reentrancy(self)
49
+ continue
50
+ code = self.wire.header._get_function_code()
51
+ return code
52
+
53
+ def __read_message_internal(self, expected_message_id, expected_statement_id, call_type):
54
+ high_bit = 1
55
+ is_for_gateway = False
56
+ header = _MessageHeader()
57
+ final_buffer = bytearray()
58
+ while high_bit != 0:
59
+ self.__read_buffer(header.buffer, 0, _MessageHeader.HEADER_SIZE)
60
+ if self._log_stream is not None:
61
+ self._log_stream._dump_header(
62
+ header.buffer, _LogFileStream.LOG_RECEIVED, self._connection)
63
+ if ((expected_message_id == -1 or expected_message_id) == header._get_message_id()) and (expected_statement_id == -1 or expected_statement_id == header._get_statement_id()):
64
+ is_for_gateway = False
65
+ elif self.__is_header_initizted_from_iris(header, call_type):
66
+ is_for_gateway = True
67
+ else:
68
+ self._connection.close()
69
+ raise Exception("Invalid Message Count: expected: " + str(expected_message_id) +
70
+ " got: " + str(header._get_message_id()))
71
+
72
+ high_bit = (header._MessageHeader__get_4_byte_int_raw(8) & 0x80000000)
73
+
74
+ header_msg_length = header._get_message_length()
75
+ if header_msg_length == 0:
76
+ buffer = bytearray(0)
77
+ else:
78
+ buffer = bytearray(header_msg_length)
79
+ self.__read_buffer(buffer, 0, header_msg_length)
80
+ if self._log_stream is not None:
81
+ self._log_stream._dump_message(buffer)
82
+
83
+ if not high_bit and len(final_buffer) == 0:
84
+ self.wire = _BufferReader(
85
+ header, buffer, self._connection._connection_info._locale)
86
+ return is_for_gateway
87
+
88
+ final_buffer.extend(buffer)
89
+ self.wire = _BufferReader(
90
+ header, final_buffer, self._connection._connection_info._locale)
91
+ return is_for_gateway
92
+
93
+ def _check_sheader(self, hash, sock):
94
+ sheader = _MessageHeader()
95
+ try:
96
+ timeout = sock.gettimeout()
97
+ sock.settimeout(5)
98
+ self.__read_buffer(sheader.buffer, 0, _MessageHeader.HEADER_SIZE)
99
+ sock.settimeout(timeout)
100
+ except Exception as e:
101
+ return False
102
+ if self._log_stream is not None:
103
+ self._log_stream._dump_header(
104
+ sheader.buffer, _LogFileStream.LOG_RECEIVED, self._connection)
105
+ if sheader._get_message_length() != 0 or sheader._get_error() != 0:
106
+ return False
107
+ header_bytes = sheader.buffer[4:12]
108
+ header_bytes_str = b''
109
+ for i in range(len(header_bytes)):
110
+ header_bytes_str += bytes([header_bytes[i]])
111
+ in_hash = hashlib.sha256(header_bytes_str).hexdigest()
112
+ if len(hash) != len(in_hash):
113
+ return False
114
+ for i in range(len(hash)):
115
+ if hash[i] != in_hash[i]:
116
+ return False
117
+ return True
118
+
119
+ def __is_header_initizted_from_iris(self, header, call_type):
120
+ data_length = header._get_message_length()
121
+ message_id = header._get_count()
122
+ statement_id = header._get_statement_id()
123
+ # Gateway initiated message: message-ID is even. if type==GATEWAY, zero is allowed, otherwise, zero is not allowed.
124
+ if (call_type == _InStream.GATEWAY or message_id > 0) and message_id % 2 == 0:
125
+ return True
126
+ function_code = header._get_function_code()
127
+ # Special case for PassPhrase: type=GATEWAY, data_length==0 and function_code==0, middle 8 bytes are for SHA-256 hash code)
128
+ if call_type == _InStream.GATEWAY and data_length == 0 and function_code == 0:
129
+ return True
130
+ # Special case for %Ping (YQ) and %Disconnect (Y4) data_length==0 and message_id==0 and statement_id==0 and function_code=="YQ" or "Y4"
131
+ if data_length == 0 and message_id == 0 and statement_id == 0 and (function_code == 20825 or function_code == 13401):
132
+ return True
133
+ return False
134
+
135
+ def __read_buffer(self, buffer, offset, length):
136
+ if self._device is None:
137
+ raise RuntimeError("no longer connected to server")
138
+ data = self._device.recv(length)
139
+ buffer[offset:offset+len(data)] = data
140
+ if len(data) == length:
141
+ return
142
+ cb = len(data)
143
+ while cb < length:
144
+ data = self._device.recv(length-cb)
145
+ if len(data) == 0:
146
+ raise Exception("Server unexpectedly closing communication device")
147
+ buffer[offset+cb:offset+cb+len(data)] = data
148
+ cb += len(data)
149
+ return