iris-pex-embedded-python 2.3.28b2__py3-none-any.whl → 3.0.0__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 (71) hide show
  1. grongier/cls/Grongier/PEX/BusinessOperation.cls +1 -28
  2. grongier/cls/Grongier/PEX/BusinessProcess.cls +1 -112
  3. grongier/cls/Grongier/PEX/BusinessService.cls +1 -28
  4. grongier/cls/Grongier/PEX/Common.cls +1 -194
  5. grongier/cls/Grongier/PEX/Director.cls +1 -48
  6. grongier/cls/Grongier/PEX/Duplex/Operation.cls +1 -26
  7. grongier/cls/Grongier/PEX/Duplex/Process.cls +1 -217
  8. grongier/cls/Grongier/PEX/Duplex/Service.cls +1 -6
  9. grongier/cls/Grongier/PEX/InboundAdapter.cls +1 -15
  10. grongier/cls/Grongier/PEX/Message.cls +1 -116
  11. grongier/cls/Grongier/PEX/OutboundAdapter.cls +1 -29
  12. grongier/cls/Grongier/PEX/PickleMessage.cls +1 -46
  13. grongier/cls/Grongier/PEX/PrivateSession/Duplex.cls +1 -253
  14. grongier/cls/Grongier/PEX/PrivateSession/Message/Ack.cls +1 -19
  15. grongier/cls/Grongier/PEX/PrivateSession/Message/Poll.cls +1 -19
  16. grongier/cls/Grongier/PEX/PrivateSession/Message/Start.cls +1 -19
  17. grongier/cls/Grongier/PEX/PrivateSession/Message/Stop.cls +1 -35
  18. grongier/cls/Grongier/PEX/Test.cls +1 -53
  19. grongier/cls/Grongier/PEX/Utils.cls +1 -365
  20. grongier/cls/Grongier/Service/WSGI.cls +1 -307
  21. grongier/pex/__init__.py +11 -11
  22. grongier/pex/__main__.py +1 -1
  23. grongier/pex/_business_host.py +1 -511
  24. grongier/pex/_cli.py +1 -152
  25. grongier/pex/_common.py +1 -347
  26. grongier/pex/_director.py +1 -286
  27. grongier/pex/_utils.py +1 -369
  28. iop/__init__.py +24 -0
  29. iop/__main__.py +4 -0
  30. iop/_business_host.py +511 -0
  31. {grongier/pex → iop}/_business_operation.py +1 -1
  32. {grongier/pex → iop}/_business_process.py +1 -1
  33. {grongier/pex → iop}/_business_service.py +1 -1
  34. iop/_cli.py +152 -0
  35. iop/_common.py +349 -0
  36. iop/_director.py +286 -0
  37. {grongier/pex → iop}/_inbound_adapter.py +1 -1
  38. {grongier/pex → iop}/_outbound_adapter.py +1 -1
  39. {grongier/pex → iop}/_private_session_duplex.py +1 -1
  40. {grongier/pex → iop}/_private_session_process.py +2 -2
  41. iop/_utils.py +374 -0
  42. iop/cls/IOP/BusinessOperation.cls +35 -0
  43. iop/cls/IOP/BusinessProcess.cls +124 -0
  44. iop/cls/IOP/BusinessService.cls +35 -0
  45. iop/cls/IOP/Common.cls +203 -0
  46. iop/cls/IOP/Director.cls +57 -0
  47. iop/cls/IOP/Duplex/Operation.cls +29 -0
  48. iop/cls/IOP/Duplex/Process.cls +229 -0
  49. iop/cls/IOP/Duplex/Service.cls +9 -0
  50. iop/cls/IOP/InboundAdapter.cls +22 -0
  51. iop/cls/IOP/Message.cls +128 -0
  52. iop/cls/IOP/OutboundAdapter.cls +36 -0
  53. iop/cls/IOP/PickleMessage.cls +58 -0
  54. iop/cls/IOP/PrivateSession/Duplex.cls +260 -0
  55. iop/cls/IOP/PrivateSession/Message/Ack.cls +32 -0
  56. iop/cls/IOP/PrivateSession/Message/Poll.cls +32 -0
  57. iop/cls/IOP/PrivateSession/Message/Start.cls +32 -0
  58. iop/cls/IOP/PrivateSession/Message/Stop.cls +48 -0
  59. iop/cls/IOP/Service/WSGI.cls +310 -0
  60. iop/cls/IOP/Test.cls +62 -0
  61. iop/cls/IOP/Utils.cls +374 -0
  62. iop/wsgi/handlers.py +104 -0
  63. {iris_pex_embedded_python-2.3.28b2.dist-info → iris_pex_embedded_python-3.0.0.dist-info}/METADATA +28 -28
  64. {iris_pex_embedded_python-2.3.28b2.dist-info → iris_pex_embedded_python-3.0.0.dist-info}/RECORD +70 -42
  65. {iris_pex_embedded_python-2.3.28b2.dist-info → iris_pex_embedded_python-3.0.0.dist-info}/WHEEL +1 -1
  66. iris_pex_embedded_python-3.0.0.dist-info/entry_points.txt +2 -0
  67. {iris_pex_embedded_python-2.3.28b2.dist-info → iris_pex_embedded_python-3.0.0.dist-info}/top_level.txt +1 -0
  68. iris_pex_embedded_python-2.3.28b2.dist-info/entry_points.txt +0 -2
  69. {grongier/pex → iop}/_message.py +0 -0
  70. {grongier/pex → iop}/_pickle_message.py +0 -0
  71. {iris_pex_embedded_python-2.3.28b2.dist-info → iris_pex_embedded_python-3.0.0.dist-info}/LICENSE +0 -0
