iris-pex-embedded-python 3.4.1b1__py3-none-any.whl → 3.4.1b2__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.

Files changed (74) hide show
  1. iop/_director.py +23 -23
  2. {iris_pex_embedded_python-3.4.1b1.dist-info → iris_pex_embedded_python-3.4.1b2.dist-info}/METADATA +1 -1
  3. iris_pex_embedded_python-3.4.1b2.dist-info/RECORD +79 -0
  4. iris_pex_embedded_python-3.4.1b2.dist-info/top_level.txt +2 -0
  5. intersystems_iris/_BufferReader.py +0 -10
  6. intersystems_iris/_BufferWriter.py +0 -32
  7. intersystems_iris/_ConnectionInformation.py +0 -56
  8. intersystems_iris/_ConnectionParameters.py +0 -18
  9. intersystems_iris/_Constant.py +0 -38
  10. intersystems_iris/_DBList.py +0 -506
  11. intersystems_iris/_Device.py +0 -69
  12. intersystems_iris/_GatewayContext.py +0 -25
  13. intersystems_iris/_GatewayException.py +0 -4
  14. intersystems_iris/_GatewayUtility.py +0 -74
  15. intersystems_iris/_IRIS.py +0 -1294
  16. intersystems_iris/_IRISConnection.py +0 -516
  17. intersystems_iris/_IRISEmbedded.py +0 -85
  18. intersystems_iris/_IRISGlobalNode.py +0 -273
  19. intersystems_iris/_IRISGlobalNodeView.py +0 -25
  20. intersystems_iris/_IRISIterator.py +0 -143
  21. intersystems_iris/_IRISList.py +0 -360
  22. intersystems_iris/_IRISNative.py +0 -208
  23. intersystems_iris/_IRISOREF.py +0 -9
  24. intersystems_iris/_IRISObject.py +0 -424
  25. intersystems_iris/_IRISReference.py +0 -133
  26. intersystems_iris/_InStream.py +0 -149
  27. intersystems_iris/_LegacyIterator.py +0 -135
  28. intersystems_iris/_ListItem.py +0 -15
  29. intersystems_iris/_ListReader.py +0 -84
  30. intersystems_iris/_ListWriter.py +0 -161
  31. intersystems_iris/_LogFileStream.py +0 -115
  32. intersystems_iris/_MessageHeader.py +0 -51
  33. intersystems_iris/_OutStream.py +0 -25
  34. intersystems_iris/_PrintStream.py +0 -65
  35. intersystems_iris/_PythonGateway.py +0 -850
  36. intersystems_iris/_SharedMemorySocket.py +0 -87
  37. intersystems_iris/__init__.py +0 -79
  38. intersystems_iris/__main__.py +0 -7
  39. intersystems_iris/dbapi/_Column.py +0 -56
  40. intersystems_iris/dbapi/_DBAPI.py +0 -2631
  41. intersystems_iris/dbapi/_Descriptor.py +0 -46
  42. intersystems_iris/dbapi/_IRISStream.py +0 -65
  43. intersystems_iris/dbapi/_Message.py +0 -158
  44. intersystems_iris/dbapi/_Parameter.py +0 -171
  45. intersystems_iris/dbapi/_ParameterCollection.py +0 -141
  46. intersystems_iris/dbapi/_ResultSetRow.py +0 -361
  47. intersystems_iris/dbapi/_SQLType.py +0 -32
  48. intersystems_iris/dbapi/__init__.py +0 -0
  49. intersystems_iris/dbapi/preparser/_PreParser.py +0 -1674
  50. intersystems_iris/dbapi/preparser/_Scanner.py +0 -391
  51. intersystems_iris/dbapi/preparser/_Token.py +0 -81
  52. intersystems_iris/dbapi/preparser/_TokenList.py +0 -251
  53. intersystems_iris/dbapi/preparser/__init__.py +0 -0
  54. intersystems_iris/pex/_BusinessHost.py +0 -101
  55. intersystems_iris/pex/_BusinessOperation.py +0 -105
  56. intersystems_iris/pex/_BusinessProcess.py +0 -214
  57. intersystems_iris/pex/_BusinessService.py +0 -95
  58. intersystems_iris/pex/_Common.py +0 -228
  59. intersystems_iris/pex/_Director.py +0 -24
  60. intersystems_iris/pex/_IRISBusinessOperation.py +0 -5
  61. intersystems_iris/pex/_IRISBusinessService.py +0 -18
  62. intersystems_iris/pex/_IRISInboundAdapter.py +0 -5
  63. intersystems_iris/pex/_IRISOutboundAdapter.py +0 -17
  64. intersystems_iris/pex/_InboundAdapter.py +0 -57
  65. intersystems_iris/pex/_Message.py +0 -6
  66. intersystems_iris/pex/_OutboundAdapter.py +0 -46
  67. intersystems_iris/pex/__init__.py +0 -25
  68. iris_pex_embedded_python-3.4.1b1.dist-info/RECORD +0 -144
  69. iris_pex_embedded_python-3.4.1b1.dist-info/top_level.txt +0 -4
  70. irisnative/_IRISNative.py +0 -9
  71. irisnative/__init__.py +0 -10
  72. {iris_pex_embedded_python-3.4.1b1.dist-info → iris_pex_embedded_python-3.4.1b2.dist-info}/WHEEL +0 -0
  73. {iris_pex_embedded_python-3.4.1b1.dist-info → iris_pex_embedded_python-3.4.1b2.dist-info}/entry_points.txt +0 -0
  74. {iris_pex_embedded_python-3.4.1b1.dist-info → iris_pex_embedded_python-3.4.1b2.dist-info}/licenses/LICENSE +0 -0
