iris-pex-embedded-python 2.3.25b2__py3-none-any.whl → 3.2.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 (85) hide show
  1. grongier/cls/Grongier/PEX/BusinessOperation.cls +1 -28
  2. grongier/cls/Grongier/PEX/BusinessProcess.cls +1 -101
  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 -481
  24. grongier/pex/_cli.py +2 -150
  25. grongier/pex/_common.py +1 -347
  26. grongier/pex/_director.py +1 -286
  27. grongier/pex/_utils.py +1 -369
  28. intersystems_iris/_ConnectionInformation.py +22 -20
  29. intersystems_iris/dbapi/_DBAPI.py +6 -1
  30. intersystems_iris/dbapi/_ResultSetRow.py +26 -15
  31. intersystems_iris/dbapi/preparser/_PreParser.py +4 -1
  32. iop/__init__.py +24 -0
  33. iop/__main__.py +4 -0
  34. iop/_business_host.py +675 -0
  35. iop/_business_operation.py +71 -0
  36. iop/_business_process.py +220 -0
  37. {grongier/pex → iop}/_business_service.py +2 -2
  38. iop/_cli.py +141 -0
  39. iop/_common.py +352 -0
  40. iop/_director.py +301 -0
  41. {grongier/pex → iop}/_inbound_adapter.py +1 -1
  42. iop/_log_manager.py +81 -0
  43. {grongier/pex → iop}/_message.py +1 -1
  44. {grongier/pex → iop}/_outbound_adapter.py +1 -1
  45. {grongier/pex → iop}/_private_session_duplex.py +4 -3
  46. {grongier/pex → iop}/_private_session_process.py +2 -2
  47. iop/_utils.py +458 -0
  48. iop/cls/IOP/BusinessOperation.cls +35 -0
  49. iop/cls/IOP/BusinessProcess.cls +124 -0
  50. iop/cls/IOP/BusinessService.cls +35 -0
  51. iop/cls/IOP/Common.cls +344 -0
  52. iop/cls/IOP/Director.cls +62 -0
  53. iop/cls/IOP/Duplex/Operation.cls +29 -0
  54. iop/cls/IOP/Duplex/Process.cls +229 -0
  55. iop/cls/IOP/Duplex/Service.cls +9 -0
  56. iop/cls/IOP/InboundAdapter.cls +22 -0
  57. iop/cls/IOP/Message/JSONSchema.cls +125 -0
  58. iop/cls/IOP/Message.cls +729 -0
  59. iop/cls/IOP/OutboundAdapter.cls +36 -0
  60. iop/cls/IOP/PickleMessage.cls +58 -0
  61. iop/cls/IOP/PrivateSession/Duplex.cls +260 -0
  62. iop/cls/IOP/PrivateSession/Message/Ack.cls +32 -0
  63. iop/cls/IOP/PrivateSession/Message/Poll.cls +32 -0
  64. iop/cls/IOP/PrivateSession/Message/Start.cls +32 -0
  65. iop/cls/IOP/PrivateSession/Message/Stop.cls +48 -0
  66. iop/cls/IOP/Service/WSGI.cls +310 -0
  67. iop/cls/IOP/Test.cls +85 -0
  68. iop/cls/IOP/Utils.cls +378 -0
  69. iop/wsgi/handlers.py +104 -0
  70. iris_pex_embedded_python-3.2.1b2.dist-info/METADATA +90 -0
  71. iris_pex_embedded_python-3.2.1b2.dist-info/RECORD +139 -0
  72. {iris_pex_embedded_python-2.3.25b2.dist-info → iris_pex_embedded_python-3.2.1b2.dist-info}/WHEEL +1 -1
  73. iris_pex_embedded_python-3.2.1b2.dist-info/entry_points.txt +2 -0
  74. {iris_pex_embedded_python-2.3.25b2.dist-info → iris_pex_embedded_python-3.2.1b2.dist-info}/top_level.txt +1 -1
  75. grongier/pex/_business_operation.py +0 -70
  76. grongier/pex/_business_process.py +0 -215
  77. iris/__init__.py +0 -60
  78. iris/__init__.pyi +0 -236
  79. iris/iris_ipm.py +0 -40
  80. iris/iris_ipm.pyi +0 -17
  81. iris_pex_embedded_python-2.3.25b2.dist-info/METADATA +0 -1384
  82. iris_pex_embedded_python-2.3.25b2.dist-info/RECORD +0 -113
  83. iris_pex_embedded_python-2.3.25b2.dist-info/entry_points.txt +0 -2
  84. {grongier/pex → iop}/_pickle_message.py +0 -0
  85. {iris_pex_embedded_python-2.3.25b2.dist-info → iris_pex_embedded_python-3.2.1b2.dist-info}/LICENSE +0 -0
