holado 0.4.0__py3-none-any.whl → 0.4.2__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 holado might be problematic. Click here for more details.

Files changed (46) hide show
  1. holado/common/handlers/object.py +6 -0
  2. {holado-0.4.0.dist-info → holado-0.4.2.dist-info}/METADATA +2 -1
  3. {holado-0.4.0.dist-info → holado-0.4.2.dist-info}/RECORD +46 -25
  4. holado_core/tools/abstracts/blocking_command_service.py +9 -1
  5. holado_django/__init__.py +31 -0
  6. holado_django/server/HOWTO.txt +27 -0
  7. holado_django/server/django_projects/rest_api/db.sqlite3 +0 -0
  8. holado_django/server/django_projects/rest_api/manage.py +22 -0
  9. holado_django/server/django_projects/rest_api/rest_api/__init__.py +0 -0
  10. holado_django/server/django_projects/rest_api/rest_api/application/__init__.py +0 -0
  11. holado_django/server/django_projects/rest_api/rest_api/application/admin.py +3 -0
  12. holado_django/server/django_projects/rest_api/rest_api/application/apps.py +9 -0
  13. holado_django/server/django_projects/rest_api/rest_api/application/migrations/__init__.py +0 -0
  14. holado_django/server/django_projects/rest_api/rest_api/application/models.py +3 -0
  15. holado_django/server/django_projects/rest_api/rest_api/application/tests.py +3 -0
  16. holado_django/server/django_projects/rest_api/rest_api/application/views.py +6 -0
  17. holado_django/server/django_projects/rest_api/rest_api/asgi.py +16 -0
  18. holado_django/server/django_projects/rest_api/rest_api/settings.py +130 -0
  19. holado_django/server/django_projects/rest_api/rest_api/urls.py +35 -0
  20. holado_django/server/django_projects/rest_api/rest_api/wsgi.py +16 -0
  21. holado_django/server/django_server.py +110 -0
  22. holado_django/server/grpc_django_server.py +57 -0
  23. holado_django/tests/behave/steps/__init__.py +16 -0
  24. holado_django/tests/behave/steps/django_server_steps.py +83 -0
  25. holado_grpc/tests/behave/steps/private/api/grpc_steps.py +9 -9
  26. holado_logging/common/logging/log_config.py +4 -3
  27. holado_multitask/multitasking/multitask_manager.py +36 -10
  28. holado_python/standard_library/ssl/resources/certificates/tcpbin.crt +16 -16
  29. holado_python/standard_library/ssl/resources/certificates/tcpbin.key +26 -26
  30. holado_python/standard_library/ssl/ssl.py +5 -1
  31. holado_rest/api/rest/TODO.txt +1 -1
  32. holado_rest/api/rest/rest_client.py +9 -7
  33. holado_rest/tests/behave/steps/private/api/rest_steps.py +11 -13
  34. holado_swagger/swagger_hub/mockserver/mockserver_client.py +1 -1
  35. holado_system/system/command/command.py +31 -9
  36. holado_system/system/global_system.py +3 -3
  37. test_holado/environment.py +6 -4
  38. test_holado/features/NonReg/api/REST.feature +7 -2
  39. test_holado/features/NonReg/api/gRPC.feature +0 -6
  40. test_holado/initialize_holado.py +62 -0
  41. test_holado/logging.conf +4 -0
  42. test_holado/tools/django/api_rest/db.sqlite3 +0 -0
  43. {holado-0.4.0.dist-info → holado-0.4.2.dist-info}/WHEEL +0 -0
  44. {holado-0.4.0.dist-info → holado-0.4.2.dist-info}/licenses/LICENSE +0 -0
  45. /holado_helper/holado_module_template/{test → tests}/behave/steps/__init__.py +0 -0
  46. /holado_helper/holado_module_template/{test → tests}/behave/steps/private/__init__.py +0 -0