grongier/pex/_cli.py CHANGED
@@ -1,152 +1 @@
1
- # _manager.py is the main entry point of the pex package
2
- # it's a command line interface to manage productions
3
- # eg :
4
- # python3 -m grongier.pex -h : display help and the default production name
5
- # python3 -m grongier.pex -l : list productions
6
- # python3 -m grongier.pex -d <production_name> : set the default production to <production_name>
7
- # python3 -m grongier.pex -s <production_name> : start a production named <production_name> if <production_name> is not set, the default production is started
8
- # python3 -m grongier.pex -k <production_name> : stop a production named <production_name> if <production_name> is not set, the default production is killed
9
- # python3 -m grongier.pex -r <production_name> : restart a production named <production_name> if <production_name> is not set, the default production is restarted
10
- # python3 -m grongier.pex -m <settings_file> : migrate a production and classes with the settings file <settings_file>
11
- # python3 -m grongier.pex -x <production_name> : export a production named <production_name> if <production_name> is not set, the default production is exported
12
- from grongier.pex._director import _Director
13
- from grongier.pex._utils import _Utils
14
-
15
- import argparse
16
- import json
17
- import os
18
- from importlib.metadata import version
19
-
20
- def parse_args():
21
- # parse arguments
22
- main_parser = argparse.ArgumentParser()
23
- parser = main_parser.add_mutually_exclusive_group()
24
- parser.add_argument('-d', '--default', help='set the default production', nargs='?', const='not_set')
25
- parser.add_argument('-l', '--list', help='list productions', action='store_true')
26
- parser.add_argument('-s', '--start', help='start a production', nargs='?', const='not_set')
27
- start = main_parser.add_argument_group('start arguments')
28
- start.add_argument('-D', '--detach', help='start a production in detach mode', action='store_true')
29
- parser.add_argument('-S', '--stop', help='stop a production', action='store_true')
30
- parser.add_argument('-k', '--kill', help='kill a production', action='store_true')
31
- parser.add_argument('-r', '--restart', help='restart a production', action='store_true')
32
- parser.add_argument('-x', '--status', help='status a production', action='store_true')
33
- parser.add_argument('-m', '-M', '--migrate', help='migrate production and classes with settings file')
34
- parser.add_argument('-e', '--export', help='export a production', nargs='?', const='not_set')
35
- parser.add_argument('-v', '--version', help='display version', action='store_true')
36
- parser.add_argument('-L', '--log', help='display log', nargs='?', const='not_set')
37
- parser.add_argument('-i', '--init', help='init the pex module in iris', nargs='?', const='not_set')
38
- parser.add_argument('-t', '--test', help='test the pex module in iris', nargs='?', const='not_set')
39
- test = main_parser.add_argument_group('test arguments')
40
- # add classname argument
41
- test.add_argument('-C', '--classname', help='test classname', nargs='?', const='not_set')
42
- # body argument
43
- test.add_argument('-B', '--body', help='test body', nargs='?', const='not_set')
44
- return main_parser
45
-
46
- def main(argv=None):
47
- # build arguments
48
- parser = parse_args()
49
- args = parser.parse_args(argv)
50
-
51
- if args.default:
52
- # set default production
53
- if args.default == 'not_set':
54
- # display default production name
55
- print(_Director.get_default_production())
56
- else:
57
- _Director.set_default_production(args.default)
58
-
59
- elif args.list:
60
- # display list of productions
61
- dikt = _Director.list_productions()
62
- print(json.dumps(dikt, indent=4))
63
-
64
- elif args.start:
65
- production_name = None
66
- if args.start == 'not_set':
67
- # start default production
68
- production_name = _Director.get_default_production()
69
- else:
70
- # start production with name
71
- production_name = args.start
72
- if args.detach:
73
- # start production in detach mode
74
- _Director.start_production(production_name)
75
- print(f"Production {production_name} started")
76
- else:
77
- _Director.start_production_with_log(production_name)
78
-
79
- elif args.init:
80
- if args.init == 'not_set':
81
- # set arg to None
82
- args.init = None
83
- _Utils.setup(args.start)
84
-
85
- elif args.kill:
86
- # kill a production
87
- _Director.shutdown_production()
88
-
89
- elif args.restart:
90
- # restart a production
91
- _Director.restart_production()
92
-
93
- elif args.migrate:
94
- # check if migrate is absolute path
95
- if os.path.isabs(args.migrate):
96
- # migrate a production with absolute path
97
- _Utils.migrate(args.migrate)
98
- else:
99
- # migrate a production with relative path
100
- _Utils.migrate(os.path.join(os.getcwd(), args.migrate))
101
-
102
- elif args.version:
103
- # display version
104
- print(version('iris-pex-embedded-python'))
105
-
106
- elif args.log:
107
- # display log
108
- if args.log == 'not_set':
109
- # display default production log
110
- _Director.log_production()
111
- else:
112
- _Director.log_production_top(args.log)
113
-
114
- elif args.stop:
115
- # stop a production
116
- _Director.stop_production()
117
- print(f"Production {_Director.get_default_production()} stopped")
118
-
119
- elif args.status:
120
- dikt=_Director.status_production()
121
- print(json.dumps(dikt, indent=4))
122
-
123
- elif args.test:
124
- classname = None
125
- body = None
126
- if args.test == 'not_set':
127
- # set arg to None
128
- args.test = None
129
- if args.classname:
130
- classname = args.classname
131
- if args.body:
132
- body = args.body
133
- response = _Director.test_component(args.test, classname=classname, body=body)
134
- print(response)
135
-
136
- elif args.export:
137
- if args.export == 'not_set':
138
- # export default production
139
- args.export=_Director.get_default_production()
140
-
141
- dikt = _Utils.export_production(args.export)
142
- print(json.dumps(dikt, indent=4))
143
-
144
- else:
145
- # display help
146
- parser.print_help()
147
- print()
148
- print("Default production : " + _Director.get_default_production())
149
-
150
-
151
- if __name__ == '__main__':
152
- main()
1
+ from iop._cli import main
grongier/pex/_common.py CHANGED
@@ -1,347 +1 @@
1
- import traceback
2
- import dataclasses
3
- import inspect
4
- import iris
5
- import abc
6
-
7
- class _Common(metaclass=abc.ABCMeta):
8
- """ This is a common superclass for all component types that defines common methods."""
9
-
10
- INFO_URL: str
11
- ICON_URL: str
12
- iris_handle = None
13
-
14
- def on_init(self):
15
- """ The on_init() method is called when the component is started.
16
- Use the on_init() method to initialize any structures needed by the component."""
17
- return self.OnInit()
18
-
19
- def on_tear_down(self):
20
- """ Called before the component is terminated. Use it to free any structures."""
21
- return self.OnTearDown()
22
-
23
- def on_connected(self):
24
- """ The on_connected() method is called when the component is connected or reconnected after being disconnected.
25
- Use the on_connected() method to initialize any structures needed by the component."""
26
- return self.OnConnected()
27
-
28
- def _dispatch_on_connected(self, host_object):
29
- """ For internal use only. """
30
- self.on_connected()
31
- return
32
-
33
- def _dispatch_on_init(self, host_object):
34
- """ For internal use only. """
35
- self.on_init()
36
- return
37
-
38
- def _dispatch_on_tear_down(self, host_object):
39
- """ For internal use only. """
40
- self.on_tear_down()
41
- return
42
-
43
- def _set_iris_handles(self, handle_current, handle_partner):
44
- pass
45
-
46
- @classmethod
47
- def _is_message_instance(cls, obj):
48
- if cls._is_message_class(type(obj)):
49
- if not dataclasses.is_dataclass(obj):
50
- raise TypeError(type(obj).__module__ + '.' + type(obj).__qualname__+" must be a dataclass")
51
- return True
52
- return False
53
-
54
- @classmethod
55
- def _is_pickle_message_instance(cls, obj):
56
- if cls._is_pickel_message_class(type(obj)):
57
- return True
58
- return False
59
-
60
- @classmethod
61
- def _is_iris_object_instance(cls, obj):
62
- if (obj is not None and type(obj).__module__.find('iris') == 0) and obj._IsA("%Persistent"):
63
- return True
64
- return False
65
-
66
- @classmethod
67
- def _is_message_class(cls, klass):
68
- name = klass.__module__ + '.' + klass.__qualname__
69
- if name == "grongier.pex.Message":
70
- return True
71
- for c in klass.__bases__:
72
- if cls._is_message_class(c):
73
- return True
74
- return False
75
-
76
- @classmethod
77
- def _is_pickel_message_class(cls, klass):
78
- name = klass.__module__ + '.' + klass.__qualname__
79
- if name == "grongier.pex.PickleMessage":
80
- return True
81
- for c in klass.__bases__:
82
- if cls._is_pickel_message_class(c):
83
- return True
84
- return False
85
-
86
- @classmethod
87
- def _get_info(cls):
88
- """ Get class information to display in the Informational Settings expando for Production config items of this Business Host or Adapter.
89
- This method returns a list of Superclass, Description, InfoURL, and IconURL, and possibly Adapter (if class is a Business Service or Business Operation)
90
- IconURL is not yet displayed anywhere
91
- """
92
- ret = []
93
- desc = ""
94
- info_url = ""
95
- icon_url = ""
96
- super_class = ""
97
- adapter = ""
98
- try:
99
- # Get tuple of the class's base classes and loop through them until we find one of the PEX component classes
100
- classes = inspect.getmro(cls)
101
- for cl in classes:
102
- classname = str(cl)[7:-1]
103
- if classname in ["'grongier.pex.BusinessService'","'grongier.pex.BusinessOperation'","'grongier.pex.DuplexOperation'","'grongier.pex.DuplexService'"] :
104
- # Remove the apostrophes and set as super_class, then find if it uses an adapter
105
- super_class = classname[1:-1]
106
- adapter = cls.get_adapter_type()
107
- if adapter is None:
108
- adapter = cls.getAdapterType()
109
- break
110
- elif classname in ["'grongier.pex.BusinessProcess'","'grongier.pex.DuplexProcess'","'grongier.pex.InboundAdapter'","'grongier.pex.OutboundAdapter'"] :
111
- # Remove the apostrophes and set as super_class
112
- super_class = classname[1:-1]
113
- break
114
-
115
- if ""==super_class:
116
- return ""
117
- ret.append(super_class)
118
-
119
- # Get the class documentation, if any
120
- class_desc = inspect.getdoc(cls)
121
- super_desc = inspect.getdoc(classes[1])
122
- if class_desc!=super_desc:
123
- desc = class_desc
124
- ret.append(str(desc))
125
-
126
- info_url = inspect.getattr_static(cls,"INFO_URL","")
127
- icon_url = inspect.getattr_static(cls,"ICON_URL","")
128
-
129
- ret.append(info_url)
130
- ret.append(icon_url)
131
-
132
- if ""!=adapter:
133
- ret.append(adapter)
134
- except Exception as e:
135
- raise e
136
- return ret
137
-
138
- @classmethod
139
- def _get_properties(cls):
140
- """ Get a list of the Attributes and Properties of this Python class.
141
- Return value is a list of lists of form $lb(propName,data_type,defaultVal,required,category,description).
142
- which can be used by the Production Configuration to display them as settings.
143
- This list will only include class attributes (no instance attributes) and properties which are not marked to be private by use of the _ prefix.
144
- For class attributes, we will use the value that it is defined with as the defaultVal and its type as the data_type, or "" and String if set to None.
145
- Add a function attrName_info() for a attribute or property 'attrName' in order to add more information about that attribute by using the function annotation for the return value.
146
- The annotation should be a dictionary including any of 'IsRequired', 'Category', 'Description', 'DataType', or 'ExcludeFromSettings' as keys.
147
- 'ExcludeFromSettings' should be a boolean, and if true will exclude an attribute from being returned in the list, and so prevent it from being displayed as a setting in the Production Configuration Page
148
- 'DataType' does not need to be specified if it is the same as the type of the attribute definition. Otherwise, it can be either a Python type or a string.
149
- If 'IsRequired' is not specified, this will default to false.
150
- If 'Category' is not specified, the attribute will be added to the Additional category.
151
- """
152
- ret = []
153
- try:
154
- # getmembers() returns all the members of an obj
155
- for member in inspect.getmembers(cls):
156
- # remove private and protected functions
157
- if not member[0].startswith('_'):
158
- # remove other methods and functions
159
- if not inspect.ismethod(member[1]) and not inspect.isfunction(member[1]) and not inspect.isclass(member[1]):
160
- if member[0] not in ('INFO_URL','ICON_URL','PERSISTENT_PROPERTY_LIST') :
161
- name = member[0]
162
- req = 0
163
- cat = "Additional"
164
- desc = ""
165
- # get value, set to "" if None or a @property
166
- val = member[1]
167
- if isinstance(val,property) or (val is None):
168
- val = ""
169
- dt = str(type(val))[8:-2]
170
- # get datatype from attribute definition, default to String
171
- data_type = {'int':'Integer','float':'Numeric','complex':'Numeric','bool':'Boolean'}.get(dt,'String')
172
- # if the user has created a attr_info function, then check the annotation on the return from that for more information about this attribute
173
- if hasattr(cls,name + '_info') :
174
- func = getattr(cls,name+'_info')
175
- if callable(func) :
176
- annotations = func.__annotations__['return']
177
- if annotations is not None:
178
- if bool(annotations.get("ExcludeFromSettings")) :
179
- # don't add this attribute to the settings list
180
- continue
181
- req = bool(annotations.get("IsRequired"))
182
- cat = annotations.get("Category","Additional")
183
- desc = annotations.get("Description")
184
- dt = annotations.get("DataType")
185
- # only override DataType found
186
- if (dt is not None) and ("" != dt):
187
- data_type = {int:'Integer',float:'Number',complex:'Number',bool:'Boolean',str:'String'}.get(dt,str(dt))
188
- default = func()
189
- if default is not None:
190
- val = default
191
- # create list of information for this specific property
192
- info = []
193
- info.append(name) # Name
194
- info.append(data_type) # DataType
195
- info.append(val) # Default Value
196
- info.append(req) # Required
197
- info.append(cat) # Category
198
- info.append(desc) # Description
199
- # add this property to the list
200
- ret.append(info)
201
- except:
202
- pass
203
- return ret
204
-
205
- def log_info(self, message):
206
- """ Write a log entry of type "info". Log entries can be viewed in the management portal.
207
-
208
- Parameters:
209
- message: a string that is written to the log.
210
- """
211
-
212
- current_class = self.__class__.__name__
213
- current_method = None
214
- try:
215
- frame = traceback.extract_stack()[-2]
216
- current_method = frame.name
217
- except:
218
- pass
219
- iris.cls("Ens.Util.Log").LogInfo(current_class, current_method, message)
220
- return
221
-
222
- def log_alert(self, message):
223
- """ Write a log entry of type "alert". Log entries can be viewed in the management portal.
224
-
225
- Parameters:
226
- message: a string that is written to the log.
227
- """
228
- current_class = self.__class__.__name__
229
- current_method = None
230
- try:
231
- frame = traceback.extract_stack()[-2]
232
- current_method = frame.name
233
- except:
234
- pass
235
- iris.cls("Ens.Util.Log").LogAlert(current_class, current_method, message)
236
- return
237
-
238
- def log_warning(self, message):
239
- """ Write a log entry of type "warning". Log entries can be viewed in the management portal.
240
-
241
- Parameters:
242
- message: a string that is written to the log.
243
- """
244
- current_class = self.__class__.__name__
245
- current_method = None
246
- try:
247
- frame = traceback.extract_stack()[-2]
248
- current_method = frame.name
249
- except:
250
- pass
251
- iris.cls("Ens.Util.Log").LogWarning(current_class, current_method, message)
252
- return
253
-
254
- def log_error(self, message):
255
- """ Write a log entry of type "error". Log entries can be viewed in the management portal.
256
-
257
- Parameters:
258
- message: a string that is written to the log.
259
- """
260
- current_class = self.__class__.__name__
261
- current_method = None
262
- try:
263
- frame = traceback.extract_stack()[-2]
264
- current_method = frame.name
265
- except:
266
- pass
267
- iris.cls("Ens.Util.Log").LogError(current_class, current_method, message)
268
- return
269
-
270
- def log_assert(self, message):
271
- """ Write a log entry of type "assert". Log entries can be viewed in the management portal.
272
-
273
- Parameters:
274
- message: a string that is written to the log.
275
- """
276
- current_class = self.__class__.__name__
277
- current_method = None
278
- try:
279
- frame = traceback.extract_stack()[-2]
280
- current_method = frame.name
281
- except:
282
- pass
283
- iris.cls("Ens.Util.Log").LogAssert(current_class, current_method, message)
284
- return
285
-
286
- def LOGINFO(self, message):
287
- """ DECAPRETED : use log_info
288
- Write a log entry of type "info". Log entries can be viewed in the management portal.
289
-
290
- Parameters:
291
- message: a string that is written to the log.
292
- """
293
- return self.log_info(message=message)
294
-
295
- def LOGALERT(self, message):
296
- """ DECAPRETED : use log_alert
297
- Write a log entry of type "alert". Log entries can be viewed in the management portal.
298
-
299
- Parameters:
300
- message: a string that is written to the log.
301
- """
302
- return self.log_alert(message)
303
-
304
- def LOGWARNING(self, message):
305
- """ DECAPRETED : use log_warning
306
- Write a log entry of type "warning". Log entries can be viewed in the management portal.
307
-
308
- Parameters:
309
- message: a string that is written to the log.
310
- """
311
- return self.log_warning(message)
312
-
313
- def LOGERROR(self, message):
314
- """ DECAPRETED : use log_error
315
- Write a log entry of type "error". Log entries can be viewed in the management portal.
316
-
317
- Parameters:
318
- message: a string that is written to the log.
319
- """
320
- return self.log_error(message)
321
-
322
- def LOGASSERT(self, message):
323
- """ DECAPRETED : use log_assert
324
- Write a log entry of type "assert". Log entries can be viewed in the management portal.
325
-
326
- Parameters:
327
- message: a string that is written to the log.
328
- """
329
- return self.log_assert(message)
330
-
331
- def OnInit(self):
332
- """ DEPRECATED : use on_init
333
- The on_init() method is called when the component is started.
334
- Use the on_init() method to initialize any structures needed by the component."""
335
- return
336
-
337
- def OnTearDown(self):
338
- """ DEPRECATED : use on_tear_down
339
- Called before the component is terminated. Use it to freee any structures.
340
- """
341
- return
342
-
343
- def OnConnected(self):
344
- """ DEPRECATED : use on_connected
345
- The on_connected() method is called when the component is connected or reconnected after being disconnected.
346
- Use the on_connected() method to initialize any structures needed by the component."""
347
- return
1
+ from iop._common import _Common