zrb 0.5.1__py3-none-any.whl → 0.6.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/__init__.py +24 -20
- zrb/__main__.py +5 -5
- zrb/action/runner.py +22 -30
- zrb/advertisement.py +10 -9
- zrb/builtin/__init__.py +18 -16
- zrb/builtin/base64.py +13 -18
- zrb/builtin/devtool/__init__.py +14 -3
- zrb/builtin/devtool/devtool_install.py +207 -221
- zrb/builtin/env.py +9 -12
- zrb/builtin/eval.py +9 -9
- zrb/builtin/explain.py +73 -74
- zrb/builtin/generator/__init__.py +7 -11
- zrb/builtin/generator/app_generator/add.py +86 -87
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/add.py +78 -77
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_checker.py +6 -6
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +32 -32
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +29 -30
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +1 -3
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +5 -4
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/__main__.py +24 -32
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/add.py +89 -87
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +42 -54
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +34 -32
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +19 -22
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +18 -18
- zrb/builtin/generator/app_generator/template/http-port/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_checker.py +10 -10
- zrb/builtin/generator/app_generator/template/http-port-build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +19 -19
- zrb/builtin/generator/app_generator/template/use-helm/_automate/generate_snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/__main__.py +12 -14
- zrb/builtin/generator/cmd_task/add.py +23 -25
- zrb/builtin/generator/cmd_task/template/_automate/snake_zrb_task_name.py +3 -5
- zrb/builtin/generator/common/helper.py +15 -20
- zrb/builtin/generator/common/task_factory.py +29 -26
- zrb/builtin/generator/common/task_input.py +97 -91
- zrb/builtin/generator/docker_compose_task/add.py +38 -39
- zrb/builtin/generator/docker_compose_task/template/_automate/snake_zrb_task_name.py +13 -19
- zrb/builtin/generator/docker_compose_task/template/src/kebab-zrb-task-name/image/main.py +18 -14
- zrb/builtin/generator/fastapp/add.py +94 -90
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_checker.py +28 -27
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_config.py +68 -39
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_env.py +24 -22
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_env_file.py +12 -12
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_get_start_microservices.py +43 -41
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_helper.py +23 -24
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_input.py +21 -20
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-load-test.sh +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-start.sh +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-test.sh +2 -2
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/container.py +46 -39
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/deployment.py +28 -20
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/frontend.py +21 -27
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/image.py +23 -18
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/load_test.py +35 -36
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/local.py +68 -58
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/test.py +24 -38
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/__main__.py +23 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/_common.py +72 -75
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/app_helper.py +70 -75
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_postgresql_helper.py +18 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_rabbitmq_helper.py +11 -19
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_redpanda_helper.py +18 -15
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_signoz_helper.py +17 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/docker-compose.yml +12 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/loadtest/locustfile.py +10 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/Dockerfile +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app.py +35 -30
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app_lifespan.py +21 -17
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app_state.py +3 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/db_connection.py +18 -20
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/frontend_index.py +5 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/log.py +7 -15
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/messagebus.py +38 -34
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/rpc.py +19 -18
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/config.py +68 -103
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/error.py +11 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/__init__.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/admin.py +38 -35
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/consumer.py +38 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/publisher.py +26 -29
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/messagebus.py +8 -14
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/mock.py +12 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/admin.py +37 -44
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/consumer.py +42 -67
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/publisher.py +32 -55
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/model/repo_model.py +11 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/__init__.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/db_entity_mixin.py +3 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/db_repo.py +76 -83
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/repo.py +5 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/search_filter.py +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/__init__.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/messagebus/caller.py +17 -19
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/messagebus/server.py +14 -18
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/rpc.py +15 -28
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/schema/__init__.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/schema/base_schema.py +6 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/serializer/__init__.py +1 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/serializer/serializer.py +3 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/async_task.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/conversion.py +10 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/migration.py +6 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/migrate.py +3 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/api.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/__init__.py +4 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/access_token_scheme.py +9 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/access_token_util.py +6 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/authorizer.py +4 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/bearer_token_scheme.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/model/user_model.py +8 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/password_hasher.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/refresh_token_util.py +7 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/group_repo.py +3 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/permission_repo.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/user_repo.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/user.py +12 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/__init__.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/access_token/scheme.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/access_token/util.py +20 -30
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/authorizer/authorizer.py +1 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/authorizer/rpc_authorizer.py +5 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/password_hasher/bcrypt_password_hasher.py +3 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/password_hasher/password_hasher.py +0 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/refresh_token/util.py +15 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/api.py +42 -49
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/model.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/repo.py +18 -16
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/rpc.py +26 -41
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/api.py +46 -51
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/model.py +5 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/repo.py +11 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/rpc.py +28 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/table.py +10 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py +60 -72
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/model.py +32 -61
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/repo.py +33 -36
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/rpc.py +42 -61
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/event.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/migrate.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/register_module.py +11 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/register_permission.py +19 -26
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/rpc.py +5 -13
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/group.py +6 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/permission.py +3 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/request.py +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/token.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/user.py +4 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/api.py +4 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/component/model/activity_model.py +3 -9
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/component/repo/activity_repo.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/core/historical_repo_model.py +13 -13
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/api.py +22 -23
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/event.py +5 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/model.py +2 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/repo.py +8 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/rpc.py +28 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/table.py +3 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/event.py +4 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/migrate.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/register_module.py +10 -11
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/rpc.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/schema/activity.py +3 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/requirements.txt +12 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +76 -106
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +73 -103
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +92 -122
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +107 -134
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/conftest.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +8 -15
- zrb/builtin/generator/fastapp_crud/add.py +74 -79
- zrb/builtin/generator/fastapp_crud/helper.py +51 -48
- zrb/builtin/generator/fastapp_crud/task_factory.py +17 -14
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/component/model/snake_zrb_entity_name_model.py +2 -2
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/component/repo/snake_zrb_entity_name_repo.py +3 -2
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/api.py +58 -40
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/model.py +7 -3
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/repo.py +9 -4
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/rpc.py +32 -39
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +3 -1
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +68 -98
- zrb/builtin/generator/fastapp_field/add.py +143 -85
- zrb/builtin/generator/fastapp_field/helper.py +184 -125
- zrb/builtin/generator/fastapp_module/add.py +90 -67
- zrb/builtin/generator/fastapp_module/helper.py +141 -155
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/api.py +3 -2
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/table.py +3 -3
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/event.py +3 -5
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/migrate.py +2 -4
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/register_module.py +10 -11
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/rpc.py +3 -5
- zrb/builtin/generator/pip_package/add.py +39 -40
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/local.py +30 -30
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/__init__.py +1 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/__main__.py +1 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/util.py +2 -2
- zrb/builtin/generator/plugin/create.py +39 -36
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/__init__.py +1 -1
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/__main__.py +1 -0
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/task/example_task.py +6 -4
- zrb/builtin/generator/plugin/template/zrb_init.py +27 -27
- zrb/builtin/generator/project/create.py +38 -46
- zrb/builtin/generator/project/template/.flake8 +3 -0
- zrb/builtin/generator/project/template/project.sh +21 -6
- zrb/builtin/generator/project_task/task_factory.py +60 -61
- zrb/builtin/generator/project_task/template/_automate/_project/__init__.py +2 -2
- zrb/builtin/generator/project_task/template/_automate/_project/build_project_images.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/deploy_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/destroy_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/push_project_images.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/remove_project_containers.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/start_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/start_project_containers.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/stop_project_containers.py +4 -4
- zrb/builtin/generator/python_task/add.py +25 -33
- zrb/builtin/generator/python_task/template/_automate/snake_zrb_task_name.py +8 -7
- zrb/builtin/generator/simple_python_app/add.py +81 -75
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/container.py +46 -61
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/deployment.py +34 -32
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/image.py +19 -22
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/local.py +23 -25
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/deployment/__main__.py +24 -32
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/src/main.py +18 -14
- zrb/builtin/git.py +46 -46
- zrb/builtin/group.py +13 -34
- zrb/builtin/helper/reccuring_action.py +26 -29
- zrb/builtin/md5.py +17 -30
- zrb/builtin/process.py +19 -19
- zrb/builtin/project.py +13 -15
- zrb/builtin/say.py +69 -88
- zrb/builtin/schedule.py +15 -19
- zrb/builtin/ubuntu.py +44 -35
- zrb/builtin/update.py +5 -5
- zrb/builtin/version.py +3 -7
- zrb/builtin/watch_changes.py +24 -25
- zrb/config/config.py +19 -18
- zrb/helper/accessories/color.py +18 -6
- zrb/helper/accessories/icon.py +24 -3
- zrb/helper/accessories/name.py +120 -28
- zrb/helper/advertisement.py +9 -13
- zrb/helper/callable.py +2 -4
- zrb/helper/cli.py +27 -31
- zrb/helper/codemod/add_argument_to_function.py +3 -4
- zrb/helper/codemod/add_argument_to_function_call.py +4 -7
- zrb/helper/codemod/add_assert_resource.py +7 -7
- zrb/helper/codemod/add_function_call.py +3 -5
- zrb/helper/codemod/add_import_module.py +15 -26
- zrb/helper/codemod/add_key_value_to_dict.py +7 -10
- zrb/helper/codemod/add_property_to_class.py +10 -8
- zrb/helper/codemod/add_upstream_to_task.py +21 -33
- zrb/helper/codemod/append_code_to_function.py +6 -13
- zrb/helper/codemod/format_code.py +2 -1
- zrb/helper/default_env.py +25 -25
- zrb/helper/docker_compose/fetch_external_env.py +18 -18
- zrb/helper/docker_compose/file.py +5 -4
- zrb/helper/docstring.py +44 -47
- zrb/helper/env_map/fetch.py +7 -12
- zrb/helper/file/copy_tree.py +12 -17
- zrb/helper/file/match.py +6 -7
- zrb/helper/file/text.py +8 -6
- zrb/helper/git/detect_changes.py +9 -8
- zrb/helper/loader/load_module.py +14 -13
- zrb/helper/log.py +4 -3
- zrb/helper/map/conversion.py +4 -5
- zrb/helper/python_task.py +2 -4
- zrb/helper/render_data.py +25 -18
- zrb/helper/string/constant.py +2 -2
- zrb/helper/string/conversion.py +17 -16
- zrb/helper/string/jinja.py +2 -2
- zrb/helper/typecheck.py +6 -4
- zrb/helper/typing.py +10 -2
- zrb/helper/util.py +44 -40
- zrb/task/any_task.py +261 -261
- zrb/task/base_remote_cmd_task.py +78 -61
- zrb/task/base_task/base_task.py +97 -110
- zrb/task/base_task/component/base_task_model.py +74 -72
- zrb/task/base_task/component/common_task_model.py +44 -31
- zrb/task/base_task/component/pid_model.py +3 -5
- zrb/task/base_task/component/renderer.py +26 -36
- zrb/task/base_task/component/trackers.py +6 -9
- zrb/task/checker.py +14 -9
- zrb/task/cmd_task.py +109 -101
- zrb/task/decorator.py +19 -13
- zrb/task/docker_compose_task.py +130 -100
- zrb/task/flow_task.py +16 -19
- zrb/task/http_checker.py +43 -37
- zrb/task/notifier.py +50 -36
- zrb/task/parallel.py +3 -3
- zrb/task/path_checker.py +35 -28
- zrb/task/path_watcher.py +50 -40
- zrb/task/port_checker.py +36 -27
- zrb/task/recurring_task.py +36 -42
- zrb/task/remote_cmd_task.py +31 -28
- zrb/task/resource_maker.py +70 -56
- zrb/task/rsync_task.py +26 -21
- zrb/task/task.py +4 -3
- zrb/task/time_watcher.py +36 -31
- zrb/task_env/constant.py +1 -1
- zrb/task_env/env.py +33 -31
- zrb/task_env/env_file.py +24 -23
- zrb/task_group/group.py +27 -30
- zrb/task_input/any_input.py +18 -16
- zrb/task_input/base_input.py +26 -26
- zrb/task_input/bool_input.py +6 -6
- zrb/task_input/choice_input.py +11 -9
- zrb/task_input/constant.py +1 -1
- zrb/task_input/float_input.py +6 -5
- zrb/task_input/int_input.py +8 -8
- zrb/task_input/password_input.py +9 -9
- zrb/task_input/str_input.py +8 -8
- zrb/task_input/task_input.py +4 -2
- {zrb-0.5.1.dist-info → zrb-0.6.1.dist-info}/METADATA +3 -1
- {zrb-0.5.1.dist-info → zrb-0.6.1.dist-info}/RECORD +316 -315
- {zrb-0.5.1.dist-info → zrb-0.6.1.dist-info}/LICENSE +0 -0
- {zrb-0.5.1.dist-info → zrb-0.6.1.dist-info}/WHEEL +0 -0
- {zrb-0.5.1.dist-info → zrb-0.6.1.dist-info}/entry_points.txt +0 -0
zrb/task/notifier.py
CHANGED
@@ -1,40 +1,48 @@
|
|
1
|
-
|
1
|
+
import os
|
2
|
+
import subprocess
|
3
|
+
|
4
|
+
from zrb.helper.accessories.icon import get_random_icon
|
5
|
+
from zrb.helper.string.modification import double_quote
|
2
6
|
from zrb.helper.typecheck import typechecked
|
3
|
-
from zrb.
|
7
|
+
from zrb.helper.typing import Any, Callable, Iterable, JinjaTemplate, Optional, Union
|
4
8
|
from zrb.task.any_task import AnyTask
|
5
9
|
from zrb.task.any_task_event_handler import (
|
6
|
-
|
10
|
+
OnFailed,
|
11
|
+
OnReady,
|
12
|
+
OnRetry,
|
13
|
+
OnSkipped,
|
14
|
+
OnStarted,
|
15
|
+
OnTriggered,
|
16
|
+
OnWaiting,
|
7
17
|
)
|
18
|
+
from zrb.task.base_task.base_task import BaseTask
|
8
19
|
from zrb.task_env.env import Env
|
9
20
|
from zrb.task_env.env_file import EnvFile
|
10
21
|
from zrb.task_group.group import Group
|
11
22
|
from zrb.task_input.any_input import AnyInput
|
12
|
-
from zrb.helper.accessories.icon import get_random_icon
|
13
|
-
from zrb.helper.string.modification import double_quote
|
14
|
-
|
15
|
-
import os
|
16
|
-
import subprocess
|
17
23
|
|
18
24
|
CURRENT_DIR = os.path.dirname(__file__)
|
19
|
-
NOTIFY_PS1_PATH = os.path.realpath(
|
20
|
-
os.path.
|
21
|
-
))
|
25
|
+
NOTIFY_PS1_PATH = os.path.realpath(
|
26
|
+
os.path.abspath(
|
27
|
+
os.path.join(os.path.dirname(CURRENT_DIR), "shell-scripts", "notify.ps1")
|
28
|
+
)
|
29
|
+
)
|
22
30
|
|
23
31
|
|
24
32
|
@typechecked
|
25
33
|
class Notifier(BaseTask):
|
26
34
|
def __init__(
|
27
35
|
self,
|
28
|
-
name: str =
|
36
|
+
name: str = "port-check",
|
29
37
|
group: Optional[Group] = None,
|
30
38
|
inputs: Iterable[AnyInput] = [],
|
31
39
|
envs: Iterable[Env] = [],
|
32
40
|
env_files: Iterable[EnvFile] = [],
|
33
41
|
icon: Optional[str] = None,
|
34
42
|
color: Optional[str] = None,
|
35
|
-
description: str =
|
36
|
-
title:
|
37
|
-
message:
|
43
|
+
description: str = "",
|
44
|
+
title: JinjaTemplate = "",
|
45
|
+
message: JinjaTemplate = "",
|
38
46
|
show_toast: bool = True,
|
39
47
|
show_stdout: bool = True,
|
40
48
|
upstreams: Iterable[AnyTask] = [],
|
@@ -48,7 +56,7 @@ class Notifier(BaseTask):
|
|
48
56
|
checking_interval: Union[int, float] = 0,
|
49
57
|
retry: int = 2,
|
50
58
|
retry_interval: Union[float, int] = 1,
|
51
|
-
should_execute: Union[bool, str, Callable[..., bool]] = True
|
59
|
+
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
52
60
|
):
|
53
61
|
BaseTask.__init__(
|
54
62
|
self,
|
@@ -74,8 +82,8 @@ class Notifier(BaseTask):
|
|
74
82
|
retry_interval=retry_interval,
|
75
83
|
should_execute=should_execute,
|
76
84
|
)
|
77
|
-
self._title = title if title !=
|
78
|
-
self._message = message if message !=
|
85
|
+
self._title = title if title != "" else name
|
86
|
+
self._message = message if message != "" else get_random_icon()
|
79
87
|
self._show_toast = show_toast
|
80
88
|
self._show_stdout = show_stdout
|
81
89
|
|
@@ -84,32 +92,37 @@ class Notifier(BaseTask):
|
|
84
92
|
message = self.render_str(self._message)
|
85
93
|
notify_kwargs = {
|
86
94
|
key: value
|
87
|
-
for key, value in kwargs.items()
|
95
|
+
for key, value in kwargs.items()
|
96
|
+
if key not in ("title", "message")
|
88
97
|
}
|
89
98
|
await self.notify(title, message, **notify_kwargs)
|
90
99
|
return message
|
91
100
|
|
92
101
|
async def notify(self, title: str, message: str, **kwargs: Any) -> None:
|
93
|
-
task: BaseTask = kwargs.get(
|
102
|
+
task: BaseTask = kwargs.get("_task")
|
94
103
|
if self._show_toast and _is_powershell_available():
|
95
104
|
cmd = [
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
105
|
+
"powershell.exe",
|
106
|
+
"-ExecutionPolicy",
|
107
|
+
"Bypass",
|
108
|
+
"-File",
|
109
|
+
NOTIFY_PS1_PATH,
|
110
|
+
"-Title",
|
111
|
+
title,
|
112
|
+
"-Message",
|
113
|
+
message,
|
101
114
|
]
|
102
115
|
subprocess.run(cmd, stdout=subprocess.DEVNULL)
|
103
116
|
if self._show_toast and _is_osascript_available():
|
104
117
|
q_message = double_quote(message)
|
105
118
|
q_title = double_quote(title)
|
106
119
|
cmd = [
|
107
|
-
|
108
|
-
|
109
|
-
f'display notification "{q_message}" with title "{q_title}"'
|
120
|
+
"osascript",
|
121
|
+
"-e",
|
122
|
+
f'display notification "{q_message}" with title "{q_title}"',
|
110
123
|
]
|
111
124
|
if self._show_toast and _is_notify_send_available():
|
112
|
-
cmd = [
|
125
|
+
cmd = ["notify-send", title, message]
|
113
126
|
subprocess.run(cmd, stdout=subprocess.DEVNULL)
|
114
127
|
if self._show_stdout:
|
115
128
|
task.print_out(message)
|
@@ -119,9 +132,10 @@ class Notifier(BaseTask):
|
|
119
132
|
def _is_powershell_available():
|
120
133
|
try:
|
121
134
|
subprocess.run(
|
122
|
-
[
|
123
|
-
check=True,
|
124
|
-
|
135
|
+
["powershell.exe", "-Command", 'echo "Checking PowerShell"'],
|
136
|
+
check=True,
|
137
|
+
stdout=subprocess.DEVNULL,
|
138
|
+
stderr=subprocess.DEVNULL,
|
125
139
|
)
|
126
140
|
return True
|
127
141
|
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
|
@@ -131,10 +145,10 @@ def _is_powershell_available():
|
|
131
145
|
def _is_notify_send_available():
|
132
146
|
try:
|
133
147
|
subprocess.run(
|
134
|
-
[
|
148
|
+
["notify-send", "--version"],
|
135
149
|
check=True,
|
136
150
|
stdout=subprocess.DEVNULL,
|
137
|
-
stderr=subprocess.DEVNULL
|
151
|
+
stderr=subprocess.DEVNULL,
|
138
152
|
)
|
139
153
|
return True
|
140
154
|
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
|
@@ -144,10 +158,10 @@ def _is_notify_send_available():
|
|
144
158
|
def _is_osascript_available():
|
145
159
|
try:
|
146
160
|
subprocess.run(
|
147
|
-
[
|
161
|
+
["osascript", "-e", "return"],
|
148
162
|
check=True,
|
149
163
|
stdout=subprocess.DEVNULL,
|
150
|
-
stderr=subprocess.DEVNULL
|
164
|
+
stderr=subprocess.DEVNULL,
|
151
165
|
)
|
152
166
|
return True
|
153
167
|
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
|
zrb/task/parallel.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
from zrb.helper.typing import TypeVar, List, Union
|
2
1
|
from abc import ABC, abstractmethod
|
2
|
+
|
3
3
|
from zrb.helper.typecheck import typechecked
|
4
|
+
from zrb.helper.typing import List, TypeVar, Union
|
4
5
|
from zrb.task.any_task import AnyTask
|
5
6
|
|
6
|
-
|
7
|
-
TParallel = TypeVar('TParallel', bound='Parallel')
|
7
|
+
TParallel = TypeVar("TParallel", bound="Parallel")
|
8
8
|
|
9
9
|
|
10
10
|
class AnyParallel(ABC):
|
zrb/task/path_checker.py
CHANGED
@@ -1,34 +1,46 @@
|
|
1
|
+
from zrb.helper.file.match import get_file_names
|
2
|
+
from zrb.helper.typecheck import typechecked
|
1
3
|
from zrb.helper.typing import (
|
2
|
-
Any,
|
4
|
+
Any,
|
5
|
+
Callable,
|
6
|
+
Iterable,
|
7
|
+
JinjaTemplate,
|
8
|
+
List,
|
9
|
+
Optional,
|
10
|
+
TypeVar,
|
11
|
+
Union,
|
3
12
|
)
|
4
|
-
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.helper.file.match import get_file_names
|
6
|
-
from zrb.task.checker import Checker
|
7
13
|
from zrb.task.any_task import AnyTask
|
8
14
|
from zrb.task.any_task_event_handler import (
|
9
|
-
|
15
|
+
OnFailed,
|
16
|
+
OnReady,
|
17
|
+
OnRetry,
|
18
|
+
OnSkipped,
|
19
|
+
OnStarted,
|
20
|
+
OnTriggered,
|
21
|
+
OnWaiting,
|
10
22
|
)
|
23
|
+
from zrb.task.checker import Checker
|
11
24
|
from zrb.task_env.env import Env
|
12
25
|
from zrb.task_env.env_file import EnvFile
|
13
26
|
from zrb.task_group.group import Group
|
14
27
|
from zrb.task_input.any_input import AnyInput
|
15
28
|
|
16
|
-
TPathChecker = TypeVar(
|
29
|
+
TPathChecker = TypeVar("TPathChecker", bound="PathChecker")
|
17
30
|
|
18
31
|
|
19
32
|
@typechecked
|
20
33
|
class PathChecker(Checker):
|
21
|
-
|
22
34
|
def __init__(
|
23
35
|
self,
|
24
|
-
name: str =
|
36
|
+
name: str = "check-path",
|
25
37
|
group: Optional[Group] = None,
|
26
38
|
inputs: Iterable[AnyInput] = [],
|
27
39
|
envs: Iterable[Env] = [],
|
28
40
|
env_files: Iterable[EnvFile] = [],
|
29
41
|
icon: Optional[str] = None,
|
30
42
|
color: Optional[str] = None,
|
31
|
-
description: str =
|
43
|
+
description: str = "",
|
32
44
|
upstreams: Iterable[AnyTask] = [],
|
33
45
|
on_triggered: Optional[OnTriggered] = None,
|
34
46
|
on_waiting: Optional[OnWaiting] = None,
|
@@ -37,12 +49,12 @@ class PathChecker(Checker):
|
|
37
49
|
on_ready: Optional[OnReady] = None,
|
38
50
|
on_retry: Optional[OnRetry] = None,
|
39
51
|
on_failed: Optional[OnFailed] = None,
|
40
|
-
path:
|
41
|
-
ignored_path: Union[
|
52
|
+
path: JinjaTemplate = "",
|
53
|
+
ignored_path: Union[JinjaTemplate, Iterable[JinjaTemplate]] = [],
|
42
54
|
checking_interval: Union[int, float] = 0.1,
|
43
55
|
progress_interval: Union[int, float] = 5,
|
44
56
|
expected_result: bool = True,
|
45
|
-
should_execute: Union[bool,
|
57
|
+
should_execute: Union[bool, JinjaTemplate, Callable[..., bool]] = True,
|
46
58
|
):
|
47
59
|
Checker.__init__(
|
48
60
|
self,
|
@@ -69,7 +81,7 @@ class PathChecker(Checker):
|
|
69
81
|
)
|
70
82
|
self._path = path
|
71
83
|
self._ignored_path = ignored_path
|
72
|
-
self._rendered_path: str =
|
84
|
+
self._rendered_path: str = ""
|
73
85
|
self._rendered_ignored_paths: List[str] = []
|
74
86
|
|
75
87
|
def copy(self) -> TPathChecker:
|
@@ -77,43 +89,38 @@ class PathChecker(Checker):
|
|
77
89
|
|
78
90
|
def to_function(
|
79
91
|
self,
|
80
|
-
env_prefix: str =
|
92
|
+
env_prefix: str = "",
|
81
93
|
raise_error: bool = True,
|
82
94
|
is_async: bool = False,
|
83
|
-
show_done_info: bool = True
|
95
|
+
show_done_info: bool = True,
|
84
96
|
) -> Callable[..., bool]:
|
85
|
-
return super().to_function(
|
86
|
-
env_prefix, raise_error, is_async, show_done_info
|
87
|
-
)
|
97
|
+
return super().to_function(env_prefix, raise_error, is_async, show_done_info)
|
88
98
|
|
89
99
|
async def run(self, *args: Any, **kwargs: Any) -> bool:
|
90
100
|
self._rendered_path = self.render_str(self._path)
|
91
101
|
self._rendered_ignored_paths = [
|
92
102
|
ignored_path
|
93
103
|
for ignored_path in self._get_rendered_ignored_paths()
|
94
|
-
if ignored_path !=
|
104
|
+
if ignored_path != ""
|
95
105
|
]
|
96
106
|
return await super().run(*args, **kwargs)
|
97
107
|
|
98
108
|
def _get_rendered_ignored_paths(self) -> List[str]:
|
99
109
|
if isinstance(self._ignored_path, str):
|
100
110
|
return [self.render_str(self._ignored_path)]
|
101
|
-
return [
|
102
|
-
self.render_str(ignored_path)
|
103
|
-
for ignored_path in self._ignored_path
|
104
|
-
]
|
111
|
+
return [self.render_str(ignored_path) for ignored_path in self._ignored_path]
|
105
112
|
|
106
113
|
async def inspect(self, *args: Any, **kwargs: Any) -> bool:
|
107
|
-
label = f
|
114
|
+
label = f"Checking {self._rendered_path}"
|
108
115
|
try:
|
109
116
|
matches = get_file_names(
|
110
117
|
glob_path=self._rendered_path,
|
111
|
-
glob_ignored_paths=self._rendered_ignored_paths
|
118
|
+
glob_ignored_paths=self._rendered_ignored_paths,
|
112
119
|
)
|
113
120
|
if len(matches) > 0:
|
114
|
-
self.print_out(f
|
121
|
+
self.print_out(f"{label} (Exist)")
|
115
122
|
return True
|
116
|
-
self.show_progress(f
|
123
|
+
self.show_progress(f"{label} (Not Exist)")
|
117
124
|
except Exception:
|
118
|
-
self.show_progress(f
|
125
|
+
self.show_progress(f"{label} Cannot inspect")
|
119
126
|
return False
|
zrb/task/path_watcher.py
CHANGED
@@ -1,26 +1,40 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from zrb.helper.file.match import get_file_names
|
4
|
+
from zrb.helper.typecheck import typechecked
|
1
5
|
from zrb.helper.typing import (
|
2
|
-
Any,
|
6
|
+
Any,
|
7
|
+
Callable,
|
8
|
+
Iterable,
|
9
|
+
JinjaTemplate,
|
10
|
+
List,
|
11
|
+
Mapping,
|
12
|
+
Optional,
|
13
|
+
TypeVar,
|
14
|
+
Union,
|
3
15
|
)
|
4
|
-
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.helper.file.match import get_file_names
|
6
|
-
from zrb.task.checker import Checker
|
7
16
|
from zrb.task.any_task import AnyTask
|
8
17
|
from zrb.task.any_task_event_handler import (
|
9
|
-
|
18
|
+
OnFailed,
|
19
|
+
OnReady,
|
20
|
+
OnRetry,
|
21
|
+
OnSkipped,
|
22
|
+
OnStarted,
|
23
|
+
OnTriggered,
|
24
|
+
OnWaiting,
|
10
25
|
)
|
26
|
+
from zrb.task.checker import Checker
|
11
27
|
from zrb.task_env.env import Env
|
12
28
|
from zrb.task_env.env_file import EnvFile
|
13
29
|
from zrb.task_group.group import Group
|
14
30
|
from zrb.task_input.any_input import AnyInput
|
15
31
|
|
16
|
-
|
17
|
-
|
18
|
-
TPathWatcher = TypeVar('TPathWatcher', bound='PathWatcher')
|
32
|
+
TPathWatcher = TypeVar("TPathWatcher", bound="PathWatcher")
|
19
33
|
|
20
34
|
|
21
35
|
@typechecked
|
22
36
|
class PathWatcher(Checker):
|
23
|
-
|
37
|
+
"""
|
24
38
|
PathWatcher will wait for any changes specified on path.
|
25
39
|
|
26
40
|
Once the changes detected, PathWatcher will be completed
|
@@ -29,18 +43,18 @@ class PathWatcher(Checker):
|
|
29
43
|
- <task-name>.new-file
|
30
44
|
- <task-name>.modified-file
|
31
45
|
- <task-name>.deleted-file
|
32
|
-
|
46
|
+
"""
|
33
47
|
|
34
48
|
def __init__(
|
35
49
|
self,
|
36
|
-
name: str =
|
50
|
+
name: str = "watch-path",
|
37
51
|
group: Optional[Group] = None,
|
38
52
|
inputs: Iterable[AnyInput] = [],
|
39
53
|
envs: Iterable[Env] = [],
|
40
54
|
env_files: Iterable[EnvFile] = [],
|
41
55
|
icon: Optional[str] = None,
|
42
56
|
color: Optional[str] = None,
|
43
|
-
description: str =
|
57
|
+
description: str = "",
|
44
58
|
upstreams: Iterable[AnyTask] = [],
|
45
59
|
on_triggered: Optional[OnTriggered] = None,
|
46
60
|
on_waiting: Optional[OnWaiting] = None,
|
@@ -49,14 +63,14 @@ class PathWatcher(Checker):
|
|
49
63
|
on_ready: Optional[OnReady] = None,
|
50
64
|
on_retry: Optional[OnRetry] = None,
|
51
65
|
on_failed: Optional[OnFailed] = None,
|
52
|
-
path:
|
53
|
-
ignored_path: Union[
|
66
|
+
path: JinjaTemplate = "",
|
67
|
+
ignored_path: Union[JinjaTemplate, Iterable[JinjaTemplate]] = [],
|
54
68
|
checking_interval: Union[int, float] = 0.1,
|
55
69
|
progress_interval: Union[int, float] = 30,
|
56
70
|
watch_new_files: bool = True,
|
57
71
|
watch_modified_files: bool = True,
|
58
72
|
watch_deleted_files: bool = True,
|
59
|
-
should_execute: Union[bool,
|
73
|
+
should_execute: Union[bool, JinjaTemplate, Callable[..., bool]] = True,
|
60
74
|
):
|
61
75
|
Checker.__init__(
|
62
76
|
self,
|
@@ -85,7 +99,7 @@ class PathWatcher(Checker):
|
|
85
99
|
self._watch_new_files = watch_new_files
|
86
100
|
self._watch_modified_files = watch_modified_files
|
87
101
|
self._watch_deleted_files = watch_deleted_files
|
88
|
-
self._rendered_path: str =
|
102
|
+
self._rendered_path: str = ""
|
89
103
|
self._rendered_ignored_paths: List[str] = []
|
90
104
|
self._init_times: Mapping[str, float] = {}
|
91
105
|
|
@@ -94,21 +108,19 @@ class PathWatcher(Checker):
|
|
94
108
|
|
95
109
|
def to_function(
|
96
110
|
self,
|
97
|
-
env_prefix: str =
|
111
|
+
env_prefix: str = "",
|
98
112
|
raise_error: bool = True,
|
99
113
|
is_async: bool = False,
|
100
|
-
show_done_info: bool = True
|
114
|
+
show_done_info: bool = True,
|
101
115
|
) -> Callable[..., bool]:
|
102
|
-
return super().to_function(
|
103
|
-
env_prefix, raise_error, is_async, show_done_info
|
104
|
-
)
|
116
|
+
return super().to_function(env_prefix, raise_error, is_async, show_done_info)
|
105
117
|
|
106
118
|
async def run(self, *args: Any, **kwargs: Any) -> bool:
|
107
119
|
self._rendered_path = self.render_str(self._path)
|
108
120
|
self._rendered_ignored_paths = [
|
109
121
|
ignored_path
|
110
122
|
for ignored_path in self._get_rendered_ignored_paths()
|
111
|
-
if ignored_path !=
|
123
|
+
if ignored_path != ""
|
112
124
|
]
|
113
125
|
self._init_times = self._get_mod_times()
|
114
126
|
return await super().run(*args, **kwargs)
|
@@ -116,50 +128,48 @@ class PathWatcher(Checker):
|
|
116
128
|
def _get_rendered_ignored_paths(self) -> List[str]:
|
117
129
|
if isinstance(self._ignored_path, str):
|
118
130
|
return [self.render_str(self._ignored_path)]
|
119
|
-
return [
|
120
|
-
self.render_str(ignored_path)
|
121
|
-
for ignored_path in self._ignored_path
|
122
|
-
]
|
131
|
+
return [self.render_str(ignored_path) for ignored_path in self._ignored_path]
|
123
132
|
|
124
133
|
async def inspect(self, *args: Any, **kwargs: Any) -> bool:
|
125
|
-
label = f
|
134
|
+
label = f"Watching {self._rendered_path}"
|
126
135
|
try:
|
127
136
|
mod_times = self._get_mod_times()
|
128
137
|
except Exception as e:
|
129
|
-
self.show_progress(f
|
138
|
+
self.show_progress(f"{label} Cannot inspect")
|
130
139
|
raise e
|
131
140
|
# watch changes
|
132
141
|
if self._watch_new_files:
|
133
142
|
new_files = mod_times.keys() - self._init_times.keys()
|
134
143
|
for file in new_files:
|
135
|
-
self.print_out_dark(f
|
136
|
-
self.set_task_xcom(
|
137
|
-
self.set_task_xcom(
|
144
|
+
self.print_out_dark(f"{label} [+] New file detected: {file}")
|
145
|
+
self.set_task_xcom("new-file", file)
|
146
|
+
self.set_task_xcom("file", file)
|
138
147
|
return True
|
139
148
|
if self._watch_deleted_files:
|
140
149
|
deleted_files = self._init_times.keys() - mod_times.keys()
|
141
150
|
for file in deleted_files:
|
142
|
-
self.print_out_dark(f
|
143
|
-
self.set_task_xcom(
|
144
|
-
self.set_task_xcom(
|
151
|
+
self.print_out_dark(f"{label} [-] File deleted: {file}")
|
152
|
+
self.set_task_xcom("deleted-file", file)
|
153
|
+
self.set_task_xcom("file", file)
|
145
154
|
return True
|
146
155
|
if self._watch_modified_files:
|
147
156
|
modified_files = {
|
148
|
-
file
|
157
|
+
file
|
158
|
+
for file, mod_time in mod_times.items()
|
149
159
|
if file in mod_times and self._init_times[file] != mod_time
|
150
160
|
}
|
151
161
|
for file in modified_files:
|
152
|
-
self.print_out_dark(f
|
153
|
-
self.set_task_xcom(
|
154
|
-
self.set_task_xcom(
|
162
|
+
self.print_out_dark(f"{label} [/] File modified: {file}")
|
163
|
+
self.set_task_xcom("modified-file", file)
|
164
|
+
self.set_task_xcom("file", file)
|
155
165
|
return True
|
156
|
-
self.show_progress(f
|
166
|
+
self.show_progress(f"{label} (Nothing changed)")
|
157
167
|
return False
|
158
168
|
|
159
169
|
def _get_mod_times(self) -> Mapping[str, float]:
|
160
170
|
matches = get_file_names(
|
161
171
|
glob_path=self._rendered_path,
|
162
|
-
glob_ignored_paths=self._rendered_ignored_paths
|
172
|
+
glob_ignored_paths=self._rendered_ignored_paths,
|
163
173
|
)
|
164
174
|
mod_times: Mapping[str, float] = {}
|
165
175
|
for file_name in matches:
|
zrb/task/port_checker.py
CHANGED
@@ -1,45 +1,58 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import socket
|
2
|
+
|
3
3
|
from zrb.helper.typecheck import typechecked
|
4
|
+
from zrb.helper.typing import (
|
5
|
+
Any,
|
6
|
+
Callable,
|
7
|
+
Iterable,
|
8
|
+
JinjaTemplate,
|
9
|
+
Optional,
|
10
|
+
TypeVar,
|
11
|
+
Union,
|
12
|
+
)
|
4
13
|
from zrb.task.any_task import AnyTask
|
5
14
|
from zrb.task.any_task_event_handler import (
|
6
|
-
|
15
|
+
OnFailed,
|
16
|
+
OnReady,
|
17
|
+
OnRetry,
|
18
|
+
OnSkipped,
|
19
|
+
OnStarted,
|
20
|
+
OnTriggered,
|
21
|
+
OnWaiting,
|
7
22
|
)
|
23
|
+
from zrb.task.checker import Checker
|
8
24
|
from zrb.task_env.env import Env
|
9
25
|
from zrb.task_env.env_file import EnvFile
|
10
26
|
from zrb.task_group.group import Group
|
11
27
|
from zrb.task_input.any_input import AnyInput
|
12
28
|
|
13
|
-
|
14
|
-
|
15
|
-
TPortChecker = TypeVar('TPortChecker', bound='PortChecker')
|
29
|
+
TPortChecker = TypeVar("TPortChecker", bound="PortChecker")
|
16
30
|
|
17
31
|
|
18
32
|
@typechecked
|
19
|
-
class PortConfig
|
33
|
+
class PortConfig:
|
20
34
|
def __init__(self, host: str, port: int, timeout: int):
|
21
35
|
self.host = host
|
22
36
|
self.port = port
|
23
37
|
self.timeout = timeout
|
24
|
-
self.label = f
|
38
|
+
self.label = f"Checking {host}:{port}"
|
25
39
|
|
26
40
|
|
27
41
|
@typechecked
|
28
42
|
class PortChecker(Checker):
|
29
|
-
|
30
43
|
def __init__(
|
31
44
|
self,
|
32
|
-
name: str =
|
45
|
+
name: str = "check-port",
|
33
46
|
group: Optional[Group] = None,
|
34
47
|
inputs: Iterable[AnyInput] = [],
|
35
48
|
envs: Iterable[Env] = [],
|
36
49
|
env_files: Iterable[EnvFile] = [],
|
37
50
|
icon: Optional[str] = None,
|
38
51
|
color: Optional[str] = None,
|
39
|
-
description: str =
|
40
|
-
host:
|
41
|
-
port: Union[int,
|
42
|
-
timeout: Union[int,
|
52
|
+
description: str = "",
|
53
|
+
host: JinjaTemplate = "localhost",
|
54
|
+
port: Union[int, JinjaTemplate] = 80,
|
55
|
+
timeout: Union[int, JinjaTemplate] = 5,
|
43
56
|
upstreams: Iterable[AnyTask] = [],
|
44
57
|
on_triggered: Optional[OnTriggered] = None,
|
45
58
|
on_waiting: Optional[OnWaiting] = None,
|
@@ -51,7 +64,7 @@ class PortChecker(Checker):
|
|
51
64
|
checking_interval: Union[int, float] = 0.1,
|
52
65
|
progress_interval: Union[int, float] = 5,
|
53
66
|
expected_result: bool = True,
|
54
|
-
should_execute: Union[bool, str, Callable[..., bool]] = True
|
67
|
+
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
55
68
|
):
|
56
69
|
Checker.__init__(
|
57
70
|
self,
|
@@ -86,20 +99,18 @@ class PortChecker(Checker):
|
|
86
99
|
|
87
100
|
def to_function(
|
88
101
|
self,
|
89
|
-
env_prefix: str =
|
102
|
+
env_prefix: str = "",
|
90
103
|
raise_error: bool = True,
|
91
104
|
is_async: bool = False,
|
92
|
-
show_done_info: bool = True
|
105
|
+
show_done_info: bool = True,
|
93
106
|
) -> Callable[..., bool]:
|
94
|
-
return super().to_function(
|
95
|
-
env_prefix, raise_error, is_async, show_done_info
|
96
|
-
)
|
107
|
+
return super().to_function(env_prefix, raise_error, is_async, show_done_info)
|
97
108
|
|
98
109
|
async def run(self, *args: Any, **kwargs: Any) -> bool:
|
99
110
|
self._config = PortConfig(
|
100
111
|
host=self.render_str(self._host),
|
101
112
|
port=self.render_int(self._port),
|
102
|
-
timeout=self.render_int(self._timeout)
|
113
|
+
timeout=self.render_int(self._timeout),
|
103
114
|
)
|
104
115
|
return await super().run(*args, **kwargs)
|
105
116
|
|
@@ -107,13 +118,11 @@ class PortChecker(Checker):
|
|
107
118
|
try:
|
108
119
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
109
120
|
sock.settimeout(self._config.timeout)
|
110
|
-
result = sock.connect_ex(
|
111
|
-
(self._config.host, self._config.port)
|
112
|
-
)
|
121
|
+
result = sock.connect_ex((self._config.host, self._config.port))
|
113
122
|
if result == 0:
|
114
|
-
self.print_out(f
|
123
|
+
self.print_out(f"{self._config.label} (OK)")
|
115
124
|
return True
|
116
|
-
self.show_progress(f
|
125
|
+
self.show_progress(f"{self._config.label} (Not OK)")
|
117
126
|
except Exception:
|
118
|
-
self.show_progress(f
|
127
|
+
self.show_progress(f"{self._config.label} (Socker error)")
|
119
128
|
return False
|