@@ -1,506 +0,0 @@
1
- import struct
2
- import decimal
3
- import functools
4
- import uuid
5
- import math
6
- import intersystems_iris._IRISOREF
7
- import datetime
8
-
9
- class _DBList(object):
10
-
11
- ITEM_UNDEF = -1;
12
- ITEM_PLACEHOLDER = 0;
13
- ITEM_ASCII = 1;
14
- ITEM_UNICODE = 2;
15
- ITEM_POSINT = 4;
16
- ITEM_NEGINT = 5;
17
- ITEM_POSNUM = 6;
18
- ITEM_NEGNUM = 7;
19
- ITEM_DOUBLE = 8;
20
- ITEM_COMPACT_DOUBLE = 9;
21
- ITEM_OREF_ASCII = 25;
22
- ITEM_OREF_UNICODE = 26;
23
-
24
- @classmethod
25
- def _get_list_element(cls, item):
26
- buffer = item.buffer
27
- offset = item.next_offset
28
- item.by_reference = False
29
- # if first byte is 0, then length is next 2 bytes
30
- if buffer[offset] == 0:
31
- length = buffer[offset + 1] | (buffer[offset + 2] << 8);
32
- offset += 3
33
- # if the length is still 0, then the length is the next 4 bytes
34
- if length == 0:
35
- length = buffer[offset] | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 16) | (buffer[offset + 3] << 24);
36
- offset += 4
37
- item.type = buffer[offset]
38
- if item.type >= 32 and item.type < 64:
39
- item.type = item.type-32
40
- item.by_reference = True
41
- item.data_offset = offset + 1
42
- item.data_length = length - 1
43
- item.next_offset = item.data_offset + item.data_length
44
- item.is_null = False
45
- item.is_undefined = False
46
- elif buffer[offset] == 1:
47
- item.type = cls.ITEM_UNDEF
48
- if item.type >= 32 and item.type < 64:
49
- item.type = item.type-32
50
- item.by_reference = True
51
- item.data_offset = offset + 1
52
- item.data_length = 0
53
- item.next_offset = item.data_offset
54
- item.is_null = True
55
- item.is_undefined = True
56
- else:
57
- item.type = buffer[offset + 1]
58
- if item.type >= 32 and item.type < 64:
59
- item.type = item.type-32
60
- item.by_reference = True
61
- item.data_offset = offset + 2
62
- item.data_length = buffer[offset] - 2
63
- item.next_offset = item.data_offset + item.data_length
64
- item.is_null = (item.type == cls.ITEM_PLACEHOLDER) or ((item.type == cls.ITEM_ASCII) and (item.data_length == 0))
65
- item.is_undefined = False
66
- return
67
-
68
- @classmethod
69
- def _get_data_offset(cls, buffer, offset):
70
- if buffer[offset] != 0:
71
- next_offset = offset + buffer[offset]
72
- elif buffer[offset + 1] == 0 and buffer[offset + 2] == 0:
73
- if offset + 6 < len(buffer):
74
- next_offset = offset + (buffer[offset + 3] | (buffer[offset + 4] << 8) | (buffer[offset + 5] << 16)) + 7
75
- elif offset + 2 < len(buffer):
76
- next_offset = offset + (buffer[offset + 1] | (buffer[offset + 2] << 8)) + 3
77
- return next_offset
78
-
79
- @classmethod
80
- def _get(cls, item, locale, asBytes = False, retainAsciiZero = False):
81
- if item.is_null:
82
- return None
83
- func = cls._get_switcher.get(item.type, None)
84
- if func is None:
85
- raise Exception("Incorrect list format, unknown type: " + item.type)
86
- else:
87
- return func(item.buffer, item.data_offset, item.data_length, locale, asBytes, retainAsciiZero)
88
-
89
- @classmethod
90
- def _grab_ascii_string(cls, buffer, offset, length, locale, asBytes = False, retainAsciiZero = False):
91
- byte_array = buffer[offset:offset+length]
92
- if not retainAsciiZero and byte_array == b'\x00':
93
- return ""
94
- if asBytes:
95
- return bytes(byte_array)
96
- else:
97
- try:
98
- return byte_array.decode(locale)
99
- except:
100
- return byte_array.decode('latin-1')
101
-
102
- @classmethod
103
- def _grab_unicode_string(cls, buffer, offset, length, *args):
104
- return buffer[offset:offset+length].decode("utf-16LE")
105
-
106
- @classmethod
107
- def _grab_pos_integer(cls, buffer, offset, length, *args):
108
- number = 0
109
- for i in range(length):
110
- number = number*256 + buffer[offset+length-i-1]
111
- return number
112
-
113
- @classmethod
114
- def _grab_neg_integer(cls, buffer, offset, length, *args):
115
- if length == 0:
116
- return -1
117
- if length == 1:
118
- return (buffer[offset]) - 0x100
119
- if length == 2:
120
- return (buffer[offset] | buffer[offset+1]<<8) - 0x10000
121
- if length == 3:
122
- return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16) - 0x1000000
123
- if length == 4:
124
- return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24) - 0x100000000
125
- if length == 5:
126
- return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24 | buffer[offset+4]<<32) - 0x10000000000
127
- if length == 6:
128
- return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24 | buffer[offset+4]<<32 | buffer[offset+5]<<40) - 0x1000000000000
129
- if length == 7:
130
- return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24 | buffer[offset+4]<<32 | buffer[offset+5]<<40 | buffer[offset+6]<<48) - 0x100000000000000
131
- if length == 8:
132
- return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24 | buffer[offset+4]<<32 | buffer[offset+5]<<40 | buffer[offset+6]<<48 | buffer[offset+7]<<56) - 0x10000000000000000
133
- raise Exception("Integer out of range")
134
-
135
- @classmethod
136
- def _grab_pos_number(cls, buffer, offset, length, *args):
137
- num = cls._grab_pos_integer(buffer, offset + 1, length - 1)
138
- scale = buffer[offset]
139
- if scale > 127:
140
- scale -= 256
141
- return cls.__parse_decimal(scale, num)
142
-
143
- @classmethod
144
- def _grab_neg_number(cls, buffer, offset, length, *args):
145
- num = cls._grab_neg_integer(buffer, offset + 1, length - 1)
146
- scale = buffer[offset]
147
- if scale > 127:
148
- scale -= 256
149
- return cls.__parse_decimal(scale, num)
150
-
151
- @classmethod
152
- def _grab_double(cls, buffer, offset, length, *args):
153
- if length != 8: return cls.__grab_compact_float(buffer, offset, length)
154
- return struct.unpack('d', buffer[offset:offset+length])[0]
155
-
156
- @classmethod
157
- def _grab_compact_double(cls, buffer, offset, length, *args):
158
- return struct.unpack('d',b'\x00\x00\x00\x00\x00\x00\x00\x00'[length:]+buffer[offset:offset+length])[0]
159
-
160
- @classmethod
161
- def __grab_compact_float(cls, buffer, offset, length):
162
- return struct.unpack('f',b'\x00\x00\x00\x00'[length:]+buffer[offset:offset+length])[0]
163
-
164
- @classmethod
165
- def _grab_oref_ascii(cls, buffer, offset, length, locale, *args):
166
- return intersystems_iris._IRISOREF._IRISOREF(cls._grab_ascii_string(buffer, offset, length, locale, False))
167
-
168
- @classmethod
169
- def _grab_oref_unicode(cls, buffer, offset, length, *args):
170
- return intersystems_iris._IRISOREF._IRISOREF(cls._grab_unicode_string(buffer, offset, length))
171
-
172
- @classmethod
173
- def _set(cls, buffer, offset, data, locale, is_unicode, compact_double):
174
- func = cls._set_switcher.get(type(data), None)
175
- if func is None:
176
- # raise Exception("Unsupported argument type: " + str(type(data)))
177
- return cls._stuff_str(buffer, offset, str(data), locale, is_unicode, compact_double)
178
- else:
179
- return func(buffer, offset, data, locale, is_unicode, compact_double)
180
-
181
- @classmethod
182
- def _set_undefined(cls, buffer, offset):
183
- buffer[offset] = 1
184
- return offset + 1
185
-
186
- @classmethod
187
- def _set_null(cls, buffer, offset):
188
- return cls._stuff_null(buffer, offset)
189
-
190
- @classmethod
191
- def _stuff_null(cls, buffer, offset, data = None, *args):
192
- buffer[offset] = 2
193
- buffer[offset+1] = cls.ITEM_ASCII
194
- return offset+2
195
-
196
- @classmethod
197
- def _stuff_bytes(cls, buffer, offset, data, *args):
198
- length = len(data)
199
- offset = cls.__set_list_length_type(buffer, offset, length, cls.ITEM_ASCII)
200
- buffer[offset:offset+length] = data[0:length]
201
- offset += length
202
- return offset
203
-
204
- @classmethod
205
- def _stuff_int(cls, buffer, offset, data, locale, is_unicode, *args):
206
- if data > 0x7fffffffffffffff or data < -0x8000000000000000:
207
- return cls._stuff_str(buffer, offset, str(data), locale=locale, is_unicode=is_unicode)
208
- if data == 0:
209
- return cls.__set_list_length_type(buffer, offset, 0, cls.ITEM_POSINT)
210
- elif data > 0:
211
- length = cls.__get_pos_int_length(data)
212
- offset = cls.__set_list_length_type(buffer, offset, length, cls.ITEM_POSINT)
213
- offset = cls.__stuff_raw_int(buffer, offset, data, length)
214
- return offset
215
- else:
216
- length = cls.__get_neg_int_length(data)
217
- offset = cls.__set_list_length_type(buffer, offset, length, cls.ITEM_NEGINT)
218
- offset = cls.__stuff_raw_int(buffer, offset, data, length)
219
- return offset
220
-
221
- @classmethod
222
- def _stuff_double(cls, buffer, offset, data, locale, is_unicode, compact_double):
223
- if compact_double:
224
- if data == 0 and math.copysign(1,data) > 0:
225
- return cls.__set_list_length_type(buffer, offset, 0, cls.ITEM_DOUBLE)
226
- # check if value can be corced to a single-precision value
227
- # pack('<f') can throw OverFlowError
228
- if struct.unpack('f', struct.pack('f', data))[0] == data:
229
- lt = cls.ITEM_DOUBLE
230
- data_bytes = struct.pack('<f',data)
231
- else:
232
- lt = cls.ITEM_COMPACT_DOUBLE
233
- data_bytes = struct.pack('<d',data)
234
- length = len(data_bytes)
235
- #skip zeros
236
- for i in range(length):
237
- if data_bytes[i] != 0:
238
- break
239
- offset = cls.__set_list_length_type(buffer, offset, length-i, lt)
240
- for j in range(i,length):
241
- buffer[offset] = data_bytes[j]
242
- offset += 1
243
- return offset
244
- else: # not compact_double
245
- data_bytes = struct.pack('<d', data)
246
- length = len(data_bytes)
247
- offset = cls.__set_list_length_type(buffer, offset, length, cls.ITEM_DOUBLE)
248
- for i in range(length):
249
- buffer[offset] = data_bytes[i]
250
- offset += 1
251
- return offset
252
-
253
- @classmethod
254
- def _stuff_decimal(cls, buffer, offset, data, *args):
255
- try:
256
- if math.isnan(data) or math.isinf(data):
257
- return cls._stuff_double(buffer, offset, data, *args)
258
- except ValueError as e:
259
- if str(data).lower() == "snan":
260
- return cls._stuff_double(buffer, offset, decimal.Decimal('nan'), *args)
261
- elif str(data).lower() == "-snan":
262
- return cls._stuff_double(buffer, offset, decimal.Decimal('-nan'), *args)
263
- else:
264
- raise e
265
- bd = data
266
- scale = -bd.as_tuple()[2]
267
- unscaled_value = int(bd.scaleb(scale))
268
- # Truncate the magnitude if it does not fit into a 63 bit value
269
- if cls.__get_bitlength(unscaled_value) > 63:
270
- bd_rnd = decimal.Context(prec=19, rounding=decimal.ROUND_HALF_UP).create_decimal(bd)
271
- scale = -bd_rnd.as_tuple()[2]
272
- unscaled_value = int(bd_rnd.scaleb(scale))
273
- if cls.__get_bitlength(unscaled_value) > 63:
274
- bd_rnd = decimal.Context(prec=18, rounding=decimal.ROUND_HALF_UP).create_decimal(bd)
275
- scale = -bd_rnd.as_tuple()[2]
276
- unscaled_value = int(bd_rnd.scaleb(scale))
277
- if unscaled_value < 922337203685477581 and unscaled_value > -922337203685477581:
278
- unscaled_value = int((decimal.Decimal(unscaled_value)*10).to_integral_exact(rounding=decimal.ROUND_HALF_UP))
279
- scale += 1
280
- if cls.__get_bitlength(unscaled_value) > 63:
281
- raise Exception("Decimal out of range")
282
- # Round the extend scale values in the 128-145 range
283
- if scale < -127 or scale > 128:
284
- if scale > 128:
285
- prec_adj = -scale + 128
286
- else:
287
- prec_adj = -scale - 127
288
- unscaled_value = int(decimal.Decimal(unscaled_value).scaleb(prec_adj).to_integral(rounding=decimal.ROUND_HALF_UP))
289
- scale += prec_adj
290
- if unscaled_value == 0:
291
- scale = 0
292
- if cls.__get_bitlength(unscaled_value) > 63:
293
- raise Exception("Decimal out of range")
294
- # If can store in type 6, 7
295
- if scale < 129 and scale > -128:
296
- if unscaled_value >= 0:
297
- length = cls.__get_pos_int_length(unscaled_value)
298
- offset = cls.__set_list_length_type(buffer, offset, length + 1, cls.ITEM_POSNUM)
299
- else:
300
- length = cls.__get_neg_int_length(unscaled_value)
301
- offset = cls.__set_list_length_type(buffer, offset, length + 1, cls.ITEM_NEGNUM)
302
- scale = -scale
303
- if scale < 0:
304
- scale += 256
305
- buffer[offset] = scale
306
- offset += 1
307
- offset = cls.__stuff_raw_int(buffer, offset, unscaled_value, length)
308
- return offset
309
- # Out of range for IRIS Numeric SQLType
310
- return cls._stuff_double(buffer, offset, data, *args)
311
-
312
- @classmethod
313
- def _stuff_str(cls, buffer, offset, data, locale, is_unicode, *args):
314
- if type(data)==str and len(data) == 0:
315
- return cls.__stuff_empty_string(buffer, offset)
316
- is_oref = False
317
- if type(data) == intersystems_iris._IRISOREF._IRISOREF:
318
- data = data._oref
319
- is_oref = True
320
- offset_saved = offset
321
- offset = cls.__stuff_8bit_ascii(buffer, offset, data, is_oref)
322
- if offset == -1:
323
- offset = offset_saved
324
- if is_unicode:
325
- offset = cls.__stuff_unicode(buffer, offset, data, is_oref)
326
- else:
327
- offset = cls.__stuff_multibyte(buffer, offset, data, is_oref, locale)
328
- return offset
329
-
330
- @classmethod
331
- def _stuff_uuid(cls, buffer, offset, data, locale, is_unicode, *args):
332
- return cls._stuff_str(buffer, offset, str(data), locale=locale, is_unicode=is_unicode)
333
-
334
- @classmethod
335
- def _stuff_datetime(cls, buffer, offset, data, locale, is_unicode, *args):
336
- return cls._stuff_str(buffer, offset, data.strftime('%Y-%m-%d %H:%M:%S.%f'), locale=locale, is_unicode=is_unicode)
337
-
338
- @classmethod
339
- def _stuff_date(cls, buffer, offset, data, locale, is_unicode, *args):
340
- return cls._stuff_str(buffer, offset, data.strftime('%Y-%m-%d'), locale=locale, is_unicode=is_unicode)
341
-
342
- @classmethod
343
- def _stuff_time(cls, buffer, offset, data, locale, is_unicode, *args):
344
- return cls._stuff_str(buffer, offset, data.strftime('%H:%M:%S.%f'), locale=locale, is_unicode=is_unicode)
345
-
346
- @classmethod
347
- def __set_list_length_type(cls, buffer, offset, length, type):
348
- length += 1
349
- if length < 0xFF:
350
- length += 1;
351
- buffer[offset] = length
352
- buffer[offset + 1] = type
353
- return offset + 2
354
- if length <= 0xFFFF:
355
- buffer[offset] = 0
356
- buffer[offset + 1] = length & 0xFF
357
- buffer[offset + 2] = (length >> 8) & 0xFF
358
- buffer[offset + 3] = type
359
- return offset + 4
360
- buffer[offset] = 0;
361
- buffer[offset + 1] = 0;
362
- buffer[offset + 2] = 0;
363
- buffer[offset + 3] = length & 0xFF
364
- buffer[offset + 4] = (length >> 8) & 0xFF
365
- buffer[offset + 5] = (length >> 16) & 0xFF
366
- buffer[offset + 6] = (length >> 24) & 0xFF
367
- buffer[offset + 7] = type
368
- return offset + 8
369
-
370
- @classmethod
371
- def __get_pos_int_length(cls, data):
372
- if data <= 0xFF:
373
- return 1
374
- if data <= 0xFFFF:
375
- return 2
376
- if data <= 0xFFFFFF:
377
- return 3
378
- if data <= 0xFFFFFFFF:
379
- return 4
380
- if data <= 0xFFFFFFFFFF:
381
- return 5
382
- if data <= 0xFFFFFFFFFFFF:
383
- return 6
384
- if data <= 0xFFFFFFFFFFFFFF:
385
- return 7
386
- if data <= 0xFFFFFFFFFFFFFFFF:
387
- return 8
388
- raise Exception("Integer out of range")
389
-
390
- @classmethod
391
- def __get_neg_int_length(cls, data):
392
- if data == -1:
393
- return 0
394
- if data >= -0x100:
395
- return 1
396
- if data >= -0x10000:
397
- return 2
398
- if data >= -0x1000000:
399
- return 3
400
- if data >= -0x100000000:
401
- return 4
402
- if data >= -0x10000000000:
403
- return 5
404
- if data >= -0x1000000000000:
405
- return 6
406
- if data >= -0x100000000000000:
407
- return 7
408
- if data >= -0x10000000000000000:
409
- return 8
410
- raise Exception("Integer out of range")
411
-
412
- @classmethod
413
- def __stuff_raw_int(cls, buffer, offset, data, length):
414
- for i in range(length):
415
- one_byte = data & 255
416
- data = data >> 8
417
- buffer[offset+i] = one_byte
418
- return offset+length
419
-
420
- @classmethod
421
- def __stuff_empty_string(cls, buffer, offset):
422
- buffer[offset] = 3
423
- buffer[offset+1] = cls.ITEM_ASCII
424
- buffer[offset+2] = 0
425
- return offset+3
426
-
427
- @classmethod
428
- def __stuff_8bit_ascii(cls, buffer, offset, data, is_oref):
429
- try:
430
- list_type = cls.ITEM_OREF_ASCII if is_oref else cls.ITEM_ASCII
431
- length = len(data)
432
- offset = cls.__set_list_length_type(buffer, offset, length, list_type)
433
- buffer[offset:offset+length] = data.encode("latin-1")
434
- return offset+length
435
- except Exception as e:
436
- return -1
437
-
438
- @classmethod
439
- def __stuff_unicode(cls, buffer, offset, data, is_oref):
440
- list_type = cls.ITEM_OREF_UNICODE if is_oref else cls.ITEM_UNICODE
441
- byte_array = bytearray(data,"utf-16LE")
442
- length = len(byte_array)
443
- offset = cls.__set_list_length_type(buffer, offset, length, list_type)
444
- buffer[offset:offset+length] = byte_array[0:length]
445
- return offset+length
446
-
447
- @classmethod
448
- def __stuff_multibyte(cls, buffer, offset, data, is_oref, locale):
449
- list_type = cls.ITEM_OREF_ASCII if is_oref else cls.ITEM_ASCII
450
- ascii = data.encode(locale)
451
- length = len(ascii)
452
- offset = cls.__set_list_length_type(buffer, offset, length, list_type)
453
- buffer[offset:offset+length] = ascii
454
- return offset + length
455
-
456
- @classmethod
457
- def __parse_decimal(cls, scale, num):
458
- decstr = str(num) + "E" + str(scale)
459
- dec = decimal.Decimal(decstr)
460
- return dec
461
-
462
- @classmethod
463
- def __get_bitlength(cls, value):
464
- if value < 0:
465
- return (value + 1).bit_length()
466
- else:
467
- return value.bit_length()
468
-
469
- @classmethod
470
- def _set_type_as_pass_by_reference(cls, buffer, offset):
471
- if buffer[offset] == 0:
472
- buffer[offset+3] = buffer[offset+3]+32
473
- elif buffer[offset] == 1:
474
- pass
475
- else:
476
- buffer[offset+1] = buffer[offset+1]+32
477
- return
478
-
479
- _DBList._get_switcher = {
480
- _DBList.ITEM_ASCII: _DBList._grab_ascii_string,
481
- _DBList.ITEM_UNICODE: _DBList._grab_unicode_string,
482
- _DBList.ITEM_POSINT: _DBList._grab_pos_integer,
483
- _DBList.ITEM_NEGINT: _DBList._grab_neg_integer,
484
- _DBList.ITEM_POSNUM: _DBList._grab_pos_number,
485
- _DBList.ITEM_NEGNUM: _DBList._grab_neg_number,
486
- _DBList.ITEM_DOUBLE: _DBList._grab_double,
487
- _DBList.ITEM_COMPACT_DOUBLE: _DBList._grab_compact_double,
488
- _DBList.ITEM_OREF_ASCII: _DBList._grab_oref_ascii,
489
- _DBList.ITEM_OREF_UNICODE: _DBList._grab_oref_unicode
490
- }
491
-
492
- _DBList._set_switcher = {
493
- type(None): _DBList._stuff_null,
494
- datetime.time: _DBList._stuff_time,
495
- datetime.date: _DBList._stuff_date,
496
- datetime.datetime: _DBList._stuff_datetime,
497
- bytes: _DBList._stuff_bytes,
498
- bytearray: _DBList._stuff_bytes,
499
- bool: _DBList._stuff_int,
500
- int: _DBList._stuff_int,
501
- float: _DBList._stuff_double,
502
- decimal.Decimal: _DBList._stuff_decimal,
503
- str: _DBList._stuff_str,
504
- uuid.UUID: _DBList._stuff_uuid,
505
- intersystems_iris._IRISOREF._IRISOREF: _DBList._stuff_str,
506
- }
@@ -1,69 +0,0 @@
1
- import base64
2
- import getpass
3
- import os
4
- import platform
5
- import socket
6
- import struct
7
- import sys
8
- import threading
9
- import intersystems_iris._SharedMemorySocket
10
- import ssl
11
-
12
- class _Device(object):
13
-
14
- def __init__(self, _connection, _socket, _sslcontext = None):
15
- _connection._device = self
16
- self._connection = _connection
17
- self._sslcontext = _sslcontext
18
- if _socket is None:
19
- self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
20
- else:
21
- self._socket = _socket
22
-
23
- def close(self):
24
- return self._socket.close()
25
-
26
- def settimeout(self,time):
27
- return self._socket.settimeout(time)
28
-
29
- def connect(self, server_address):
30
- if self._sslcontext is None:
31
- return self._socket.connect(server_address)
32
- else:
33
- self._socket = self._sslcontext.wrap_socket(self._socket, server_hostname = server_address[0])
34
- return self._socket.connect(server_address)
35
-
36
- def sendall(self, buffer):
37
- return self._socket.sendall(buffer)
38
-
39
- def recv(self, len):
40
- return self._socket.recv(len)
41
-
42
- def gethostname(self):
43
- return socket.gethostname()
44
-
45
- def gethostbyname(self, hostname):
46
- return socket.gethostbyname(hostname)
47
-
48
- def is_sharedmemory(self):
49
- return isinstance(self._socket, intersystems_iris._SharedMemorySocket._SharedMemorySocket)
50
-
51
- def establishSHMSocket(self):
52
- try:
53
- iris_bin_dir = self._connection._connection_info._iris_install_dir
54
- server_job_number = self._connection._connection_info._server_job_number
55
- filename = b''
56
- if self._connection._connection_params.hostname != None:
57
- array = self._connection._connection_params.hostname.split("|")
58
- filename = array[3] if len(array)>=4 else ""
59
- filename = filename.upper()
60
- filename = bytes(filename, "latin-1")
61
- shmSocket = intersystems_iris._SharedMemorySocket._SharedMemorySocket(iris_bin_dir, server_job_number, filename)
62
- shmSocket.connect()
63
- self._socket.close()
64
- self._socket = shmSocket
65
- except BaseException as e:
66
- try:
67
- shmSocket.close()
68
- except BaseException as e:
69
- pass
@@ -1,25 +0,0 @@
1
- import threading
2
- import intersystems_iris._IRIS
3
-
4
- class _GatewayContext(object):
5
-
6
- __thread_local_connection = {}
7
-
8
- @classmethod
9
- def _set_connection(cls, connection):
10
- thread_id = threading.get_ident()
11
- cls.__thread_local_connection[thread_id] = connection
12
-
13
- @classmethod
14
- def _get_connection(cls):
15
- thread_id = threading.get_ident()
16
- return cls.__thread_local_connection.get(thread_id)
17
-
18
- @classmethod
19
- def getConnection(cls):
20
- return cls._get_connection()
21
-
22
- @classmethod
23
- def getIRIS(cls):
24
- return intersystems_iris.IRIS(cls._get_connection())
25
-
@@ -1,4 +0,0 @@
1
- class _GatewayException(Exception):
2
-
3
- def __init__(self, msg):
4
- super().__init__(msg)
@@ -1,74 +0,0 @@
1
- import inspect
2
- import platform
3
- import sys
4
- import intersystems_iris._GatewayContext
5
-
6
- class _GatewayUtility(object):
7
-
8
- @staticmethod
9
- def getLanguageName():
10
- return "Python"
11
-
12
- @staticmethod
13
- def getLanguageVersion():
14
- return platform.python_version()
15
-
16
- @staticmethod
17
- def writeOutput(data):
18
- connection = intersystems_iris.GatewayContext.getConnection()
19
- method_object = connection._output_redirect_handler
20
- if method_object is None:
21
- print(data, end="", flush=True)
22
- else:
23
- args = [ data ]
24
- method_object(*args)
25
-
26
- @classmethod
27
- def dumpAllModules(cls, startswith = None):
28
- if startswith is None: startswith = ""
29
- lines = {}
30
- gateway = intersystems_iris.GatewayContext.getConnection()._get_gateway()
31
- cls._dumpOneModuleCollection(startswith, lines, sys.modules.copy())
32
- cls._dumpOneModuleCollection(startswith, lines, gateway._thread_modules)
33
- return "\r\n".join(sorted(lines.keys()))
34
-
35
- @classmethod
36
- def dumpSysModules(cls, startswith = None):
37
- if startswith is None: startswith = ""
38
- lines = {}
39
- gateway = intersystems_iris.GatewayContext.getConnection()._get_gateway()
40
- cls._dumpOneModuleCollection(startswith, lines, sys.modules.copy())
41
- return "\r\n".join(sorted(lines.keys()))
42
-
43
- @classmethod
44
- def dumpThreadModules(cls, startswith = None):
45
- if startswith is None: startswith = ""
46
- lines = {}
47
- gateway = intersystems_iris.GatewayContext.getConnection()._get_gateway()
48
- cls._dumpOneModuleCollection(startswith, lines, gateway._thread_modules)
49
- return "\r\n".join(sorted(lines.keys()))
50
-
51
- @classmethod
52
- def dumpMethods(cls, class_name = None):
53
- lines = {}
54
- gateway = intersystems_iris.GatewayContext.getConnection()._get_gateway()
55
- class_object = gateway._load_class(class_name)
56
- methods = inspect.getmembers(class_object, inspect.isfunction)
57
- for m in range(len(methods)):
58
- lines[methods[m][0]] = ""
59
- return "\r\n".join(sorted(lines.keys()))
60
-
61
- @classmethod
62
- def _dumpOneModuleCollection(cls, startswith, lines, collection):
63
- for module in collection.values():
64
- module_name = module.__name__ + "."
65
- if module_name.startswith(startswith): lines[module_name] = ""
66
- try:
67
- classes = inspect.getmembers(module, inspect.isclass)
68
- for clazz in range(len(classes)):
69
- class_name = module_name + classes[clazz][0]
70
- if class_name.startswith(startswith): lines[class_name] = ""
71
- except Exception as ex:
72
- pass
73
- return
74
-