zrb 0.6.0__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 +19 -10
- 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 +251 -251
- zrb/task/base_remote_cmd_task.py +76 -59
- zrb/task/base_task/base_task.py +95 -108
- zrb/task/base_task/component/base_task_model.py +73 -71
- zrb/task/base_task/component/common_task_model.py +42 -29
- 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 +102 -100
- zrb/task/decorator.py +19 -13
- zrb/task/docker_compose_task.py +127 -98
- zrb/task/flow_task.py +16 -19
- zrb/task/http_checker.py +40 -36
- zrb/task/notifier.py +50 -38
- zrb/task/parallel.py +3 -3
- zrb/task/path_checker.py +34 -27
- zrb/task/path_watcher.py +49 -40
- zrb/task/port_checker.py +33 -26
- zrb/task/recurring_task.py +36 -42
- zrb/task/remote_cmd_task.py +31 -28
- zrb/task/resource_maker.py +66 -52
- zrb/task/rsync_task.py +24 -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.6.0.dist-info → zrb-0.6.1.dist-info}/METADATA +3 -1
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/RECORD +316 -315
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/LICENSE +0 -0
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/WHEEL +0 -0
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/entry_points.txt +0 -0
zrb/task/notifier.py
CHANGED
@@ -1,42 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
4
6
|
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.
|
7
|
+
from zrb.helper.typing import Any, Callable, Iterable, JinjaTemplate, Optional, Union
|
6
8
|
from zrb.task.any_task import AnyTask
|
7
9
|
from zrb.task.any_task_event_handler import (
|
8
|
-
|
10
|
+
OnFailed,
|
11
|
+
OnReady,
|
12
|
+
OnRetry,
|
13
|
+
OnSkipped,
|
14
|
+
OnStarted,
|
15
|
+
OnTriggered,
|
16
|
+
OnWaiting,
|
9
17
|
)
|
18
|
+
from zrb.task.base_task.base_task import BaseTask
|
10
19
|
from zrb.task_env.env import Env
|
11
20
|
from zrb.task_env.env_file import EnvFile
|
12
21
|
from zrb.task_group.group import Group
|
13
22
|
from zrb.task_input.any_input import AnyInput
|
14
|
-
from zrb.helper.accessories.icon import get_random_icon
|
15
|
-
from zrb.helper.string.modification import double_quote
|
16
|
-
|
17
|
-
import os
|
18
|
-
import subprocess
|
19
23
|
|
20
24
|
CURRENT_DIR = os.path.dirname(__file__)
|
21
|
-
NOTIFY_PS1_PATH = os.path.realpath(
|
22
|
-
os.path.
|
23
|
-
))
|
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
|
+
)
|
24
30
|
|
25
31
|
|
26
32
|
@typechecked
|
27
33
|
class Notifier(BaseTask):
|
28
34
|
def __init__(
|
29
35
|
self,
|
30
|
-
name: str =
|
36
|
+
name: str = "port-check",
|
31
37
|
group: Optional[Group] = None,
|
32
38
|
inputs: Iterable[AnyInput] = [],
|
33
39
|
envs: Iterable[Env] = [],
|
34
40
|
env_files: Iterable[EnvFile] = [],
|
35
41
|
icon: Optional[str] = None,
|
36
42
|
color: Optional[str] = None,
|
37
|
-
description: str =
|
38
|
-
title: JinjaTemplate =
|
39
|
-
message: JinjaTemplate =
|
43
|
+
description: str = "",
|
44
|
+
title: JinjaTemplate = "",
|
45
|
+
message: JinjaTemplate = "",
|
40
46
|
show_toast: bool = True,
|
41
47
|
show_stdout: bool = True,
|
42
48
|
upstreams: Iterable[AnyTask] = [],
|
@@ -50,7 +56,7 @@ class Notifier(BaseTask):
|
|
50
56
|
checking_interval: Union[int, float] = 0,
|
51
57
|
retry: int = 2,
|
52
58
|
retry_interval: Union[float, int] = 1,
|
53
|
-
should_execute: Union[bool, str, Callable[..., bool]] = True
|
59
|
+
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
54
60
|
):
|
55
61
|
BaseTask.__init__(
|
56
62
|
self,
|
@@ -76,8 +82,8 @@ class Notifier(BaseTask):
|
|
76
82
|
retry_interval=retry_interval,
|
77
83
|
should_execute=should_execute,
|
78
84
|
)
|
79
|
-
self._title = title if title !=
|
80
|
-
self._message = message if message !=
|
85
|
+
self._title = title if title != "" else name
|
86
|
+
self._message = message if message != "" else get_random_icon()
|
81
87
|
self._show_toast = show_toast
|
82
88
|
self._show_stdout = show_stdout
|
83
89
|
|
@@ -86,32 +92,37 @@ class Notifier(BaseTask):
|
|
86
92
|
message = self.render_str(self._message)
|
87
93
|
notify_kwargs = {
|
88
94
|
key: value
|
89
|
-
for key, value in kwargs.items()
|
95
|
+
for key, value in kwargs.items()
|
96
|
+
if key not in ("title", "message")
|
90
97
|
}
|
91
98
|
await self.notify(title, message, **notify_kwargs)
|
92
99
|
return message
|
93
100
|
|
94
101
|
async def notify(self, title: str, message: str, **kwargs: Any) -> None:
|
95
|
-
task: BaseTask = kwargs.get(
|
102
|
+
task: BaseTask = kwargs.get("_task")
|
96
103
|
if self._show_toast and _is_powershell_available():
|
97
104
|
cmd = [
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
105
|
+
"powershell.exe",
|
106
|
+
"-ExecutionPolicy",
|
107
|
+
"Bypass",
|
108
|
+
"-File",
|
109
|
+
NOTIFY_PS1_PATH,
|
110
|
+
"-Title",
|
111
|
+
title,
|
112
|
+
"-Message",
|
113
|
+
message,
|
103
114
|
]
|
104
115
|
subprocess.run(cmd, stdout=subprocess.DEVNULL)
|
105
116
|
if self._show_toast and _is_osascript_available():
|
106
117
|
q_message = double_quote(message)
|
107
118
|
q_title = double_quote(title)
|
108
119
|
cmd = [
|
109
|
-
|
110
|
-
|
111
|
-
f'display notification "{q_message}" with title "{q_title}"'
|
120
|
+
"osascript",
|
121
|
+
"-e",
|
122
|
+
f'display notification "{q_message}" with title "{q_title}"',
|
112
123
|
]
|
113
124
|
if self._show_toast and _is_notify_send_available():
|
114
|
-
cmd = [
|
125
|
+
cmd = ["notify-send", title, message]
|
115
126
|
subprocess.run(cmd, stdout=subprocess.DEVNULL)
|
116
127
|
if self._show_stdout:
|
117
128
|
task.print_out(message)
|
@@ -121,9 +132,10 @@ class Notifier(BaseTask):
|
|
121
132
|
def _is_powershell_available():
|
122
133
|
try:
|
123
134
|
subprocess.run(
|
124
|
-
[
|
125
|
-
check=True,
|
126
|
-
|
135
|
+
["powershell.exe", "-Command", 'echo "Checking PowerShell"'],
|
136
|
+
check=True,
|
137
|
+
stdout=subprocess.DEVNULL,
|
138
|
+
stderr=subprocess.DEVNULL,
|
127
139
|
)
|
128
140
|
return True
|
129
141
|
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
|
@@ -133,10 +145,10 @@ def _is_powershell_available():
|
|
133
145
|
def _is_notify_send_available():
|
134
146
|
try:
|
135
147
|
subprocess.run(
|
136
|
-
[
|
148
|
+
["notify-send", "--version"],
|
137
149
|
check=True,
|
138
150
|
stdout=subprocess.DEVNULL,
|
139
|
-
stderr=subprocess.DEVNULL
|
151
|
+
stderr=subprocess.DEVNULL,
|
140
152
|
)
|
141
153
|
return True
|
142
154
|
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
|
@@ -146,10 +158,10 @@ def _is_notify_send_available():
|
|
146
158
|
def _is_osascript_available():
|
147
159
|
try:
|
148
160
|
subprocess.run(
|
149
|
-
[
|
161
|
+
["osascript", "-e", "return"],
|
150
162
|
check=True,
|
151
163
|
stdout=subprocess.DEVNULL,
|
152
|
-
stderr=subprocess.DEVNULL
|
164
|
+
stderr=subprocess.DEVNULL,
|
153
165
|
)
|
154
166
|
return True
|
155
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: JinjaTemplate =
|
52
|
+
path: JinjaTemplate = "",
|
41
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, JinjaTemplate, Callable[..., bool]] = True
|
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,27 +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,
|
3
|
-
|
6
|
+
Any,
|
7
|
+
Callable,
|
8
|
+
Iterable,
|
9
|
+
JinjaTemplate,
|
10
|
+
List,
|
11
|
+
Mapping,
|
12
|
+
Optional,
|
13
|
+
TypeVar,
|
14
|
+
Union,
|
4
15
|
)
|
5
|
-
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.file.match import get_file_names
|
7
|
-
from zrb.task.checker import Checker
|
8
16
|
from zrb.task.any_task import AnyTask
|
9
17
|
from zrb.task.any_task_event_handler import (
|
10
|
-
|
18
|
+
OnFailed,
|
19
|
+
OnReady,
|
20
|
+
OnRetry,
|
21
|
+
OnSkipped,
|
22
|
+
OnStarted,
|
23
|
+
OnTriggered,
|
24
|
+
OnWaiting,
|
11
25
|
)
|
26
|
+
from zrb.task.checker import Checker
|
12
27
|
from zrb.task_env.env import Env
|
13
28
|
from zrb.task_env.env_file import EnvFile
|
14
29
|
from zrb.task_group.group import Group
|
15
30
|
from zrb.task_input.any_input import AnyInput
|
16
31
|
|
17
|
-
|
18
|
-
|
19
|
-
TPathWatcher = TypeVar('TPathWatcher', bound='PathWatcher')
|
32
|
+
TPathWatcher = TypeVar("TPathWatcher", bound="PathWatcher")
|
20
33
|
|
21
34
|
|
22
35
|
@typechecked
|
23
36
|
class PathWatcher(Checker):
|
24
|
-
|
37
|
+
"""
|
25
38
|
PathWatcher will wait for any changes specified on path.
|
26
39
|
|
27
40
|
Once the changes detected, PathWatcher will be completed
|
@@ -30,18 +43,18 @@ class PathWatcher(Checker):
|
|
30
43
|
- <task-name>.new-file
|
31
44
|
- <task-name>.modified-file
|
32
45
|
- <task-name>.deleted-file
|
33
|
-
|
46
|
+
"""
|
34
47
|
|
35
48
|
def __init__(
|
36
49
|
self,
|
37
|
-
name: str =
|
50
|
+
name: str = "watch-path",
|
38
51
|
group: Optional[Group] = None,
|
39
52
|
inputs: Iterable[AnyInput] = [],
|
40
53
|
envs: Iterable[Env] = [],
|
41
54
|
env_files: Iterable[EnvFile] = [],
|
42
55
|
icon: Optional[str] = None,
|
43
56
|
color: Optional[str] = None,
|
44
|
-
description: str =
|
57
|
+
description: str = "",
|
45
58
|
upstreams: Iterable[AnyTask] = [],
|
46
59
|
on_triggered: Optional[OnTriggered] = None,
|
47
60
|
on_waiting: Optional[OnWaiting] = None,
|
@@ -50,14 +63,14 @@ class PathWatcher(Checker):
|
|
50
63
|
on_ready: Optional[OnReady] = None,
|
51
64
|
on_retry: Optional[OnRetry] = None,
|
52
65
|
on_failed: Optional[OnFailed] = None,
|
53
|
-
path: JinjaTemplate =
|
66
|
+
path: JinjaTemplate = "",
|
54
67
|
ignored_path: Union[JinjaTemplate, Iterable[JinjaTemplate]] = [],
|
55
68
|
checking_interval: Union[int, float] = 0.1,
|
56
69
|
progress_interval: Union[int, float] = 30,
|
57
70
|
watch_new_files: bool = True,
|
58
71
|
watch_modified_files: bool = True,
|
59
72
|
watch_deleted_files: bool = True,
|
60
|
-
should_execute: Union[bool, JinjaTemplate, Callable[..., bool]] = True
|
73
|
+
should_execute: Union[bool, JinjaTemplate, Callable[..., bool]] = True,
|
61
74
|
):
|
62
75
|
Checker.__init__(
|
63
76
|
self,
|
@@ -86,7 +99,7 @@ class PathWatcher(Checker):
|
|
86
99
|
self._watch_new_files = watch_new_files
|
87
100
|
self._watch_modified_files = watch_modified_files
|
88
101
|
self._watch_deleted_files = watch_deleted_files
|
89
|
-
self._rendered_path: str =
|
102
|
+
self._rendered_path: str = ""
|
90
103
|
self._rendered_ignored_paths: List[str] = []
|
91
104
|
self._init_times: Mapping[str, float] = {}
|
92
105
|
|
@@ -95,21 +108,19 @@ class PathWatcher(Checker):
|
|
95
108
|
|
96
109
|
def to_function(
|
97
110
|
self,
|
98
|
-
env_prefix: str =
|
111
|
+
env_prefix: str = "",
|
99
112
|
raise_error: bool = True,
|
100
113
|
is_async: bool = False,
|
101
|
-
show_done_info: bool = True
|
114
|
+
show_done_info: bool = True,
|
102
115
|
) -> Callable[..., bool]:
|
103
|
-
return super().to_function(
|
104
|
-
env_prefix, raise_error, is_async, show_done_info
|
105
|
-
)
|
116
|
+
return super().to_function(env_prefix, raise_error, is_async, show_done_info)
|
106
117
|
|
107
118
|
async def run(self, *args: Any, **kwargs: Any) -> bool:
|
108
119
|
self._rendered_path = self.render_str(self._path)
|
109
120
|
self._rendered_ignored_paths = [
|
110
121
|
ignored_path
|
111
122
|
for ignored_path in self._get_rendered_ignored_paths()
|
112
|
-
if ignored_path !=
|
123
|
+
if ignored_path != ""
|
113
124
|
]
|
114
125
|
self._init_times = self._get_mod_times()
|
115
126
|
return await super().run(*args, **kwargs)
|
@@ -117,50 +128,48 @@ class PathWatcher(Checker):
|
|
117
128
|
def _get_rendered_ignored_paths(self) -> List[str]:
|
118
129
|
if isinstance(self._ignored_path, str):
|
119
130
|
return [self.render_str(self._ignored_path)]
|
120
|
-
return [
|
121
|
-
self.render_str(ignored_path)
|
122
|
-
for ignored_path in self._ignored_path
|
123
|
-
]
|
131
|
+
return [self.render_str(ignored_path) for ignored_path in self._ignored_path]
|
124
132
|
|
125
133
|
async def inspect(self, *args: Any, **kwargs: Any) -> bool:
|
126
|
-
label = f
|
134
|
+
label = f"Watching {self._rendered_path}"
|
127
135
|
try:
|
128
136
|
mod_times = self._get_mod_times()
|
129
137
|
except Exception as e:
|
130
|
-
self.show_progress(f
|
138
|
+
self.show_progress(f"{label} Cannot inspect")
|
131
139
|
raise e
|
132
140
|
# watch changes
|
133
141
|
if self._watch_new_files:
|
134
142
|
new_files = mod_times.keys() - self._init_times.keys()
|
135
143
|
for file in new_files:
|
136
|
-
self.print_out_dark(f
|
137
|
-
self.set_task_xcom(
|
138
|
-
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)
|
139
147
|
return True
|
140
148
|
if self._watch_deleted_files:
|
141
149
|
deleted_files = self._init_times.keys() - mod_times.keys()
|
142
150
|
for file in deleted_files:
|
143
|
-
self.print_out_dark(f
|
144
|
-
self.set_task_xcom(
|
145
|
-
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)
|
146
154
|
return True
|
147
155
|
if self._watch_modified_files:
|
148
156
|
modified_files = {
|
149
|
-
file
|
157
|
+
file
|
158
|
+
for file, mod_time in mod_times.items()
|
150
159
|
if file in mod_times and self._init_times[file] != mod_time
|
151
160
|
}
|
152
161
|
for file in modified_files:
|
153
|
-
self.print_out_dark(f
|
154
|
-
self.set_task_xcom(
|
155
|
-
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)
|
156
165
|
return True
|
157
|
-
self.show_progress(f
|
166
|
+
self.show_progress(f"{label} (Nothing changed)")
|
158
167
|
return False
|
159
168
|
|
160
169
|
def _get_mod_times(self) -> Mapping[str, float]:
|
161
170
|
matches = get_file_names(
|
162
171
|
glob_path=self._rendered_path,
|
163
|
-
glob_ignored_paths=self._rendered_ignored_paths
|
172
|
+
glob_ignored_paths=self._rendered_ignored_paths,
|
164
173
|
)
|
165
174
|
mod_times: Mapping[str, float] = {}
|
166
175
|
for file_name in matches:
|
zrb/task/port_checker.py
CHANGED
@@ -1,45 +1,56 @@
|
|
1
|
+
import socket
|
2
|
+
|
3
|
+
from zrb.helper.typecheck import typechecked
|
1
4
|
from zrb.helper.typing import (
|
2
|
-
Any,
|
5
|
+
Any,
|
6
|
+
Callable,
|
7
|
+
Iterable,
|
8
|
+
JinjaTemplate,
|
9
|
+
Optional,
|
10
|
+
TypeVar,
|
11
|
+
Union,
|
3
12
|
)
|
4
|
-
from zrb.task.checker import Checker
|
5
|
-
from zrb.helper.typecheck import typechecked
|
6
13
|
from zrb.task.any_task import AnyTask
|
7
14
|
from zrb.task.any_task_event_handler import (
|
8
|
-
|
15
|
+
OnFailed,
|
16
|
+
OnReady,
|
17
|
+
OnRetry,
|
18
|
+
OnSkipped,
|
19
|
+
OnStarted,
|
20
|
+
OnTriggered,
|
21
|
+
OnWaiting,
|
9
22
|
)
|
23
|
+
from zrb.task.checker import Checker
|
10
24
|
from zrb.task_env.env import Env
|
11
25
|
from zrb.task_env.env_file import EnvFile
|
12
26
|
from zrb.task_group.group import Group
|
13
27
|
from zrb.task_input.any_input import AnyInput
|
14
28
|
|
15
|
-
|
16
|
-
|
17
|
-
TPortChecker = TypeVar('TPortChecker', bound='PortChecker')
|
29
|
+
TPortChecker = TypeVar("TPortChecker", bound="PortChecker")
|
18
30
|
|
19
31
|
|
20
32
|
@typechecked
|
21
|
-
class PortConfig
|
33
|
+
class PortConfig:
|
22
34
|
def __init__(self, host: str, port: int, timeout: int):
|
23
35
|
self.host = host
|
24
36
|
self.port = port
|
25
37
|
self.timeout = timeout
|
26
|
-
self.label = f
|
38
|
+
self.label = f"Checking {host}:{port}"
|
27
39
|
|
28
40
|
|
29
41
|
@typechecked
|
30
42
|
class PortChecker(Checker):
|
31
|
-
|
32
43
|
def __init__(
|
33
44
|
self,
|
34
|
-
name: str =
|
45
|
+
name: str = "check-port",
|
35
46
|
group: Optional[Group] = None,
|
36
47
|
inputs: Iterable[AnyInput] = [],
|
37
48
|
envs: Iterable[Env] = [],
|
38
49
|
env_files: Iterable[EnvFile] = [],
|
39
50
|
icon: Optional[str] = None,
|
40
51
|
color: Optional[str] = None,
|
41
|
-
description: str =
|
42
|
-
host: JinjaTemplate =
|
52
|
+
description: str = "",
|
53
|
+
host: JinjaTemplate = "localhost",
|
43
54
|
port: Union[int, JinjaTemplate] = 80,
|
44
55
|
timeout: Union[int, JinjaTemplate] = 5,
|
45
56
|
upstreams: Iterable[AnyTask] = [],
|
@@ -53,7 +64,7 @@ class PortChecker(Checker):
|
|
53
64
|
checking_interval: Union[int, float] = 0.1,
|
54
65
|
progress_interval: Union[int, float] = 5,
|
55
66
|
expected_result: bool = True,
|
56
|
-
should_execute: Union[bool, str, Callable[..., bool]] = True
|
67
|
+
should_execute: Union[bool, str, Callable[..., bool]] = True,
|
57
68
|
):
|
58
69
|
Checker.__init__(
|
59
70
|
self,
|
@@ -88,20 +99,18 @@ class PortChecker(Checker):
|
|
88
99
|
|
89
100
|
def to_function(
|
90
101
|
self,
|
91
|
-
env_prefix: str =
|
102
|
+
env_prefix: str = "",
|
92
103
|
raise_error: bool = True,
|
93
104
|
is_async: bool = False,
|
94
|
-
show_done_info: bool = True
|
105
|
+
show_done_info: bool = True,
|
95
106
|
) -> Callable[..., bool]:
|
96
|
-
return super().to_function(
|
97
|
-
env_prefix, raise_error, is_async, show_done_info
|
98
|
-
)
|
107
|
+
return super().to_function(env_prefix, raise_error, is_async, show_done_info)
|
99
108
|
|
100
109
|
async def run(self, *args: Any, **kwargs: Any) -> bool:
|
101
110
|
self._config = PortConfig(
|
102
111
|
host=self.render_str(self._host),
|
103
112
|
port=self.render_int(self._port),
|
104
|
-
timeout=self.render_int(self._timeout)
|
113
|
+
timeout=self.render_int(self._timeout),
|
105
114
|
)
|
106
115
|
return await super().run(*args, **kwargs)
|
107
116
|
|
@@ -109,13 +118,11 @@ class PortChecker(Checker):
|
|
109
118
|
try:
|
110
119
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
111
120
|
sock.settimeout(self._config.timeout)
|
112
|
-
result = sock.connect_ex(
|
113
|
-
(self._config.host, self._config.port)
|
114
|
-
)
|
121
|
+
result = sock.connect_ex((self._config.host, self._config.port))
|
115
122
|
if result == 0:
|
116
|
-
self.print_out(f
|
123
|
+
self.print_out(f"{self._config.label} (OK)")
|
117
124
|
return True
|
118
|
-
self.show_progress(f
|
125
|
+
self.show_progress(f"{self._config.label} (Not OK)")
|
119
126
|
except Exception:
|
120
|
-
self.show_progress(f
|
127
|
+
self.show_progress(f"{self._config.label} (Socker error)")
|
121
128
|
return False
|