@@ -20,6 +20,9 @@ import time
20
20
  from enum import IntEnum
21
21
  from holado_core.common.exceptions.functional_exception import FunctionalException
22
22
  import copy
23
+ import signal
24
+ from holado_core.common.tools.tools import Tools
25
+ from holado_multitask.multitasking.multitask_manager import MultitaskManager
23
26
 
24
27
  logger = logging.getLogger(__name__)
25
28
 
@@ -31,6 +34,7 @@ class CommandStates(IntEnum):
31
34
  Success = 3
32
35
  Error = 4
33
36
 
37
+
34
38
  class Command(threading.Thread):
35
39
  """
36
40
  Execute a command in a thread.
@@ -58,6 +62,7 @@ class Command(threading.Thread):
58
62
  self.__callback_delay_ms = None
59
63
  self.__external_parameters = {}
60
64
  self.__subprocess_kwargs = subprocess_kwargs
65
+ self.__stop_signal = signal.SIGTERM
61
66
 
62
67
 
63
68
  @property
@@ -94,29 +99,38 @@ class Command(threading.Thread):
94
99
  return self.__process.returncode
95
100
  else:
96
101
  return None
97
-
102
+
98
103
  @property
99
104
  def callback(self):
100
105
  return self.__callback
101
-
106
+
102
107
  @callback.setter
103
108
  def callback(self, callback):
104
109
  """Set callback called when execution end."""
105
110
  self.__callback = callback
106
-
111
+
107
112
  @property
108
113
  def callback_delay_ms(self):
109
114
  return self.__callback_delay_ms
110
-
115
+
111
116
  @callback_delay_ms.setter
112
117
  def callback_delay_ms(self, delay_ms):
113
118
  """Set callback delay in ms."""
114
119
  self.__callback_delay_ms = delay_ms
115
-
120
+
116
121
  @property
117
122
  def external_parameters(self):
118
123
  return self.__external_parameters
119
-
124
+
125
+ @property
126
+ def stop_signal(self):
127
+ return self.__stop_signal
128
+
129
+ @stop_signal.setter
130
+ def stop_signal(self, stop_signal):
131
+ """Set stop signal."""
132
+ self.__stop_signal = stop_signal
133
+
120
134
  def run(self):
121
135
  logger.debug("Call command: {}".format(self.cmd))
122
136
  try:
@@ -139,7 +153,7 @@ class Command(threading.Thread):
139
153
 
140
154
  self.__stdout = ""
141
155
  self.__stderr = ""
142
- while (self.__process.returncode is None):
156
+ while self.__process.returncode is None:
143
157
  # Wait a small time and in same time yield this thread
144
158
  time.sleep(0.001)
145
159
 
@@ -175,7 +189,7 @@ class Command(threading.Thread):
175
189
  logger.debug(f"Command [{self.cmd}] has finished, calling callback...")
176
190
  self.callback(self)
177
191
  elif self.error is not None:
178
- logger.error(f"Command [{self.cmd}] has finished on error : {self.error}")
192
+ logger.error(f"Command [{self.cmd}] has finished on error: {self.error}")
179
193
  elif self.state == CommandStates.Error:
180
194
  logger.error(f"Command [{self.cmd}] has finished on error code {self.return_code} and stderr: {self.stderr}")
181
195
  elif self.state != CommandStates.Success:
@@ -208,13 +222,21 @@ class Command(threading.Thread):
208
222
  raise FunctionalException(msg)
209
223
 
210
224
  def kill(self):
225
+ # Note: kill is equivalent to terminate in subprocess implementation
211
226
  if self.state == CommandStates.Running:
212
227
  self.__process.kill()
213
228
 
214
229
  def terminate(self):
215
230
  if self.state == CommandStates.Running:
216
231
  self.__process.terminate()
217
-
232
+
233
+ def stop(self):
234
+ if self.state == CommandStates.Running:
235
+ if Tools.do_log(logger, logging.DEBUG):
236
+ logger.debug(f"Stopping command [{self.cmd}] with signal {self.__stop_signal} and PID {self.__process.pid}")
237
+
238
+ MultitaskManager.kill_process(self.__process.pid, sig=self.__stop_signal, do_kill_children=True, recursively=True)
239
+
218
240
  def __repr__(self):
219
241
  return pprint.pformat({'cmd' : self.cmd,
220
242
  'is alive' : self.is_alive() })
@@ -14,9 +14,7 @@
14
14
  import logging
15
15
  from holado.common.handlers.enums import AutoNumber
16
16
  import platform
17
- from holado_system.system.command.command import Command, CommandStates
18
17
  from holado_core.common.exceptions.technical_exception import TechnicalException
19
- from holado_system.system.command.command_result import CommandResult
20
18
  import time
21
19
  import os
22
20
  from holado_core.common.tools.tools import Tools
@@ -87,6 +85,9 @@ class GlobalSystem(object):
87
85
 
88
86
  @classmethod
89
87
  def execute_command(cls, cmd, do_log_output=False, do_raise_on_stderr=False):
88
+ from holado_system.system.command.command import Command, CommandStates
89
+ from holado_system.system.command.command_result import CommandResult
90
+
90
91
  command = Command(cmd, do_log_output=do_log_output, do_raise_on_stderr=do_raise_on_stderr)
91
92
  command.start()
92
93
  command.join()
@@ -183,5 +184,4 @@ class GlobalSystem(object):
183
184
  return port
184
185
  return None
185
186
 
186
-
187
187
 
@@ -19,10 +19,12 @@ import logging
19
19
 
20
20
  # Add testing solution sources paths
21
21
  here = os.path.abspath(os.path.dirname(__file__))
22
- sys.path.append(here)
23
- holado_path = os.path.normpath(os.path.join(here, "..", "..", ".."))
24
- sys.path.append( os.path.join(holado_path, "src") )
25
- sys.path.append( os.path.join(holado_path, "tests", "behave") )
22
+ sys.path.insert(0, here)
23
+
24
+ # Add HolAdo source paths (needed when using a clone of HolAdo project)
25
+ from initialize_holado import insert_holado_source_paths
26
+ insert_holado_source_paths()
27
+
26
28
 
27
29
  # Configure HolAdo
28
30
  import holado
@@ -2,8 +2,7 @@
2
2
  @rest
3
3
  Feature: Test REST module
4
4
 
5
- @go_nogo
6
- @need_update
5
+ #@need_update
7
6
  Scenario: Simple get
8
7
 
9
8
  ### PRECONDITIONS - BEGIN
@@ -18,4 +17,10 @@ Feature: Test REST module
18
17
 
19
18
  When RESULT = get '/users' (REST client: CLIENT)
20
19
  Then RESULT['results'] is list
20
+
21
+ Given TABLE = convert json RESULT['results'] to table with names as columns
22
+ Then table TABLE contains
23
+ | email | groups | url | username |
24
+ | N/A | N/A | N/A | 'admin' |
25
+
21
26
 
@@ -9,8 +9,6 @@ Feature: Test gRPC module
9
9
  Given begin preconditions
10
10
 
11
11
  Given SERVER = start internal gRPC server
12
- When wait 1 seconds
13
-
14
12
  Given CLIENT = new internal gRPC client on service 'account.UserController'
15
13
 
16
14
  Given end preconditions
@@ -33,8 +31,6 @@ Feature: Test gRPC module
33
31
  Given begin preconditions
34
32
 
35
33
  Given SERVER = start internal gRPC server
36
- When wait 1 seconds
37
-
38
34
  Given CLIENT = new internal gRPC client on service 'account.UserController'
39
35
 
40
36
  Given end preconditions
@@ -78,8 +74,6 @@ Feature: Test gRPC module
78
74
  Given begin preconditions
79
75
 
80
76
  Given SERVER = start internal gRPC server
81
- When wait 1 seconds
82
-
83
77
  Given CLIENT = new internal gRPC client on service 'account.UserController'
84
78
 
85
79
  Given end preconditions
@@ -0,0 +1,62 @@
1
+
2
+ #################################################
3
+ # HolAdo (Holistic Automation do)
4
+ #
5
+ # (C) Copyright 2021-2025 by Eric Klumpp
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ # The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
12
+ #################################################
13
+
14
+
15
+ #################################################
16
+ # GOAL: Tools when using a clone of HolAdo project.
17
+ #
18
+ # This file contains methods usefull to initialize environments using a clone of HolAdo project.
19
+ #
20
+ # USAGE:
21
+ # - Copy this file in projects using HolAdo.
22
+ # - Define environment variable HOLADO_PATH with path to cloned HolAdo project.
23
+ # If HOLADO_PATH is defined, sources of cloned HolAdo project are used, else installed holado package is used.
24
+ #################################################
25
+
26
+
27
+
28
+ import os
29
+ import sys
30
+
31
+
32
+ def insert_sys_path(path, index=0):
33
+ """Insert a path in sys.path if it doesn't already exists.
34
+ """
35
+ if path not in sys.path:
36
+ sys.path.insert(index, path)
37
+
38
+ def insert_holado_source_paths(with_test_behave=True):
39
+ """Insert in sys.path all HolAdo source paths.
40
+ If environment variable HOLADO_PATH is defined with path to HolAdo project, following paths are inserted in sys.path:
41
+ - HOLADO_PATH/src: path to holado modules sources
42
+ - HOLADO_PATH/tests/behave (if with_test_behave==True): path to holado test sources, needed by testing solutions
43
+ """
44
+ holado_path = os.getenv('HOLADO_PATH')
45
+ if holado_path is None:
46
+ try:
47
+ import holado # @UnusedImport
48
+ except Exception as exc:
49
+ if "No module named" in str(exc):
50
+ raise Exception(f"If environment variable HOLADO_PATH is not defined with path to HolAdo project, 'holado' python package must be installed")
51
+ else:
52
+ raise exc
53
+ else:
54
+ # holado is installed, and all sources are already accessible
55
+ pass
56
+ else:
57
+ print(f"Using HolAdo project installed in '{holado_path}'")
58
+ insert_sys_path(os.path.join(holado_path, "src"))
59
+ if with_test_behave:
60
+ insert_sys_path(os.path.join(holado_path, "tests", "behave"))
61
+
62
+
test_holado/logging.conf CHANGED
@@ -3,7 +3,9 @@ level=INFO
3
3
  #level=DEBUG
4
4
  #level=TRACE
5
5
  log_on_console=False
6
+ #log_on_console=True
6
7
  log_in_file=True
8
+ #log_in_file=False
7
9
 
8
10
  [loggers_levels]
9
11
  holado=INFO
@@ -22,6 +24,7 @@ holado_multitask=WARNING
22
24
  #holado_protobuf.ipc.protobuf=DEBUG
23
25
  #holado_protobuf.ipc.protobuf.protobuf_messages=TRACE
24
26
  #holado_python.standard_library.socket=DEBUG
27
+ #holado_rest.api/rest=DEBUG
25
28
  #holado_value.common.tables.value_table_cell=TRACE
26
29
  holado_s3.tools.s3.minio_client.trace=INFO
27
30
 
@@ -31,6 +34,7 @@ holado_s3.tools.s3.minio_client.trace=INFO
31
34
  #holado_scripting.common.tools.variable_manager=TRACE
32
35
  #holado_scripting.text.interpreter=TRACE
33
36
 
37
+ #holado_system=DEBUG
34
38
  #holado_test.behave.behave=DEBUG
35
39
 
36
40
  # External libraries
File without changes