@@ -1,1384 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: iris_pex_embedded_python
3
- Version: 2.3.25b2
4
- Summary: Iris Interoperability based on Embedded Python
5
- Author-email: grongier <guillaume.rongier@intersystems.com>
6
- License: MIT License
7
-
8
- Copyright (c) 2019 InterSystems Developer Community
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
- Project-URL: homepage, https://github.com/grongierisc/interoperability-embedded-python
29
- Project-URL: documentation, https://github.com/grongierisc/interoperability-embedded-python/blob/master/README.md
30
- Project-URL: repository, https://github.com/grongierisc/interoperability-embedded-python
31
- Project-URL: issues, https://github.com/grongierisc/interoperability-embedded-python/issues
32
- Keywords: iris,intersystems,python,embedded
33
- Classifier: Development Status :: 5 - Production/Stable
34
- Classifier: Intended Audience :: Developers
35
- Classifier: License :: OSI Approved :: MIT License
36
- Classifier: Operating System :: OS Independent
37
- Classifier: Programming Language :: Python :: 3.6
38
- Classifier: Programming Language :: Python :: 3.7
39
- Classifier: Programming Language :: Python :: 3.8
40
- Classifier: Programming Language :: Python :: 3.9
41
- Classifier: Programming Language :: Python :: 3.10
42
- Classifier: Programming Language :: Python :: 3.11
43
- Classifier: Topic :: Utilities
44
- Description-Content-Type: text/markdown
45
- License-File: LICENSE
46
- Requires-Dist: dacite >=1.6.0
47
- Requires-Dist: xmltodict >=0.12.0
48
-
49
- # 1. interoperability-embedded-python
50
-
51
- [![PyPI - Status](https://img.shields.io/pypi/status/iris-pex-embedded-python)](https://pypi.org/project/iris-pex-embedded-python/)
52
- [![PyPI](https://img.shields.io/pypi/v/iris-pex-embedded-python)](https://pypi.org/project/iris-pex-embedded-python/)
53
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/iris-pex-embedded-python)](https://pypi.org/project/iris-pex-embedded-python/)
54
- [![PyPI - License](https://img.shields.io/pypi/l/iris-pex-embedded-python)](https://pypi.org/project/iris-pex-embedded-python/)
55
- ![GitHub last commit](https://img.shields.io/github/last-commit/grongierisc/interoperability-embedded-python)
56
-
57
- This proof of concept aims to show how the **iris interoperability framework** can be use with **embedded python**.
58
-
59
- ## 1.1. Table of Contents
60
-
61
- - [1. interoperability-embedded-python](#1-interoperability-embedded-python)
62
- - [1.1. Table of Contents](#11-table-of-contents)
63
- - [1.2. Example](#12-example)
64
- - [1.3. Register a component](#13-register-a-component)
65
- - [2. Demo](#2-demo)
66
- - [3. Installation](#3-installation)
67
- - [3.1. With ZPM](#31-with-zpm)
68
- - [3.2. With PyPI](#32-with-pypi)
69
- - [3.2.1. Known issues](#321-known-issues)
70
- - [4. How to Run the Sample](#4-how-to-run-the-sample)
71
- - [4.1. Docker containers](#41-docker-containers)
72
- - [4.2. Management Portal and VSCode](#42-management-portal-and-vscode)
73
- - [4.3. Open the production](#43-open-the-production)
74
- - [5. What's inside the repository](#5-whats-inside-the-repository)
75
- - [5.1. Dockerfile](#51-dockerfile)
76
- - [5.2. .vscode/settings.json](#52-vscodesettingsjson)
77
- - [5.3. .vscode/launch.json](#53-vscodelaunchjson)
78
- - [5.4. .vscode/extensions.json](#54-vscodeextensionsjson)
79
- - [5.5. src folder](#55-src-folder)
80
- - [6. How it works](#6-how-it-works)
81
- - [6.1. The `__init__.py`file](#61-the-__init__pyfile)
82
- - [6.2. The `common` class](#62-the-common-class)
83
- - [6.3. The `business_host` class](#63-the-business_host-class)
84
- - [6.4. The `inbound_adapter` class](#64-the-inbound_adapter-class)
85
- - [6.5. The `outbound_adapter` class](#65-the-outbound_adapter-class)
86
- - [6.6. The `business_service` class](#66-the-business_service-class)
87
- - [6.7. The `business_process` class](#67-the-business_process-class)
88
- - [6.8. The `business_operation` class](#68-the-business_operation-class)
89
- - [6.8.1. The dispacth system](#681-the-dispacth-system)
90
- - [6.8.2. The methods](#682-the-methods)
91
- - [6.9. The `director` class](#69-the-director-class)
92
- - [6.10. The `objects`](#610-the-objects)
93
- - [6.11. The `messages`](#611-the-messages)
94
- - [6.12. How to regsiter a component](#612-how-to-regsiter-a-component)
95
- - [6.12.1. register\_component](#6121-register_component)
96
- - [6.12.2. register\_file](#6122-register_file)
97
- - [6.12.3. register\_folder](#6123-register_folder)
98
- - [6.12.4. migrate](#6124-migrate)
99
- - [6.12.4.1. setting.py file](#61241-settingpy-file)
100
- - [6.12.4.1.1. CLASSES section](#612411-classes-section)
101
- - [6.12.4.1.2. Productions section](#612412-productions-section)
102
- - [6.13. Direct use of Grongier.PEX](#613-direct-use-of-grongierpex)
103
- - [7. Command line](#7-command-line)
104
- - [7.1. help](#71-help)
105
- - [7.2. default](#72-default)
106
- - [7.3. lists](#73-lists)
107
- - [7.4. start](#74-start)
108
- - [7.5. kill](#75-kill)
109
- - [7.6. stop](#76-stop)
110
- - [7.7. restart](#77-restart)
111
- - [7.8. migrate](#78-migrate)
112
- - [7.9. export](#79-export)
113
- - [7.10. status](#710-status)
114
- - [7.11. version](#711-version)
115
- - [7.12. log](#712-log)
116
- - [8. Credits](#8-credits)
117
-
118
- ## 1.2. Example
119
-
120
- bo.py
121
- ```python
122
- from grongier.pex import BusinessOperation,Message
123
-
124
- class MyBusinessOperation(BusinessOperation):
125
-
126
- def on_init(self):
127
- #This method is called when the component is becoming active in the production
128
-
129
- self.log_info("[Python] ...MyBusinessOperation:on_init() is called")
130
-
131
- return
132
-
133
- def on_teardown(self):
134
- #This method is called when the component is becoming inactive in the production
135
-
136
- self.log_info("[Python] ...MyBusinessOperation:on_teardown() is called")
137
-
138
- return
139
-
140
- def on_message(self, message_input:MyRequest):
141
- # called from service/process/operation, message is of type MyRequest with property request_string
142
-
143
- self.log_info("[Python] ...MyBusinessOperation:on_message() is called with message:"+message_input.request_string)
144
-
145
- response = MyResponse("...MyBusinessOperation:on_message() echos")
146
-
147
- return response
148
-
149
- @dataclass
150
- class MyRequest(Message):
151
-
152
- request_string:str = None
153
-
154
- @dataclass
155
- class MyResponse(Message):
156
-
157
- my_string:str = None
158
-
159
- ```
160
-
161
- ## 1.3. Register a component
162
-
163
- To register a component, you need to create a `setting.py` file in the root of your project.<br>
164
-
165
- This file will be used to register your classes and productions.<br>
166
-
167
- e.g.:
168
- setting.py
169
- ```python
170
- from grongier.pex import Utils
171
-
172
- import bo
173
-
174
- CLASSES = {
175
- "Python.MyBusinessOperation": bo.MyBusinessOperation
176
- }
177
- ```
178
-
179
- Then you can use the `iop` command line to register your component.
180
-
181
- ```sh
182
- iop --migrate /path/to/your/project/setting.py
183
- ```
184
-
185
- # 2. Demo
186
-
187
- You can find a demo in the [src/python/demo](src/python/demo) folder.
188
-
189
- Other demos are aviailable in those repositories:
190
-
191
- - [training](https://github.com/grongierisc/formation-template-python)
192
- - [template](https://github.com/grongierisc/iris-python-interoperability-template)
193
- - [falsk](https://github.com/grongierisc/iris-python-flask-api-template)
194
- - [rest-to-dicom](https://github.com/grongierisc/RestToDicom)
195
-
196
- # 3. Installation
197
-
198
- ## 3.1. With ZPM
199
-
200
- ```objectscript
201
- zpm "install pex-embbeded-python"
202
- ```
203
-
204
- ## 3.2. With PyPI
205
-
206
- ```sh
207
- pip3 install iris-pex-embedded-python
208
- ```
209
-
210
- Import the ObjectScript classes, open an embedded python shell and run :
211
-
212
- ```python
213
- from grongier.pex import Utils
214
- Utils.setup()
215
- ```
216
-
217
- or use `iop` command line :
218
-
219
- ```sh
220
- iop --init
221
- ```
222
-
223
- ### 3.2.1. Known issues
224
-
225
- If the module is not updated, make sure to remove the old version :
226
-
227
- ```sh
228
- pip3 uninstall iris-pex-embedded-python
229
- ```
230
-
231
- or manually remove the `grongier` folder in `<iris_installation>/lib/python/`
232
-
233
- or force the installation with pip :
234
-
235
- ```sh
236
- pip3 install --upgrade iris-pex-embedded-python --target <iris_installation>/lib/python/
237
- ```
238
-
239
- # 4. How to Run the Sample
240
-
241
- ## 4.1. Docker containers
242
-
243
-
244
- In order to have access to the InterSystems images, we need to go to the following url: http://container.intersystems.com. After connecting with our InterSystems credentials, we will get our password to connect to the registry. In the docker VScode addon, in the image tab, by pressing connect registry and entering the same url as before (http://container.intersystems.com) as a generic registry, we will be asked to give our credentials. The login is the usual one but the password is the one we got from the website.
245
-
246
- From there, we should be able to build and compose our containers (with the `docker-compose.yml` and `Dockerfile` files given).
247
-
248
- ## 4.2. Management Portal and VSCode
249
-
250
- This repository is ready for [VS Code](https://code.visualstudio.com/).
251
-
252
- Open the locally-cloned `interoperability-embedeed-python` folder in VS Code.
253
-
254
- If prompted (bottom right corner), install the recommended extensions.
255
-
256
- **IMPORTANT**: When prompted, reopen the folder inside the container so you will be able to use the python components within it. The first time you do this it may take several minutes while the container is readied.
257
-
258
- By opening the folder remote you enable VS Code and any terminals you open within it to use the python components within the container. Configure these to use `/usr/irissys/bin/irispython`
259
-
260
- <img width="1614" alt="PythonInterpreter" src="https://user-images.githubusercontent.com/47849411/145864423-2de24aaa-036c-4beb-bda0-3a73fe15ccbd.png">
261
-
262
- ## 4.3. Open the production
263
- To open the production you can go to [production](http://localhost:52773/csp/irisapp/EnsPortal.ProductionConfig.zen?PRODUCTION=PEX.Production).<br>
264
- You can also click on the bottom on the `127.0.0.1:52773[IRISAPP]` button and select `Open Management Portal` then, click on [Interoperability] and [Configure] menus then click [productions] and [Go].
265
-
266
- The production already has some code sample.
267
-
268
- Here we can see the production and our pure python services and operations:
269
- <img width="1177" alt="interop-screenshot" src="https://user-images.githubusercontent.com/47849411/131305197-d19511fd-6e05-4aec-a525-c88e6ebd0971.png">
270
-
271
- <br>
272
-
273
- New json trace for python native messages :
274
- <img width="910" alt="json-message-trace" src="https://user-images.githubusercontent.com/47849411/131305211-b8beb2c0-438d-4afc-a6d2-f94d854373ae.png">
275
-
276
- # 5. What's inside the repository
277
-
278
- ## 5.1. Dockerfile
279
-
280
- A dockerfile which install some python dependancies (pip, venv) and sudo in the container for conviencies.
281
- Then it create the dev directory and copy in it this git repository.
282
-
283
- It starts IRIS and activates **%Service_CallIn** for **Python Shell**.
284
- Use the related docker-compose.yml to easily setup additional parametes like port number and where you map keys and host folders.
285
-
286
- This dockerfile ends with the installation of requirements for python modules.
287
-
288
- Use .env/ file to adjust the dockerfile being used in docker-compose.
289
-
290
- ## 5.2. .vscode/settings.json
291
-
292
- Settings file to let you immedietly code in VSCode with [VSCode ObjectScript plugin](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript)
293
-
294
- ## 5.3. .vscode/launch.json
295
- Config file if you want to debug with VSCode ObjectScript
296
-
297
- [Read about all the files in this article](https://community.intersystems.com/post/dockerfile-and-friends-or-how-run-and-collaborate-objectscript-projects-intersystems-iris)
298
-
299
- ## 5.4. .vscode/extensions.json
300
- Recommendation file to add extensions if you want to run with VSCode in the container.
301
-
302
- [More information here](https://code.visualstudio.com/docs/remote/containers)
303
-
304
- This is very useful to work with embedded python.
305
-
306
- ## 5.5. src folder
307
-
308
- ```
309
- src
310
- ├── Grongier
311
- │ └── PEX // ObjectScript classes that wrap python code
312
- │ ├── BusinessOperation.cls
313
- │ ├── BusinessProcess.cls
314
- │ ├── BusinessService.cls
315
- │ ├── Common.cls
316
- │ ├── Director.cls
317
- │ ├── InboundAdapter.cls
318
- │ ├── Message.cls
319
- │ ├── OutboundAdapter.cls
320
- │ ├── Python.cls
321
- │ ├── Test.cls
322
- │ └── _utils.cls
323
- ├── PEX // Some example of wrapped classes
324
- │ └── Production.cls
325
- └── python
326
- ├── demo // Actual python code to run this demo
327
- | `-- reddit
328
- | |-- adapter.py
329
- | |-- bo.py
330
- | |-- bp.py
331
- | |-- bs.py
332
- | |-- message.py
333
- | `-- obj.py
334
- ├── dist // Wheel used to implement python interoperability components
335
- │ └── grongier_pex-1.2.4-py3-none-any.whl
336
- ├── grongier
337
- │ └── pex // Helper classes to implement interoperability components
338
- │ ├── _business_host.py
339
- │ ├── _business_operation.py
340
- │ ├── _business_process.py
341
- │ ├── _business_service.py
342
- │ ├── _common.py
343
- │ ├── _director.py
344
- │ ├── _inbound_adapter.py
345
- │ ├── _message.py
346
- │ ├── _outbound_adapter.py
347
- │ ├── __init__.py
348
- │ └── _utils.py
349
- └── setup.py // setup to build the wheel
350
- ```
351
- # 6. How it works
352
-
353
- ## 6.1. The `__init__.py`file
354
- This file will allow us to create the classes to import in the code.<br>
355
- It gets from the multiple files seen earlier the classes and make them into callable classes.
356
- That way, when you wish to create a business operation, for example, you can just do:
357
- ```python
358
- from grongier.pex import BusinessOperation
359
- ```
360
-
361
- ## 6.2. The `common` class
362
- The common class shouldn't be called by the user, it defines almost all the other classes.<br>
363
- This class defines:
364
-
365
- `on_init`: The on_init() method is called when the component is started.<br> Use the on_init() method to initialize any structures needed by the component.
366
-
367
- `on_tear_down`: Called before the component is terminated.<br> Use it to free any structures.
368
-
369
- `on_connected`: The on_connected() method is called when the component is connected or reconnected after being disconnected.<br>Use the on_connected() method to initialize any structures needed by the component.
370
-
371
- `log_info`: Write a log entry of type "info". :log entries can be viewed in the management portal.
372
-
373
- `log_alert`: Write a log entry of type "alert". :log entries can be viewed in the management portal.
374
-
375
- `log_warning`: Write a log entry of type "warning". :log entries can be viewed in the management portal.
376
-
377
- `log_error`: Write a log entry of type "error". :log entries can be viewed in the management portal.
378
-
379
- ## 6.3. The `business_host` class
380
- The business host class shouldn't be called by the user, it is the base class for all the business classes.<br>
381
- This class defines:
382
-
383
- `send_request_sync`: Send the specified message to the target business process or business operation synchronously.
384
- **Parameters**:<br>
385
- - **target**: a string that specifies the name of the business process or operation to receive the request. <br>
386
- The target is the name of the component as specified in the Item Name property in the production definition, not the class name of the component.
387
- - **request**: specifies the message to send to the target. The request is either an instance of a class that is a subclass of Message class or of IRISObject class.<br>
388
- If the target is a build-in ObjectScript component, you should use the IRISObject class. The IRISObject class enables the PEX framework to convert the message to a class supported by the target.
389
- - **timeout**: an optional integer that specifies the number of seconds to wait before treating the send request as a failure. The default value is -1, which means wait forever.<br>
390
- description: an optional string parameter that sets a description property in the message header. The default is None.
391
-
392
- **Returns**:
393
- the response object from target.
394
-
395
- **Raises**:
396
- TypeError: if request is not of type Message or IRISObject.
397
-
398
- <br><br>
399
-
400
- `send_request_async`: Send the specified message to the target business process or business operation asynchronously.
401
- **Parameters**:<br>
402
- - **target**: a string that specifies the name of the business process or operation to receive the request. <br>
403
- The target is the name of the component as specified in the Item Name property in the production definition, not the class name of the component.
404
- - **request**: specifies the message to send to the target. The request is an instance of IRISObject or of a subclass of Message.<br>
405
- If the target is a built-in ObjectScript component, you should use the IRISObject class. The IRISObject class enables the PEX framework to convert the message to a class supported by the target.
406
- - **description**: an optional string parameter that sets a description property in the message header. The default is None.
407
-
408
- **Raises**:
409
- TypeError: if request is not of type Message or IRISObject.
410
-
411
- <br><br>
412
-
413
- `get_adapter_type`: Name of the registred Adapter.
414
-
415
-
416
- ## 6.4. The `inbound_adapter` class
417
- Inbound Adapter in Python are subclass from grongier.pex.InboundAdapter in Python, that inherit from all the functions of the [common class](#72-the-common-class).<br>
418
- This class is responsible for receiving the data from the external system, validating the data, and sending it to the business service by calling the BusinessHost process_input method.
419
- This class defines:
420
-
421
- `on_task`: Called by the production framework at intervals determined by the business service CallInterval property.<br>
422
- The message can have any structure agreed upon by the inbound adapter and the business service.
423
-
424
- Example of an inbound adapter ( situated in the src/python/demo/reddit/adapter.py file ):
425
- ```python
426
- from grongier.pex import InboundAdapter
427
- import requests
428
- import iris
429
- import json
430
-
431
- class RedditInboundAdapter(InboundAdapter):
432
- """
433
- This adapter use requests to fetch self.limit posts as data from the reddit
434
- API before calling process_input for each post.
435
- """
436
- def on_init(self):
437
-
438
- if not hasattr(self,'feed'):
439
- self.feed = "/new/"
440
-
441
- if self.limit is None:
442
- raise TypeError('no Limit field')
443
-
444
- self.last_post_name = ""
445
-
446
- return 1
447
-
448
- def on_task(self):
449
- self.log_info(f"LIMIT:{self.limit}")
450
- if self.feed == "" :
451
- return 1
452
-
453
- tSC = 1
454
- # HTTP Request
455
- try:
456
- server = "https://www.reddit.com"
457
- request_string = self.feed+".json?before="+self.last_post_name+"&limit="+self.limit
458
- self.log_info(server+request_string)
459
- response = requests.get(server+request_string)
460
- response.raise_for_status()
461
-
462
- data = response.json()
463
- updateLast = 0
464
-
465
- for key, value in enumerate(data['data']['children']):
466
- if value['data']['selftext']=="":
467
- continue
468
- post = iris.cls('dc.Reddit.Post')._New()
469
- post._JSONImport(json.dumps(value['data']))
470
- post.OriginalJSON = json.dumps(value)
471
- if not updateLast:
472
- self.LastPostName = value['data']['name']
473
- updateLast = 1
474
- response = self.BusinessHost.ProcessInput(post)
475
- except requests.exceptions.HTTPError as err:
476
- if err.response.status_code == 429:
477
- self.log_warning(err.__str__())
478
- else:
479
- raise err
480
- except Exception as err:
481
- self.log_error(err.__str__())
482
- raise err
483
-
484
- return tSC
485
- ```
486
-
487
- ## 6.5. The `outbound_adapter` class
488
- Outbound Adapter in Python are subclass from grongier.pex.OutboundAdapter in Python, that inherit from all the functions of the [common class](#72-the-common-class).<br>
489
- This class is responsible for sending the data to the external system.
490
-
491
- The Outbound Adapter gives the Operation the possibility to have a heartbeat notion.
492
- To activate this option, the CallInterval parameter of the adapter must be strictly greater than 0.
493
-
494
- <img width="301" alt="image" src="https://user-images.githubusercontent.com/47849411/178230243-39806602-a63d-4a89-9563-fcf6836d0515.png">
495
-
496
- Example of an outbound adapter ( situated in the src/python/demo/reddit/adapter.py file ):
497
-
498
- ```python
499
- class TestHeartBeat(OutboundAdapter):
500
-
501
- def on_keepalive(self):
502
- self.log_info('beep')
503
-
504
- def on_task(self):
505
- self.log_info('on_task')
506
- ```
507
-
508
- ## 6.6. The `business_service` class
509
- This class is responsible for receiving the data from external system and sending it to business processes or business operations in the production.<br>
510
- The business service can use an adapter to access the external system, which is specified overriding the get_adapter_type method.<br>
511
- There are three ways of implementing a business service:<br>
512
- - Polling business service with an adapter - The production framework at regular intervals calls the adapter’s OnTask() method,
513
- which sends the incoming data to the the business service ProcessInput() method, which, in turn calls the OnProcessInput method with your code.
514
-
515
- - Polling business service that uses the default adapter - In this case, the framework calls the default adapter's OnTask method with no data.
516
- The OnProcessInput() method then performs the role of the adapter and is responsible for accessing the external system and receiving the data.
517
-
518
- - Nonpolling business service - The production framework does not initiate the business service. Instead custom code in either a long-running process
519
- or one that is started at regular intervals initiates the business service by calling the Director.CreateBusinessService() method.
520
-
521
- Business service in Python are subclass from grongier.pex.BusinessService in Python, that inherit from all the functions of the [business host](#73-the-business_host-class).<br>
522
- This class defines:
523
-
524
- `on_process_input`: Receives the message from the inbond adapter via the PRocessInput method and is responsible for forwarding it to target business processes or operations.<br>
525
- If the business service does not specify an adapter, then the default adapter calls this method with no message and the business service is responsible for receiving the data from the external system and validating it.
526
- **Parameters**:<br>
527
- - **message_input**: an instance of IRISObject or subclass of Message containing the data that the inbound adapter passes in.<br>
528
- The message can have any structure agreed upon by the inbound adapter and the business service.
529
-
530
- <br><br>
531
-
532
- Example of a business service ( situated in the src/python/demo/reddit/bs.py file ):
533
- ```python
534
- from grongier.pex import BusinessService
535
-
536
- import iris
537
-
538
- from message import PostMessage
539
- from obj import PostClass
540
-
541
- class RedditServiceWithPexAdapter(BusinessService):
542
- """
543
- This service use our python Python.RedditInboundAdapter to receive post
544
- from reddit and call the FilterPostRoutingRule process.
545
- """
546
- def get_adapter_type():
547
- """
548
- Name of the registred Adapter
549
- """
550
- return "Python.RedditInboundAdapter"
551
-
552
- def on_process_input(self, message_input):
553
- msg = iris.cls("dc.Demo.PostMessage")._New()
554
- msg.Post = message_input
555
- return self.send_request_sync(self.target,msg)
556
-
557
- def on_init(self):
558
-
559
- if not hasattr(self,'target'):
560
- self.target = "Python.FilterPostRoutingRule"
561
-
562
- return
563
- ```
564
-
565
-
566
- ## 6.7. The `business_process` class
567
- Typically contains most of the logic in a production.<br>
568
- A business process can receive messages from a business service, another business process, or a business operation.<br>
569
- It can modify the message, convert it to a different format, or route it based on the message contents.<br>
570
- The business process can route a message to a business operation or another business process.<br>
571
- Business processes in Python are subclass from grongier.pex.BusinessProcess in Python, that inherit from all the functions of the [business host](#73-the-business_host-class).<br>
572
- This class defines:
573
-
574
- `on_request`: Handles requests sent to the business process. A production calls this method whenever an initial request for a specific business process arrives on the appropriate queue and is assigned a job in which to execute.<br>
575
- **Parameters**:<br>
576
- - **request**: An instance of IRISObject or subclass of Message that contains the request message sent to the business process.
577
-
578
- **Returns**:
579
- An instance of IRISObject or subclass of Message that contains the response message that this business process can return
580
- to the production component that sent the initial message.
581
-
582
- <br><br>
583
-
584
- `on_response`: Handles responses sent to the business process in response to messages that it sent to the target.<br>
585
- A production calls this method whenever a response for a specific business process arrives on the appropriate queue and is assigned a job in which to execute.<br>
586
- Typically this is a response to an asynchronous request made by the business process where the responseRequired parameter has a true value.<br>
587
- **Parameters**:<br>
588
- - **request**: An instance of IRISObject or subclass of Message that contains the initial request message sent to the business process.
589
- - **response**: An instance of IRISObject or subclass of Message that contains the response message that this business process can return to the production component that sent the initial message.
590
- - **callRequest**: An instance of IRISObject or subclass of Message that contains the request that the business process sent to its target.
591
- - **callResponse**: An instance of IRISObject or subclass of Message that contains the incoming response.
592
- - **completionKey**: A string that contains the completionKey specified in the completionKey parameter of the outgoing SendAsync() method.
593
-
594
- **Returns**:
595
- An instance of IRISObject or subclass of Message that contains the response message that this business process can return
596
- to the production component that sent the initial message.
597
-
598
- <br><br>
599
-
600
- `on_complete`: Called after the business process has received and handled all responses to requests it has sent to targets.<br>
601
- **Parameters**:
602
- - **request**: An instance of IRISObject or subclass of Message that contains the initial request message sent to the business process.<br>
603
- - **response**: An instance of IRISObject or subclass of Message that contains the response message that this business process can return to the production component that sent the initial message.
604
-
605
- **Returns**:
606
- An instance of IRISObject or subclass of Message that contains the response message that this business process can return to the production component that sent the initial message.
607
-
608
- <br><br>
609
-
610
- Example of a business process ( situated in the src/python/demo/reddit/bp.py file ):
611
- ```python
612
- from grongier.pex import BusinessProcess
613
-
614
- from message import PostMessage
615
- from obj import PostClass
616
-
617
- class FilterPostRoutingRule(BusinessProcess):
618
- """
619
- This process receive a PostMessage containing a reddit post.
620
- It then understand if the post is about a dog or a cat or nothing and
621
- fill the right infomation inside the PostMessage before sending it to
622
- the FileOperation operation.
623
- """
624
- def on_init(self):
625
-
626
- if not hasattr(self,'target'):
627
- self.target = "Python.FileOperation"
628
-
629
- return
630
-
631
- def on_request(self, request):
632
-
633
- if 'dog'.upper() in request.post.selftext.upper():
634
- request.to_email_address = 'dog@company.com'
635
- request.found = 'Dog'
636
- if 'cat'.upper() in request.post.selftext.upper():
637
- request.to_email_address = 'cat@company.com'
638
- request.found = 'Cat'
639
-
640
- if request.found is not None:
641
- return self.send_request_sync(self.target,request)
642
- else:
643
- return
644
- ```
645
-
646
- ## 6.8. The `business_operation` class
647
- This class is responsible for sending the data to an external system or a local system such as an iris database.<br>
648
- The business operation can optionally use an adapter to handle the outgoing message which is specified overriding the get_adapter_type method.<br>
649
- If the business operation has an adapter, it uses the adapter to send the message to the external system.<br>
650
- The adapter can either be a PEX adapter, an ObjectScript adapter or a [python adapter](#75-the-outbound_adapter-class).<br>
651
- Business operation in Python are subclass from grongier.pex.BusinessOperation in Python, that inherit from all the functions of the [business host](#73-the-business_host-class).<br>
652
-
653
- ### 6.8.1. The dispacth system
654
- In a business operation it is possbile to create any number of function [similar to the on_message method](#782-the-methods) that will take as argument a [typed request](#711-the-messages) like this `my_special_message_method(self,request: MySpecialMessage)`.
655
-
656
- The dispatch system will automatically analyze any request arriving to the operation and dispacth the requests depending of their type. If the type of the request is not recognized or is not specified in any **on_message like function**, the dispatch system will send it to the `on_message` function.
657
-
658
- ### 6.8.2. The methods
659
- This class defines:
660
-
661
- `on_message`: Called when the business operation receives a message from another production component [that can not be dispatched to another function](#781-the-dispacth-system).<br>
662
- Typically, the operation will either send the message to the external system or forward it to a business process or another business operation.
663
- If the operation has an adapter, it uses the Adapter.invoke() method to call the method on the adapter that sends the message to the external system.
664
- If the operation is forwarding the message to another production component, it uses the SendRequestAsync() or the SendRequestSync() method.<br>
665
- **Parameters**:
666
- - **request**: An instance of either a subclass of Message or of IRISObject containing the incoming message for the business operation.
667
-
668
- **Returns**:
669
- The response object
670
-
671
- Example of a business operation ( situated in the src/python/demo/reddit/bo.py file ):
672
- ```python
673
- from grongier.pex import BusinessOperation
674
-
675
- from message import MyRequest,MyMessage
676
-
677
- import iris
678
-
679
- import os
680
- import datetime
681
- import smtplib
682
- from email.mime.text import MIMEText
683
-
684
- class EmailOperation(BusinessOperation):
685
- """
686
- This operation receive a PostMessage and send an email with all the
687
- important information to the concerned company ( dog or cat company )
688
- """
689
-
690
- def my_message(self,request:MyMessage):
691
- sender = 'admin@example.com'
692
- receivers = 'toto@example.com'
693
- port = 1025
694
- msg = MIMEText(request.toto)
695
-
696
- msg['Subject'] = 'MyMessage'
697
- msg['From'] = sender
698
- msg['To'] = receivers
699
-
700
- with smtplib.SMTP('localhost', port) as server:
701
- server.sendmail(sender, receivers, msg.as_string())
702
- print("Successfully sent email")
703
-
704
- def on_message(self, request):
705
-
706
- sender = 'admin@example.com'
707
- receivers = [ request.to_email_address ]
708
-
709
-
710
- port = 1025
711
- msg = MIMEText('This is test mail')
712
-
713
- msg['Subject'] = request.found+" found"
714
- msg['From'] = 'admin@example.com'
715
- msg['To'] = request.to_email_address
716
-
717
- with smtplib.SMTP('localhost', port) as server:
718
-
719
- # server.login('username', 'password')
720
- server.sendmail(sender, receivers, msg.as_string())
721
- print("Successfully sent email")
722
-
723
- ```
724
- If this operation is called using a MyRequest message, the my_message function will be called thanks to the dispatcher, otherwise the on_message function will be called.
725
-
726
- ## 6.9. The `director` class
727
- The Director class is used for nonpolling business services, that is, business services which are not automatically called by the production framework (through the inbound adapter) at the call interval.<br>
728
- Instead these business services are created by a custom application by calling the Director.create_business_service() method.<br>
729
- This class defines:
730
-
731
- `create_business_service`: The create_business_service() method initiates the specified business service.<br>
732
- **Parameters**:
733
- - **connection**: an IRISConnection object that specifies the connection to an IRIS instance for Java.
734
- - **target**: a string that specifies the name of the business service in the production definition.
735
-
736
- **Returns**:
737
- an object that contains an instance of IRISBusinessService
738
-
739
- `start_production`: The start_production() method starts the production.<br>
740
- **Parameters**:
741
- - **production_name**: a string that specifies the name of the production to start.
742
-
743
- `stop_production`: The stop_production() method stops the production.<br>
744
- **Parameters**:
745
- - **production_name**: a string that specifies the name of the production to stop.
746
-
747
- `restart_production`: The restart_production() method restarts the production.<br>
748
- **Parameters**:
749
- - **production_name**: a string that specifies the name of the production to restart.
750
-
751
- `list_productions`: The list_productions() method returns a dictionary of the names of the productions that are currently running.<br>
752
-
753
- ## 6.10. The `objects`
754
- We will use `dataclass` to hold information in our [messages](#711-the-messages) in a `obj.py` file.
755
-
756
- Example of an object ( situated in the src/python/demo/reddit/obj.py file ):
757
- ```python
758
- from dataclasses import dataclass
759
-
760
- @dataclass
761
- class PostClass:
762
- title: str
763
- selftext : str
764
- author: str
765
- url: str
766
- created_utc: float = None
767
- original_json: str = None
768
- ```
769
-
770
- ## 6.11. The `messages`
771
- The messages will contain one or more [objects](#710-the-objects), located in the `obj.py` file.<br>
772
- Messages, requests and responses all inherit from the `grongier.pex.Message` class.
773
-
774
- These messages will allow us to transfer information between any business service/process/operation.
775
-
776
- Example of a message ( situated in the src/python/demo/reddit/message.py file ):
777
- ```python
778
- from grongier.pex import Message
779
-
780
- from dataclasses import dataclass
781
-
782
- from obj import PostClass
783
-
784
- @dataclass
785
- class PostMessage(Message):
786
- post:PostClass = None
787
- to_email_address:str = None
788
- found:str = None
789
- ```
790
-
791
- WIP It is to be noted that it is needed to use types when you define an object or a message.
792
-
793
- ## 6.12. How to regsiter a component
794
-
795
- You can register a component to iris in many way :
796
- * Only one component with `register_component`
797
- * All the component in a file with `register_file`
798
- * All the component in a folder with `register_folder`
799
-
800
- ### 6.12.1. register_component
801
-
802
- Start an embedded python shell :
803
-
804
- ```sh
805
- /usr/irissys/bin/irispython
806
- ```
807
-
808
- Then use this class method to add a new py file to the component list for interoperability.
809
-
810
- ```python
811
- from grongier.pex import Utils
812
- Utils.register_component(<ModuleName>,<ClassName>,<PathToPyFile>,<OverWrite>,<NameOfTheComponent>)
813
- ```
814
-
815
- e.g :
816
- ```python
817
- from grongier.pex import Utils
818
- Utils.register_component("MyCombinedBusinessOperation","MyCombinedBusinessOperation","/irisdev/app/src/python/demo/",1,"PEX.MyCombinedBusinessOperation")
819
- ```
820
-
821
- ### 6.12.2. register_file
822
-
823
- Start an embedded python shell :
824
-
825
- ```sh
826
- /usr/irissys/bin/irispython
827
- ```
828
-
829
- Then use this class method to add a new py file to the component list for interoperability.
830
-
831
- ```python
832
- from grongier.pex import Utils
833
- Utils.register_file(<File>,<OverWrite>,<PackageName>)
834
- ```
835
-
836
- e.g :
837
- ```python
838
- from grongier.pex import Utils
839
- Utils.register_file("/irisdev/app/src/python/demo/bo.py",1,"PEX")
840
- ```
841
-
842
- ### 6.12.3. register_folder
843
-
844
- Start an embedded python shell :
845
-
846
- ```sh
847
- /usr/irissys/bin/irispython
848
- ```
849
-
850
- Then use this class method to add a new py file to the component list for interoperability.
851
-
852
- ```python
853
- from grongier.pex import Utils
854
- Utils.register_folder(<Path>,<OverWrite>,<PackageName>)
855
- ```
856
-
857
- e.g :
858
- ```python
859
- from grongier.pex import Utils
860
- Utils.register_folder("/irisdev/app/src/python/demo/",1,"PEX")
861
- ```
862
-
863
- ### 6.12.4. migrate
864
-
865
- Start an embedded python shell :
866
-
867
- ```sh
868
- /usr/irissys/bin/irispython
869
- ```
870
-
871
- Then use this static method to migrate the settings file to the iris framework.
872
-
873
- ```python
874
- from grongier.pex import Utils
875
- Utils.migrate()
876
- ```
877
-
878
- #### 6.12.4.1. setting.py file
879
-
880
- This file is used to store the settings of the interoperability components.
881
-
882
- It has two sections :
883
- * `CLASSES` : This section is used to store the classes of the interoperability components.
884
- * `PRODUCTIONS` : This section is used to store the productions of the interoperability components.
885
-
886
- e.g :
887
- ```python
888
- import bp
889
- from bo import *
890
- from bs import *
891
-
892
- CLASSES = {
893
- 'Python.RedditService': RedditService,
894
- 'Python.FilterPostRoutingRule': bp.FilterPostRoutingRule,
895
- 'Python.FileOperation': FileOperation,
896
- 'Python.FileOperationWithIrisAdapter': FileOperationWithIrisAdapter,
897
- }
898
-
899
- PRODUCTIONS = [
900
- {
901
- 'dc.Python.Production': {
902
- "@Name": "dc.Demo.Production",
903
- "@TestingEnabled": "true",
904
- "@LogGeneralTraceEvents": "false",
905
- "Description": "",
906
- "ActorPoolSize": "2",
907
- "Item": [
908
- {
909
- "@Name": "Python.FileOperation",
910
- "@Category": "",
911
- "@ClassName": "Python.FileOperation",
912
- "@PoolSize": "1",
913
- "@Enabled": "true",
914
- "@Foreground": "false",
915
- "@Comment": "",
916
- "@LogTraceEvents": "true",
917
- "@Schedule": "",
918
- "Setting": {
919
- "@Target": "Host",
920
- "@Name": "%settings",
921
- "#text": "path=/tmp"
922
- }
923
- },
924
- {
925
- "@Name": "Python.RedditService",
926
- "@Category": "",
927
- "@ClassName": "Python.RedditService",
928
- "@PoolSize": "1",
929
- "@Enabled": "true",
930
- "@Foreground": "false",
931
- "@Comment": "",
932
- "@LogTraceEvents": "false",
933
- "@Schedule": "",
934
- "Setting": [
935
- {
936
- "@Target": "Host",
937
- "@Name": "%settings",
938
- "#text": "limit=10\nother<10"
939
- }
940
- ]
941
- },
942
- {
943
- "@Name": "Python.FilterPostRoutingRule",
944
- "@Category": "",
945
- "@ClassName": "Python.FilterPostRoutingRule",
946
- "@PoolSize": "1",
947
- "@Enabled": "true",
948
- "@Foreground": "false",
949
- "@Comment": "",
950
- "@LogTraceEvents": "false",
951
- "@Schedule": ""
952
- }
953
- ]
954
- }
955
- }
956
- ]
957
- ```
958
-
959
- ##### 6.12.4.1.1. CLASSES section
960
-
961
- This section is used to store the classes of the interoperability components.
962
-
963
- It aims to help to register the components.
964
-
965
- This dictionary has the following structure :
966
- * Key : The name of the component
967
- * Value :
968
- * The class of the component (you have to import it before)
969
- * The module of the component (you have to import it before)
970
- * Another dictionary with the following structure :
971
- * `module` : Name of the module of the component (optional)
972
- * `class` : Name of the class of the component (optional)
973
- * `path` : The path of the component (mandatory)
974
-
975
- e.g :
976
-
977
- When Value is a class or a module:
978
- ```python
979
- import bo
980
- import bp
981
- from bs import RedditService
982
-
983
- CLASSES = {
984
- 'Python.RedditService': RedditService,
985
- 'Python.FilterPostRoutingRule': bp.FilterPostRoutingRule,
986
- 'Python.FileOperation': bo,
987
- }
988
- ```
989
-
990
- When Value is a dictionary :
991
- ```python
992
- CLASSES = {
993
- 'Python.RedditService': {
994
- 'module': 'bs',
995
- 'class': 'RedditService',
996
- 'path': '/irisdev/app/src/python/demo/'
997
- },
998
- 'Python.Module': {
999
- 'module': 'bp',
1000
- 'path': '/irisdev/app/src/python/demo/'
1001
- },
1002
- 'Python.Package': {
1003
- 'path': '/irisdev/app/src/python/demo/'
1004
- },
1005
- }
1006
- ```
1007
-
1008
- ##### 6.12.4.1.2. Productions section
1009
-
1010
- This section is used to store the productions of the interoperability components.
1011
-
1012
- It aims to help to register a production.
1013
-
1014
- This list has the following structure :
1015
- * A list of dictionary with the following structure :
1016
- * `dc.Python.Production` : The name of the production
1017
- * `@Name` : The name of the production
1018
- * `@TestingEnabled` : The testing enabled of the production
1019
- * `@LogGeneralTraceEvents` : The log general trace events of the production
1020
- * `Description` : The description of the production
1021
- * `ActorPoolSize` : The actor pool size of the production
1022
- * `Item` : The list of the items of the production
1023
- * `@Name` : The name of the item
1024
- * `@Category` : The category of the item
1025
- * `@ClassName` : The class name of the item
1026
- * `@PoolSize` : The pool size of the item
1027
- * `@Enabled` : The enabled of the item
1028
- * `@Foreground` : The foreground of the item
1029
- * `@Comment` : The comment of the item
1030
- * `@LogTraceEvents` : The log trace events of the item
1031
- * `@Schedule` : The schedule of the item
1032
- * `Setting` : The list of the settings of the item
1033
- * `@Target` : The target of the setting
1034
- * `@Name` : The name of the setting
1035
- * `#text` : The value of the setting
1036
-
1037
- The minimum structure of a production is :
1038
- ```python
1039
- PRODUCTIONS = [
1040
- {
1041
- 'UnitTest.Production': {
1042
- "Item": [
1043
- {
1044
- "@Name": "Python.FileOperation",
1045
- "@ClassName": "Python.FileOperation",
1046
- },
1047
- {
1048
- "@Name": "Python.EmailOperation",
1049
- "@ClassName": "UnitTest.Package.EmailOperation"
1050
- }
1051
- ]
1052
- }
1053
- }
1054
- ]
1055
- ```
1056
-
1057
- You can also set in `@ClassName` an item from the CLASSES section.
1058
-
1059
- e.g :
1060
- ```python
1061
- from bo import FileOperation
1062
- PRODUCTIONS = [
1063
- {
1064
- 'UnitTest.Production': {
1065
- "Item": [
1066
- {
1067
- "@Name": "Python.FileOperation",
1068
- "@ClassName": FileOperation,
1069
- }
1070
- ]
1071
- }
1072
- }
1073
- ]
1074
- ```
1075
-
1076
- As the production is a dictionary, you can add in value of the production dictionary an environment variable.
1077
-
1078
- e.g :
1079
- ```python
1080
- import os
1081
-
1082
- PRODUCTIONS = [
1083
- {
1084
- 'UnitTest.Production': {
1085
- "Item": [
1086
- {
1087
- "@Name": "Python.FileOperation",
1088
- "@ClassName": "Python.FileOperation",
1089
- "Setting": {
1090
- "@Target": "Host",
1091
- "@Name": "%settings",
1092
- "#text": os.environ['SETTINGS']
1093
- }
1094
- }
1095
- ]
1096
- }
1097
- }
1098
- ]
1099
- ```
1100
-
1101
- ## 6.13. Direct use of Grongier.PEX
1102
-
1103
- If you don't want to use the register_component util. You can add a Grongier.PEX.BusinessService component directly into the management portal and configure the properties :
1104
- - %module :
1105
- - Module name of your python code
1106
- - %classname :
1107
- - Classname of you component
1108
- - %classpaths
1109
- - Path where you component is.
1110
- - This can one or more Classpaths (separated by '|' character) needed in addition to PYTHON_PATH
1111
-
1112
- e.g :
1113
- <img width="800" alt="component-config" src="https://user-images.githubusercontent.com/47849411/131316308-e1898b19-11df-433b-b1c6-7f69d5cc9974.png">
1114
-
1115
- # 7. Command line
1116
-
1117
- Since version 2.3.1, you can use the command line to register your components and productions.
1118
-
1119
- To use it, you have to use the following command :
1120
- ```bash
1121
- iop
1122
- ```
1123
-
1124
- output :
1125
- ```bash
1126
- usage: python3 -m grongier.pex [-h] [-d DEFAULT] [-l] [-s START] [-k] [-S] [-r] [-M MIGRATE] [-e EXPORT] [-x] [-v] [-L]
1127
- optional arguments:
1128
- -h, --help display help and default production name
1129
- -d DEFAULT, --default DEFAULT
1130
- set the default production
1131
- -l, --lists list productions
1132
- -s START, --start START
1133
- start a production
1134
- -k, --kill kill a production (force stop)
1135
- -S, --stop stop a production
1136
- -r, --restart restart a production
1137
- -M MIGRATE, --migrate MIGRATE
1138
- migrate production and classes with settings file
1139
- -e EXPORT, --export EXPORT
1140
- export a production
1141
- -x, --status status a production
1142
- -v, --version display version
1143
- -L, --log display log
1144
-
1145
- default production: PEX.Production
1146
- ```
1147
-
1148
- ## 7.1. help
1149
-
1150
- The help command display the help and the default production name.
1151
-
1152
- ```bash
1153
- iop -h
1154
- ```
1155
-
1156
- output :
1157
- ```bash
1158
- usage: python3 -m grongier.pex [-h] [-d DEFAULT] [-l] [-s START] [-k] [-S] [-r] [-M MIGRATE] [-e EXPORT] [-x] [-v] [-L]
1159
- ...
1160
- default production: PEX.Production
1161
- ```
1162
-
1163
- ## 7.2. default
1164
-
1165
- The default command set the default production.
1166
-
1167
- With no argument, it display the default production.
1168
-
1169
- ```bash
1170
- iop -d
1171
- ```
1172
-
1173
- output :
1174
- ```bash
1175
- default production: PEX.Production
1176
- ```
1177
-
1178
- With an argument, it set the default production.
1179
-
1180
- ```bash
1181
- iop -d PEX.Production
1182
- ```
1183
-
1184
- ## 7.3. lists
1185
-
1186
- The lists command list productions.
1187
-
1188
- ```bash
1189
- iop -l
1190
- ```
1191
-
1192
- output :
1193
- ```bash
1194
- {
1195
- "PEX.Production": {
1196
- "Status": "Stopped",
1197
- "LastStartTime": "2023-05-31 11:13:51.000",
1198
- "LastStopTime": "2023-05-31 11:13:54.153",
1199
- "AutoStart": 0
1200
- }
1201
- }
1202
- ```
1203
-
1204
- ## 7.4. start
1205
-
1206
- The start command start a production.
1207
-
1208
- To exit the command, you have to press CTRL+C.
1209
-
1210
- ```bash
1211
- iop -s PEX.Production
1212
- ```
1213
-
1214
- output :
1215
- ```bash
1216
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting production
1217
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.FileOperation
1218
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.EmailOperation
1219
- ...
1220
- ```
1221
-
1222
- ## 7.5. kill
1223
-
1224
- The kill command kill a production (force stop).
1225
-
1226
- Kill command is the same as stop command but with a force stop.
1227
-
1228
- Kill command doesn't take an argument because only one production can be running.
1229
-
1230
- ```bash
1231
- iop -k
1232
- ```
1233
-
1234
- ## 7.6. stop
1235
-
1236
- The stop command stop a production.
1237
-
1238
- Stop command doesn't take an argument because only one production can be running.
1239
-
1240
- ```bash
1241
- iop -S
1242
- ```
1243
-
1244
- ## 7.7. restart
1245
-
1246
- The restart command restart a production.
1247
-
1248
- Restart command doesn't take an argument because only one production can be running.
1249
-
1250
- ```bash
1251
- iop -r
1252
- ```
1253
-
1254
- ## 7.8. migrate
1255
-
1256
- The migrate command migrate a production and classes with settings file.
1257
-
1258
- Migrate command must take the absolute path of the settings file.
1259
-
1260
- Settings file must be in the same folder as the python code.
1261
-
1262
- ```bash
1263
- iop -M /tmp/settings.py
1264
- ```
1265
-
1266
- ## 7.9. export
1267
-
1268
- The export command export a production.
1269
-
1270
- If no argument is given, the export command export the default production.
1271
-
1272
- ```bash
1273
- iop -e
1274
- ```
1275
-
1276
- If an argument is given, the export command export the production given in argument.
1277
-
1278
- ```bash
1279
- iop -e PEX.Production
1280
- ```
1281
-
1282
- output :
1283
- ```bash
1284
- {
1285
- "Production": {
1286
- "@Name": "PEX.Production",
1287
- "@TestingEnabled": "true",
1288
- "@LogGeneralTraceEvents": "false",
1289
- "Description": "",
1290
- "ActorPoolSize": "2",
1291
- "Item": [
1292
- {
1293
- "@Name": "Python.FileOperation",
1294
- "@Category": "",
1295
- "@ClassName": "Python.FileOperation",
1296
- "@PoolSize": "1",
1297
- "@Enabled": "true",
1298
- "@Foreground": "false",
1299
- "@Comment": "",
1300
- "@LogTraceEvents": "true",
1301
- "@Schedule": "",
1302
- "Setting": [
1303
- {
1304
- "@Target": "Adapter",
1305
- "@Name": "Charset",
1306
- "#text": "utf-8"
1307
- },
1308
- {
1309
- "@Target": "Adapter",
1310
- "@Name": "FilePath",
1311
- "#text": "/irisdev/app/output/"
1312
- },
1313
- {
1314
- "@Target": "Host",
1315
- "@Name": "%settings",
1316
- "#text": "path=/irisdev/app/output/"
1317
- }
1318
- ]
1319
- }
1320
- ]
1321
- }
1322
- }
1323
- ```
1324
-
1325
- ## 7.10. status
1326
-
1327
- The status command status a production.
1328
-
1329
- Status command doesn't take an argument because only one production can be running.
1330
-
1331
- ```bash
1332
- iop -x
1333
- ```
1334
-
1335
- output :
1336
- ```bash
1337
- {
1338
- "Production": "PEX.Production",
1339
- "Status": "stopped"
1340
- }
1341
- ```
1342
-
1343
- Status can be :
1344
- - stopped
1345
- - running
1346
- - suspended
1347
- - troubled
1348
-
1349
- ## 7.11. version
1350
-
1351
- The version command display the version.
1352
-
1353
- ```bash
1354
- iop -v
1355
- ```
1356
-
1357
- output :
1358
- ```bash
1359
- 2.3.0
1360
- ```
1361
-
1362
- ## 7.12. log
1363
-
1364
- The log command display the log.
1365
-
1366
- To exit the command, you have to press CTRL+C.
1367
-
1368
- ```bash
1369
- iop -L
1370
- ```
1371
-
1372
- output :
1373
- ```bash
1374
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting production
1375
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.FileOperation
1376
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.EmailOperation
1377
- ...
1378
- ```
1379
-
1380
- # 8. Credits
1381
-
1382
- Most of the code came from PEX for Python by Mo Cheng and Summer Gerry.
1383
-
1384
- Works only on IRIS 2021.2 +