zrb 0.18.0__py3-none-any.whl → 0.18.1__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.
- zrb/task/any_task.py +7 -0
- zrb/task/base_task/base_task.py +1 -2
- zrb/task/base_task/component/common_task_model.py +34 -3
- zrb/task/cmd_task.py +21 -8
- {zrb-0.18.0.dist-info → zrb-0.18.1.dist-info}/METADATA +1 -1
- {zrb-0.18.0.dist-info → zrb-0.18.1.dist-info}/RECORD +9 -9
- {zrb-0.18.0.dist-info → zrb-0.18.1.dist-info}/LICENSE +0 -0
- {zrb-0.18.0.dist-info → zrb-0.18.1.dist-info}/WHEEL +0 -0
- {zrb-0.18.0.dist-info → zrb-0.18.1.dist-info}/entry_points.txt +0 -0
zrb/task/any_task.py
CHANGED
zrb/task/base_task/base_task.py
CHANGED
@@ -467,10 +467,9 @@ class BaseTask(FinishTracker, AttemptTracker, Renderer, BaseTaskModel, AnyTask):
|
|
467
467
|
)
|
468
468
|
)
|
469
469
|
# set checker keyval
|
470
|
+
self._lock_checkers()
|
470
471
|
checker_coroutines = []
|
471
472
|
for checker_task in self._get_checkers():
|
472
|
-
checker_task.add_input(*self._get_inputs())
|
473
|
-
checker_task.add_env(*self._get_envs())
|
474
473
|
checker_coroutines.append(
|
475
474
|
asyncio.create_task(
|
476
475
|
checker_task._set_keyval(kwargs=new_kwargs, env_prefix=env_prefix)
|
@@ -65,6 +65,11 @@ class CommonTaskModel:
|
|
65
65
|
self._group = group
|
66
66
|
if group is not None:
|
67
67
|
group._add_task(self)
|
68
|
+
checkers_cp: List[AnyTask] = [checker.copy() for checker in checkers]
|
69
|
+
for checker in checkers_cp:
|
70
|
+
checker.add_env(*envs)
|
71
|
+
checker.add_env_file(*env_files)
|
72
|
+
checker.add_input(*inputs)
|
68
73
|
self._description = coalesce_str(description, name)
|
69
74
|
self._inputs = inputs
|
70
75
|
self._envs = envs
|
@@ -75,7 +80,7 @@ class CommonTaskModel:
|
|
75
80
|
self._retry_interval = retry_interval
|
76
81
|
self._upstreams = upstreams
|
77
82
|
self._fallbacks = fallbacks
|
78
|
-
self._checkers =
|
83
|
+
self._checkers = checkers_cp
|
79
84
|
self._checking_interval = checking_interval
|
80
85
|
self._run_function: Optional[Callable[..., Any]] = run
|
81
86
|
self._on_triggered = on_triggered
|
@@ -101,6 +106,9 @@ class CommonTaskModel:
|
|
101
106
|
self.__has_already_inject_fallbacks: bool = False
|
102
107
|
self.__all_inputs: Optional[List[AnyInput]] = None
|
103
108
|
|
109
|
+
def _lock_checkers(self):
|
110
|
+
self.__allow_add_checkers = False
|
111
|
+
|
104
112
|
def _lock_upstreams(self):
|
105
113
|
self.__allow_add_upstreams = False
|
106
114
|
|
@@ -164,11 +172,15 @@ class CommonTaskModel:
|
|
164
172
|
if not self.__allow_add_inputs:
|
165
173
|
raise Exception(f"Cannot insert inputs for `{self.get_name()}`")
|
166
174
|
self._inputs = list(inputs) + list(self._inputs)
|
175
|
+
for checker in self._get_checkers():
|
176
|
+
checker.insert_input(*inputs)
|
167
177
|
|
168
178
|
def add_input(self, *inputs: AnyInput):
|
169
179
|
if not self.__allow_add_inputs:
|
170
180
|
raise Exception(f"Cannot add inputs for `{self.get_name()}`")
|
171
181
|
self._inputs = list(self._inputs) + list(inputs)
|
182
|
+
for checker in self._get_checkers():
|
183
|
+
checker.add_input(*inputs)
|
172
184
|
|
173
185
|
def inject_inputs(self):
|
174
186
|
pass
|
@@ -219,11 +231,15 @@ class CommonTaskModel:
|
|
219
231
|
if not self.__allow_add_envs:
|
220
232
|
raise Exception(f"Cannot insert envs to `{self.get_name()}`")
|
221
233
|
self._envs = list(envs) + list(self._envs)
|
234
|
+
for checker in self._get_checkers():
|
235
|
+
checker.insert_env(*envs)
|
222
236
|
|
223
237
|
def add_env(self, *envs: Env):
|
224
238
|
if not self.__allow_add_envs:
|
225
239
|
raise Exception(f"Cannot add envs to `{self.get_name()}`")
|
226
240
|
self._envs = list(self._envs) + list(envs)
|
241
|
+
for checker in self._get_checkers():
|
242
|
+
checker.add_env(*envs)
|
227
243
|
|
228
244
|
def inject_envs(self):
|
229
245
|
pass
|
@@ -255,11 +271,15 @@ class CommonTaskModel:
|
|
255
271
|
if not self.__allow_add_env_files:
|
256
272
|
raise Exception(f"Cannot insert env_files to `{self.get_name()}`")
|
257
273
|
self._env_files = list(env_files) + list(self._env_files)
|
274
|
+
for checker in self._get_checkers():
|
275
|
+
checker.insert_env_file(*env_files)
|
258
276
|
|
259
277
|
def add_env_file(self, *env_files: EnvFile):
|
260
278
|
if not self.__allow_add_env_files:
|
261
279
|
raise Exception(f"Cannot add env_files to `{self.get_name()}`")
|
262
280
|
self._env_files = list(self._env_files) + list(env_files)
|
281
|
+
for checker in self._get_checkers():
|
282
|
+
checker.add_env_file(*env_files)
|
263
283
|
|
264
284
|
def inject_env_files(self):
|
265
285
|
pass
|
@@ -317,15 +337,26 @@ class CommonTaskModel:
|
|
317
337
|
def insert_checker(self, *checkers: AnyTask):
|
318
338
|
if not self.__allow_add_checkers:
|
319
339
|
raise Exception(f"Cannot insert checkers to `{self.get_name()}`")
|
320
|
-
additional_checkers =
|
340
|
+
additional_checkers = self.__complete_new_checkers(checkers)
|
321
341
|
self._checkers = additional_checkers + self._checkers
|
322
342
|
|
323
343
|
def add_checker(self, *checkers: AnyTask):
|
324
344
|
if not self.__allow_add_checkers:
|
325
345
|
raise Exception(f"Cannot add checkers to `{self.get_name()}`")
|
326
|
-
additional_checkers =
|
346
|
+
additional_checkers = self.__complete_new_checkers(checkers)
|
327
347
|
self._checkers = self._checkers + additional_checkers
|
328
348
|
|
349
|
+
def __complete_new_checkers(self, new_checkers: List[AnyTask]) -> List[AnyTask]:
|
350
|
+
"""
|
351
|
+
For internal use: copy and completing new checkers
|
352
|
+
"""
|
353
|
+
checkers: List[AnyTask] = [checker.copy() for checker in new_checkers]
|
354
|
+
for checker in checkers:
|
355
|
+
checker.add_input(*self._get_inputs())
|
356
|
+
checker.add_env(*self._get_envs())
|
357
|
+
checker.add_env_file(*self._get_env_files())
|
358
|
+
return checkers
|
359
|
+
|
329
360
|
def inject_checkers(self):
|
330
361
|
pass
|
331
362
|
|
zrb/task/cmd_task.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import asyncio
|
2
2
|
import atexit
|
3
|
+
import logging
|
3
4
|
import os
|
4
5
|
import pathlib
|
5
6
|
import signal
|
@@ -7,7 +8,7 @@ import subprocess
|
|
7
8
|
import sys
|
8
9
|
import time
|
9
10
|
|
10
|
-
from zrb.config.config import default_shell
|
11
|
+
from zrb.config.config import default_shell, logging_level
|
11
12
|
from zrb.helper.accessories.color import colored
|
12
13
|
from zrb.helper.log import logger
|
13
14
|
from zrb.helper.typecheck import typechecked
|
@@ -55,6 +56,18 @@ def _reset_stty():
|
|
55
56
|
_has_stty = False
|
56
57
|
|
57
58
|
|
59
|
+
def _log_error(message: Any):
|
60
|
+
if logging_level > logging.ERROR:
|
61
|
+
return
|
62
|
+
colored_message = colored(f"{message}", color="red", attrs=["bold"])
|
63
|
+
logger.error(colored_message, exc_info=True)
|
64
|
+
|
65
|
+
|
66
|
+
def _print_out_dark(message: Any):
|
67
|
+
message_str = f"{message}"
|
68
|
+
print(colored(message_str, attrs=["dark"]), file=sys.stderr)
|
69
|
+
|
70
|
+
|
58
71
|
CmdVal = Union[
|
59
72
|
JinjaTemplate,
|
60
73
|
Iterable[JinjaTemplate],
|
@@ -272,7 +285,7 @@ class CmdTask(BaseTask):
|
|
272
285
|
def __on_kill(self, signum: Any, frame: Any):
|
273
286
|
self._global_state.no_more_attempt = True
|
274
287
|
self._global_state.is_killed_by_signal = True
|
275
|
-
|
288
|
+
_print_out_dark(f"Getting signal {signum}")
|
276
289
|
for pid in self._pids:
|
277
290
|
self.__kill_by_pid(pid)
|
278
291
|
tasks = asyncio.all_tasks()
|
@@ -282,7 +295,7 @@ class CmdTask(BaseTask):
|
|
282
295
|
except Exception as e:
|
283
296
|
self.print_err(e)
|
284
297
|
time.sleep(0.3)
|
285
|
-
|
298
|
+
_print_out_dark(f"Exiting with signal {signum}")
|
286
299
|
sys.exit(signum)
|
287
300
|
|
288
301
|
def __on_exit(self):
|
@@ -297,20 +310,20 @@ class CmdTask(BaseTask):
|
|
297
310
|
process_ever_exists = False
|
298
311
|
if self.__is_process_exist(pid):
|
299
312
|
process_ever_exists = True
|
300
|
-
|
313
|
+
_print_out_dark(f"Send SIGTERM to process {pid}")
|
301
314
|
os.killpg(os.getpgid(pid), signal.SIGTERM)
|
302
315
|
time.sleep(0.3)
|
303
316
|
if self.__is_process_exist(pid):
|
304
|
-
|
317
|
+
_print_out_dark(f"Send SIGINT to process {pid}")
|
305
318
|
os.killpg(os.getpgid(pid), signal.SIGINT)
|
306
319
|
time.sleep(0.3)
|
307
320
|
if self.__is_process_exist(pid):
|
308
|
-
|
321
|
+
_print_out_dark(f"Send SIGKILL to process {pid}")
|
309
322
|
os.killpg(os.getpgid(pid), signal.SIGKILL)
|
310
323
|
if process_ever_exists:
|
311
|
-
|
324
|
+
_print_out_dark(f"Process {pid} is killed successfully")
|
312
325
|
except Exception:
|
313
|
-
|
326
|
+
_log_error(f"Cannot kill process {pid}")
|
314
327
|
|
315
328
|
def __is_process_exist(self, pid: int) -> bool:
|
316
329
|
try:
|
@@ -1355,19 +1355,19 @@ zrb/shell-scripts/notify.ps1,sha256=6_xPoIwuxARpYljcjVV-iRJS3gJqGfx-B6kj719cJ9o,
|
|
1355
1355
|
zrb/shell-scripts/rsync-util.sh,sha256=QzdhSBvUNMxB4U2B4m0Dxg9czGckRjB7Vk4A1ObG0-k,353
|
1356
1356
|
zrb/shell-scripts/ssh-util.sh,sha256=9lXDzw6oO8HuA4vdbfps_uQMMwKyNYX9fZkZgpK52g8,401
|
1357
1357
|
zrb/task/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1358
|
-
zrb/task/any_task.py,sha256=
|
1358
|
+
zrb/task/any_task.py,sha256=nKcCj_RbSC-MUSi4rxcIAC2eEFo7uKwODkgglxp3mj8,39346
|
1359
1359
|
zrb/task/any_task_event_handler.py,sha256=AjTC6lIcprutRusNBGl83EifQe4TbZzxdlVIR4ndWN4,524
|
1360
1360
|
zrb/task/base_remote_cmd_task.py,sha256=q2Kwo5OMahL5gPSxwp_9zZLYouFfFc6Ru_p6ApOI-pk,12124
|
1361
1361
|
zrb/task/base_task/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1362
|
-
zrb/task/base_task/base_task.py,sha256=
|
1362
|
+
zrb/task/base_task/base_task.py,sha256=rPWMIBNnNtwn0q3VEUDw3HfbSPWtww_lyOA3rUh5aq0,20310
|
1363
1363
|
zrb/task/base_task/component/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1364
1364
|
zrb/task/base_task/component/base_task_model.py,sha256=i6TrtTusZ71ZnOnx8yM0aJl8uF6R1hKdAf62bEdpdCs,10379
|
1365
|
-
zrb/task/base_task/component/common_task_model.py,sha256=
|
1365
|
+
zrb/task/base_task/component/common_task_model.py,sha256=OaliFPkL9HQPuoMBsmmVkJ6xxyQd3GoTJS0u5LaVeNk,13538
|
1366
1366
|
zrb/task/base_task/component/pid_model.py,sha256=RjJIqOpavucDssnd3q3gT4q8QnP8I9SUdlv1b9pR7kU,292
|
1367
1367
|
zrb/task/base_task/component/renderer.py,sha256=9wP2IW811Ta81IoPWmeQ7yVc7eG-uaSnOVbEyeaOIuk,4439
|
1368
1368
|
zrb/task/base_task/component/trackers.py,sha256=c5xhZ6agICxKPI5Va1sn66_9OqC92ebF5CNhcwVUNUE,2074
|
1369
1369
|
zrb/task/checker.py,sha256=raYNBHgeyEqkyfBRsPPgSV7ukEfMlJOCUn97WQNl6mU,3384
|
1370
|
-
zrb/task/cmd_task.py,sha256=
|
1370
|
+
zrb/task/cmd_task.py,sha256=z20xSsFTjnMToTgORzToKRn8_AwubLC0Sm6b-3z58_c,14526
|
1371
1371
|
zrb/task/decorator.py,sha256=stxrl6aXbuUDK83lVf8m8uni3Ii6egLl0TCR0vxslUQ,3064
|
1372
1372
|
zrb/task/docker_compose_task.py,sha256=hUKF7W3GwxFuEWmlPPFxa7h8npEnig2sm7KjlidHFBI,14911
|
1373
1373
|
zrb/task/flow_task.py,sha256=QBOoyIrqc6ToSf3RF8xu8h4yxCWCerUAu2Ba0GxAqgg,5147
|
@@ -1403,8 +1403,8 @@ zrb/task_input/int_input.py,sha256=d2fXcm5fCo09472eMAm6PdzLQD82ZBV9ARq5CjKepAo,4
|
|
1403
1403
|
zrb/task_input/password_input.py,sha256=g_g8ZWAzDaHx4h2EHY3UCGvTigC6esAUBzXU0T9nDUk,4192
|
1404
1404
|
zrb/task_input/str_input.py,sha256=BNflOhrJvST9bWK0rGdCi7C7y-QDvHj9ISQMRmujIWU,4200
|
1405
1405
|
zrb/task_input/task_input.py,sha256=DcHgKie5Oo1sUxj41t1ZQjCIK1aAfTgGzaKr7_ap7ZI,2248
|
1406
|
-
zrb-0.18.
|
1407
|
-
zrb-0.18.
|
1408
|
-
zrb-0.18.
|
1409
|
-
zrb-0.18.
|
1410
|
-
zrb-0.18.
|
1406
|
+
zrb-0.18.1.dist-info/LICENSE,sha256=WfnGCl8G60EYOPAEkuc8C9m9pdXWDe08NsKj3TBbxsM,728
|
1407
|
+
zrb-0.18.1.dist-info/METADATA,sha256=RnbEITp7ykt9BYdrmFaPEX71dBHXmFfVvL3n8ble_jA,17076
|
1408
|
+
zrb-0.18.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
1409
|
+
zrb-0.18.1.dist-info/entry_points.txt,sha256=xTgXc1kBKYhJHEujdaSPHUcJT3-hbyP1mLgwkv-5sSk,40
|
1410
|
+
zrb-0.18.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|