Commit 11b2601e authored by qunfeng qiu's avatar qunfeng qiu
Browse files

Initial commit

parents
# Details
Date : 2023-10-27 16:38:11
Directory e:\\MyDesktop\\MyProgram\\PythonProject\\common_pkg
Total : 138 files, 31256 codes, 10094 comments, 5540 blanks, all 46890 lines
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
## Files
| filename | language | code | comment | blank | total |
| :--- | :--- | ---: | ---: | ---: | ---: |
| [__init__.py](/__init__.py) | Python | 0 | 0 | 1 | 1 |
| [cucc_common_pkg/__init__.py](/cucc_common_pkg/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/cfginfohandle.py](/cucc_common_pkg/cfginfohandle.py) | Python | 91 | 43 | 24 | 158 |
| [cucc_common_pkg/cucc_k8s.py](/cucc_common_pkg/cucc_k8s.py) | Python | 327 | 14 | 59 | 400 |
| [cucc_common_pkg/flask_wrapper.py](/cucc_common_pkg/flask_wrapper.py) | Python | 198 | 33 | 51 | 282 |
| [cucc_common_pkg/globalconst.py](/cucc_common_pkg/globalconst.py) | Python | 204 | 65 | 70 | 339 |
| [cucc_common_pkg/globalerror.py](/cucc_common_pkg/globalerror.py) | Python | 19 | 19 | 11 | 49 |
| [cucc_common_pkg/globalutility.py](/cucc_common_pkg/globalutility.py) | Python | 380 | 346 | 104 | 830 |
| [cucc_common_pkg/httptrans.py](/cucc_common_pkg/httptrans.py) | Python | 129 | 85 | 40 | 254 |
| [cucc_common_pkg/initflaskhanlde.py](/cucc_common_pkg/initflaskhanlde.py) | Python | 17 | 25 | 9 | 51 |
| [cucc_common_pkg/loginhandle.py](/cucc_common_pkg/loginhandle.py) | Python | 75 | 49 | 33 | 157 |
| [cucc_common_pkg/ludq_utils/README.md](/cucc_common_pkg/ludq_utils/README.md) | Markdown | 53 | 0 | 28 | 81 |
| [cucc_common_pkg/ludq_utils/__init__.py](/cucc_common_pkg/ludq_utils/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/aes_utils.py](/cucc_common_pkg/ludq_utils/aes_utils.py) | Python | 49 | 63 | 11 | 123 |
| [cucc_common_pkg/ludq_utils/app_exception.py](/cucc_common_pkg/ludq_utils/app_exception.py) | Python | 47 | 62 | 16 | 125 |
| [cucc_common_pkg/ludq_utils/app_response.py](/cucc_common_pkg/ludq_utils/app_response.py) | Python | 80 | 56 | 23 | 159 |
| [cucc_common_pkg/ludq_utils/base_const.py](/cucc_common_pkg/ludq_utils/base_const.py) | Python | 24 | 10 | 7 | 41 |
| [cucc_common_pkg/ludq_utils/base_db_service.py](/cucc_common_pkg/ludq_utils/base_db_service.py) | Python | 234 | 165 | 68 | 467 |
| [cucc_common_pkg/ludq_utils/base_redis_service.py](/cucc_common_pkg/ludq_utils/base_redis_service.py) | Python | 264 | 229 | 87 | 580 |
| [cucc_common_pkg/ludq_utils/cert_utils.py](/cucc_common_pkg/ludq_utils/cert_utils.py) | Python | 261 | 164 | 59 | 484 |
| [cucc_common_pkg/ludq_utils/common_app_config.py](/cucc_common_pkg/ludq_utils/common_app_config.py) | Python | 125 | 42 | 28 | 195 |
| [cucc_common_pkg/ludq_utils/common_base_webservice.py](/cucc_common_pkg/ludq_utils/common_base_webservice.py) | Python | 408 | 297 | 90 | 795 |
| [cucc_common_pkg/ludq_utils/common_base_webservice_for_stream.py](/cucc_common_pkg/ludq_utils/common_base_webservice_for_stream.py) | Python | 33 | 20 | 12 | 65 |
| [cucc_common_pkg/ludq_utils/logined_user.py](/cucc_common_pkg/ludq_utils/logined_user.py) | Python | 53 | 27 | 15 | 95 |
| [cucc_common_pkg/ludq_utils/md5_utils.py](/cucc_common_pkg/ludq_utils/md5_utils.py) | Python | 15 | 14 | 5 | 34 |
| [cucc_common_pkg/ludq_utils/rsa_utils.py](/cucc_common_pkg/ludq_utils/rsa_utils.py) | Python | 36 | 49 | 14 | 99 |
| [cucc_common_pkg/ludq_utils/send_notices_utils.py](/cucc_common_pkg/ludq_utils/send_notices_utils.py) | Python | 176 | 84 | 58 | 318 |
| [cucc_common_pkg/ludq_utils/util_methods.py](/cucc_common_pkg/ludq_utils/util_methods.py) | Python | 305 | 59 | 27 | 391 |
| [cucc_common_pkg/ludq_utils/utils_base.py](/cucc_common_pkg/ludq_utils/utils_base.py) | Python | 880 | 361 | 137 | 1,378 |
| [cucc_common_pkg/ludq_utils/utils_get_cluster_info/__init__.py](/cucc_common_pkg/ludq_utils/utils_get_cluster_info/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_get_cluster_info/cluster_info.py](/cucc_common_pkg/ludq_utils/utils_get_cluster_info/cluster_info.py) | Python | 69 | 54 | 13 | 136 |
| [cucc_common_pkg/ludq_utils/utils_get_cluster_info/get_cluster_info_utils.py](/cucc_common_pkg/ludq_utils/utils_get_cluster_info/get_cluster_info_utils.py) | Python | 1,221 | 208 | 146 | 1,575 |
| [cucc_common_pkg/ludq_utils/utils_http/__init__.py](/cucc_common_pkg/ludq_utils/utils_http/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_http/call_k8s_api_utils.py](/cucc_common_pkg/ludq_utils/utils_http/call_k8s_api_utils.py) | Python | 227 | 81 | 28 | 336 |
| [cucc_common_pkg/ludq_utils/utils_http/http_cookie.py](/cucc_common_pkg/ludq_utils/utils_http/http_cookie.py) | Python | 22 | 25 | 8 | 55 |
| [cucc_common_pkg/ludq_utils/utils_http/http_utils.py](/cucc_common_pkg/ludq_utils/utils_http/http_utils.py) | Python | 131 | 230 | 28 | 389 |
| [cucc_common_pkg/ludq_utils/utils_k8s/__init__.py](/cucc_common_pkg/ludq_utils/utils_k8s/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_k8s/cr_utils.py](/cucc_common_pkg/ludq_utils/utils_k8s/cr_utils.py) | Python | 148 | 94 | 25 | 267 |
| [cucc_common_pkg/ludq_utils/utils_k8s/k8s_api_object_utils.py](/cucc_common_pkg/ludq_utils/utils_k8s/k8s_api_object_utils.py) | Python | 3,036 | 615 | 269 | 3,920 |
| [cucc_common_pkg/ludq_utils/utils_k8s/k8s_api_object_utils_v2.py](/cucc_common_pkg/ludq_utils/utils_k8s/k8s_api_object_utils_v2.py) | Python | 1,399 | 526 | 162 | 2,087 |
| [cucc_common_pkg/ludq_utils/utils_k8s/k8s_api_objects.py](/cucc_common_pkg/ludq_utils/utils_k8s/k8s_api_objects.py) | Python | 890 | 141 | 87 | 1,118 |
| [cucc_common_pkg/ludq_utils/utils_k8s/k8s_model.py](/cucc_common_pkg/ludq_utils/utils_k8s/k8s_model.py) | Python | 43 | 22 | 15 | 80 |
| [cucc_common_pkg/ludq_utils/utils_k8s/k8s_utils.py](/cucc_common_pkg/ludq_utils/utils_k8s/k8s_utils.py) | Python | 629 | 279 | 85 | 993 |
| [cucc_common_pkg/ludq_utils/utils_k8s_istio/__init__.py](/cucc_common_pkg/ludq_utils/utils_k8s_istio/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_k8s_knative/__init__.py](/cucc_common_pkg/ludq_utils/utils_k8s_knative/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_k8s_knative/knative_service_obj.py](/cucc_common_pkg/ludq_utils/utils_k8s_knative/knative_service_obj.py) | Python | 516 | 228 | 151 | 895 |
| [cucc_common_pkg/ludq_utils/utils_k8s_knative/knative_utils.py](/cucc_common_pkg/ludq_utils/utils_k8s_knative/knative_utils.py) | Python | 86 | 44 | 16 | 146 |
| [cucc_common_pkg/ludq_utils/utils_k8s_knative/tekton_taskrun_obj.py](/cucc_common_pkg/ludq_utils/utils_k8s_knative/tekton_taskrun_obj.py) | Python | 28 | 23 | 10 | 61 |
| [cucc_common_pkg/ludq_utils/utils_k8s_knative/tekton_utils.py](/cucc_common_pkg/ludq_utils/utils_k8s_knative/tekton_utils.py) | Python | 82 | 43 | 16 | 141 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/__init__.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/base_app_vpc_utils.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/base_app_vpc_utils.py) | Python | 224 | 96 | 26 | 346 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/base_const_for_mesh_mng.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/base_const_for_mesh_mng.py) | Python | 95 | 10 | 29 | 134 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/base_model_for_mesh_mng.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/base_model_for_mesh_mng.py) | Python | 68 | 30 | 17 | 115 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/base_utils_for_mesh_mng.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/base_utils_for_mesh_mng.py) | Python | 202 | 42 | 21 | 265 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/ca_source_info.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/ca_source_info.py) | Python | 41 | 17 | 13 | 71 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/cluster_istio.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/cluster_istio.py) | Python | 1,236 | 248 | 248 | 1,732 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/csm_instance.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/csm_instance.py) | Python | 258 | 60 | 54 | 372 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/csm_instance_cluster.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/csm_instance_cluster.py) | Python | 110 | 38 | 28 | 176 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/csm_instance_db_service.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/csm_instance_db_service.py) | Python | 581 | 181 | 78 | 840 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/cuk_clb_info.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/cuk_clb_info.py) | Python | 35 | 24 | 13 | 72 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/describe_cluster_istio.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/describe_cluster_istio.py) | Python | 1,085 | 196 | 152 | 1,433 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/maintain_func_utils.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/maintain_func_utils.py) | Python | 1,186 | 347 | 152 | 1,685 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/manage_istio_in_k8s.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/manage_istio_in_k8s.py) | Python | 236 | 31 | 23 | 290 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/query_istio_in_k8s.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/query_istio_in_k8s.py) | Python | 2,116 | 556 | 264 | 2,936 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/spire_config.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/spire_config.py) | Python | 28 | 20 | 11 | 59 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/spire_func_utils.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/spire_func_utils.py) | Python | 955 | 204 | 155 | 1,314 |
| [cucc_common_pkg/ludq_utils/utils_mesh_mng/thread_delete_maintain_res_svc.py](/cucc_common_pkg/ludq_utils/utils_mesh_mng/thread_delete_maintain_res_svc.py) | Python | 50 | 12 | 12 | 74 |
| [cucc_common_pkg/ludq_utils/utils_promapi/__init__.py](/cucc_common_pkg/ludq_utils/utils_promapi/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_promapi/prom_config.py](/cucc_common_pkg/ludq_utils/utils_promapi/prom_config.py) | Python | 12 | 15 | 5 | 32 |
| [cucc_common_pkg/ludq_utils/utils_promapi/prom_result_vector.py](/cucc_common_pkg/ludq_utils/utils_promapi/prom_result_vector.py) | Python | 59 | 20 | 16 | 95 |
| [cucc_common_pkg/ludq_utils/utils_promapi/prom_utils.py](/cucc_common_pkg/ludq_utils/utils_promapi/prom_utils.py) | Python | 243 | 38 | 23 | 304 |
| [cucc_common_pkg/ludq_utils/utils_tg_billing/__init__.py](/cucc_common_pkg/ludq_utils/utils_tg_billing/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_tg_billing/billing_create_order_info.py](/cucc_common_pkg/ludq_utils/utils_tg_billing/billing_create_order_info.py) | Python | 51 | 20 | 14 | 85 |
| [cucc_common_pkg/ludq_utils/utils_tg_billing/billing_feededuct_info.py](/cucc_common_pkg/ludq_utils/utils_tg_billing/billing_feededuct_info.py) | Python | 29 | 17 | 8 | 54 |
| [cucc_common_pkg/ludq_utils/utils_tg_billing/billing_update_order_info.py](/cucc_common_pkg/ludq_utils/utils_tg_billing/billing_update_order_info.py) | Python | 19 | 15 | 8 | 42 |
| [cucc_common_pkg/ludq_utils/utils_tg_billing/billing_utils.py](/cucc_common_pkg/ludq_utils/utils_tg_billing/billing_utils.py) | Python | 143 | 85 | 46 | 274 |
| [cucc_common_pkg/ludq_utils/utils_tg_configcenter/__init__.py](/cucc_common_pkg/ludq_utils/utils_tg_configcenter/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_tg_configcenter/configcenter_region_quota.py](/cucc_common_pkg/ludq_utils/utils_tg_configcenter/configcenter_region_quota.py) | Python | 70 | 34 | 20 | 124 |
| [cucc_common_pkg/ludq_utils/utils_tg_configcenter/configcenter_response.py](/cucc_common_pkg/ludq_utils/utils_tg_configcenter/configcenter_response.py) | Python | 19 | 18 | 9 | 46 |
| [cucc_common_pkg/ludq_utils/utils_tg_configcenter/configcenter_utils.py](/cucc_common_pkg/ludq_utils/utils_tg_configcenter/configcenter_utils.py) | Python | 247 | 94 | 49 | 390 |
| [cucc_common_pkg/ludq_utils/utils_tg_iam/__init__.py](/cucc_common_pkg/ludq_utils/utils_tg_iam/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_tg_iam/iam_instance.py](/cucc_common_pkg/ludq_utils/utils_tg_iam/iam_instance.py) | Python | 14 | 16 | 11 | 41 |
| [cucc_common_pkg/ludq_utils/utils_tg_iam/iam_response.py](/cucc_common_pkg/ludq_utils/utils_tg_iam/iam_response.py) | Python | 9 | 12 | 6 | 27 |
| [cucc_common_pkg/ludq_utils/utils_tg_iam/iam_utils.py](/cucc_common_pkg/ludq_utils/utils_tg_iam/iam_utils.py) | Python | 268 | 110 | 58 | 436 |
| [cucc_common_pkg/ludq_utils/utils_tg_sso/__init__.py](/cucc_common_pkg/ludq_utils/utils_tg_sso/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_tg_sso/sso_utils.py](/cucc_common_pkg/ludq_utils/utils_tg_sso/sso_utils.py) | Python | 165 | 63 | 39 | 267 |
| [cucc_common_pkg/ludq_utils/utils_tg_vpc/__init__.py](/cucc_common_pkg/ludq_utils/utils_tg_vpc/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_tg_vpc/vpc_utils.py](/cucc_common_pkg/ludq_utils/utils_tg_vpc/vpc_utils.py) | Python | 541 | 102 | 85 | 728 |
| [cucc_common_pkg/ludq_utils/utils_v2.py](/cucc_common_pkg/ludq_utils/utils_v2.py) | Python | 52 | 26 | 15 | 93 |
| [cucc_common_pkg/ludq_utils/utils_webservice/__init__.py](/cucc_common_pkg/ludq_utils/utils_webservice/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [cucc_common_pkg/ludq_utils/utils_webservice/change_logging_level.py](/cucc_common_pkg/ludq_utils/utils_webservice/change_logging_level.py) | Python | 40 | 19 | 16 | 75 |
| [cucc_common_pkg/ludq_utils/utils_webservice/common_base_webservice_for_stream_v2.py](/cucc_common_pkg/ludq_utils/utils_webservice/common_base_webservice_for_stream_v2.py) | Python | 75 | 22 | 17 | 114 |
| [cucc_common_pkg/ludq_utils/utils_webservice/common_base_webservice_v2.py](/cucc_common_pkg/ludq_utils/utils_webservice/common_base_webservice_v2.py) | Python | 351 | 200 | 82 | 633 |
| [cucc_common_pkg/ludq_utils/utils_webservice/show_logging_level.py](/cucc_common_pkg/ludq_utils/utils_webservice/show_logging_level.py) | Python | 14 | 13 | 7 | 34 |
| [cucc_common_pkg/my_anykeyvalue_utils.py](/cucc_common_pkg/my_anykeyvalue_utils.py) | Python | 65 | 17 | 24 | 106 |
| [cucc_common_pkg/my_baseexception.py](/cucc_common_pkg/my_baseexception.py) | Python | 88 | 81 | 30 | 199 |
| [cucc_common_pkg/my_basehttpsrvlet.py](/cucc_common_pkg/my_basehttpsrvlet.py) | Python | 451 | 17 | 122 | 590 |
| [cucc_common_pkg/my_datahandle/__init__.py](/cucc_common_pkg/my_datahandle/__init__.py) | Python | 0 | 0 | 1 | 1 |
| [cucc_common_pkg/my_datahandle/const.py](/cucc_common_pkg/my_datahandle/const.py) | Python | 81 | 24 | 13 | 118 |
| [cucc_common_pkg/my_datahandle/datahandle_utility.py](/cucc_common_pkg/my_datahandle/datahandle_utility.py) | Python | 222 | 132 | 33 | 387 |
| [cucc_common_pkg/my_servicehandle.py](/cucc_common_pkg/my_servicehandle.py) | Python | 486 | 33 | 117 | 636 |
| [cucc_common_pkg/my_stringutils.py](/cucc_common_pkg/my_stringutils.py) | Python | 15 | 41 | 9 | 65 |
| [cucc_common_pkg/my_structure_utils.py](/cucc_common_pkg/my_structure_utils.py) | Python | 1,046 | 55 | 253 | 1,354 |
| [cucc_common_pkg/my_utils.py](/cucc_common_pkg/my_utils.py) | Python | 167 | 128 | 47 | 342 |
| [cucc_common_pkg/mysql_utils.py](/cucc_common_pkg/mysql_utils.py) | Python | 172 | 131 | 45 | 348 |
| [cucc_common_pkg/redishanlde.py](/cucc_common_pkg/redishanlde.py) | Python | 236 | 172 | 74 | 482 |
| [cucc_common_pkg/simple_sql_opt.py](/cucc_common_pkg/simple_sql_opt.py) | Python | 137 | 20 | 12 | 169 |
| [cucc_common_pkg/sky_baseexception.py](/cucc_common_pkg/sky_baseexception.py) | Python | 126 | 35 | 39 | 200 |
| [cucc_common_pkg/sky_httptrans.py](/cucc_common_pkg/sky_httptrans.py) | Python | 164 | 96 | 49 | 309 |
| [cucc_common_pkg/util_pkg/__init__.py](/cucc_common_pkg/util_pkg/__init__.py) | Python | 8 | 0 | 1 | 9 |
| [cucc_common_pkg/util_pkg/cke_cluster_info.py](/cucc_common_pkg/util_pkg/cke_cluster_info.py) | Python | 164 | 2 | 14 | 180 |
| [cucc_common_pkg/util_pkg/common_dao.py](/cucc_common_pkg/util_pkg/common_dao.py) | Python | 252 | 122 | 30 | 404 |
| [cucc_common_pkg/util_pkg/common_func.py](/cucc_common_pkg/util_pkg/common_func.py) | Python | 323 | 120 | 33 | 476 |
| [cucc_common_pkg/util_pkg/const.py](/cucc_common_pkg/util_pkg/const.py) | Python | 243 | 39 | 40 | 322 |
| [cucc_common_pkg/util_pkg/csk_cluster_info.py](/cucc_common_pkg/util_pkg/csk_cluster_info.py) | Python | 159 | 2 | 14 | 175 |
| [cucc_common_pkg/util_pkg/cuk_cluster_info.py](/cucc_common_pkg/util_pkg/cuk_cluster_info.py) | Python | 163 | 9 | 14 | 186 |
| [cucc_common_pkg/util_pkg/kube_cluster_info_get.py](/cucc_common_pkg/util_pkg/kube_cluster_info_get.py) | Python | 194 | 42 | 18 | 254 |
| [cucc_common_pkg/util_pkg/login_verify.py](/cucc_common_pkg/util_pkg/login_verify.py) | Python | 181 | 2 | 15 | 198 |
| [cucc_common_pkg/util_pkg/login_verify_low_require.py](/cucc_common_pkg/util_pkg/login_verify_low_require.py) | Python | 47 | 2 | 7 | 56 |
| [cucc_common_pkg/util_pkg/namespace_opt.py](/cucc_common_pkg/util_pkg/namespace_opt.py) | Python | 99 | 31 | 10 | 140 |
| [cucc_common_pkg/util_pkg/resource_obj_opt.py](/cucc_common_pkg/util_pkg/resource_obj_opt.py) | Python | 130 | 85 | 11 | 226 |
| [requirements.txt](/requirements.txt) | pip requirements | 46 | 0 | 1 | 47 |
| [setup.py](/setup.py) | Python | 73 | 11 | 4 | 88 |
| [test/__init__.py](/test/__init__.py) | Python | 0 | 10 | 1 | 11 |
| [test/test_flask_wrapper.py](/test/test_flask_wrapper.py) | Python | 16 | 10 | 9 | 35 |
| [test/test_httptrans.py](/test/test_httptrans.py) | Python | 64 | 13 | 23 | 100 |
| [test/test_k8s_op.py](/test/test_k8s_op.py) | Python | 136 | 15 | 40 | 191 |
| [test/test_ludq_k8s_utils.py](/test/test_ludq_k8s_utils.py) | Python | 202 | 284 | 30 | 516 |
| [test/test_ludq_utils_v2.py](/test/test_ludq_utils_v2.py) | Python | 21 | 15 | 9 | 45 |
| [test/test_my_anykeyvalue_tils.py](/test/test_my_anykeyvalue_tils.py) | Python | 21 | 10 | 11 | 42 |
| [test/test_my_baseexception.py](/test/test_my_baseexception.py) | Python | 69 | 10 | 18 | 97 |
| [test/test_my_servicehandle.py](/test/test_my_servicehandle.py) | Python | 202 | 10 | 72 | 284 |
| [test/test_my_stringutils.py](/test/test_my_stringutils.py) | Python | 30 | 10 | 16 | 56 |
| [test/test_my_structure_utils.py](/test/test_my_structure_utils.py) | Python | 402 | 10 | 49 | 461 |
| [test/test_mysqlutils.py](/test/test_mysqlutils.py) | Python | 90 | 10 | 28 | 128 |
| [test/test_redis_sentinel_handle.py](/test/test_redis_sentinel_handle.py) | Python | 43 | 15 | 18 | 76 |
| [test/test_redishandle.py](/test/test_redishandle.py) | Python | 76 | 18 | 33 | 127 |
| [test/test_utility.py](/test/test_utility.py) | Python | 409 | 10 | 112 | 531 |
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
\ No newline at end of file
# Diff Details
Date : 2023-10-27 16:38:11
Directory e:\\MyDesktop\\MyProgram\\PythonProject\\common_pkg
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
## Files
| filename | language | code | comment | blank | total |
| :--- | :--- | ---: | ---: | ---: | ---: |
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
\ No newline at end of file
"filename", "language", "", "comment", "blank", "total"
"Total", "-", , 0, 0, 0
\ No newline at end of file
# Diff Summary
Date : 2023-10-27 16:38:11
Directory e:\\MyDesktop\\MyProgram\\PythonProject\\common_pkg
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
## Languages
| language | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
## Directories
| path | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
\ No newline at end of file
Date : 2023-10-27 16:38:11
Directory : e:\MyDesktop\MyProgram\PythonProject\common_pkg
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
Languages
+----------+------------+------------+------------+------------+------------+
| language | files | code | comment | blank | total |
+----------+------------+------------+------------+------------+------------+
+----------+------------+------------+------------+------------+------------+
Directories
+------+------------+------------+------------+------------+------------+
| path | files | code | comment | blank | total |
+------+------------+------------+------------+------------+------------+
+------+------------+------------+------------+------------+------------+
Files
+----------+----------+------------+------------+------------+------------+
| filename | language | code | comment | blank | total |
+----------+----------+------------+------------+------------+------------+
| Total | | 0 | 0 | 0 | 0 |
+----------+----------+------------+------------+------------+------------+
\ No newline at end of file
"filename", "language", "Python", "pip requirements", "Markdown", "comment", "blank", "total"
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\__init__.py", "Python", 0, 0, 0, 0, 1, 1
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\cfginfohandle.py", "Python", 91, 0, 0, 43, 24, 158
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\cucc_k8s.py", "Python", 327, 0, 0, 14, 59, 400
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\flask_wrapper.py", "Python", 198, 0, 0, 33, 51, 282
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\globalconst.py", "Python", 204, 0, 0, 65, 70, 339
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\globalerror.py", "Python", 19, 0, 0, 19, 11, 49
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\globalutility.py", "Python", 380, 0, 0, 346, 104, 830
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\httptrans.py", "Python", 129, 0, 0, 85, 40, 254
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\initflaskhanlde.py", "Python", 17, 0, 0, 25, 9, 51
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\loginhandle.py", "Python", 75, 0, 0, 49, 33, 157
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\README.md", "Markdown", 0, 0, 53, 0, 28, 81
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\aes_utils.py", "Python", 49, 0, 0, 63, 11, 123
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\app_exception.py", "Python", 47, 0, 0, 62, 16, 125
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\app_response.py", "Python", 80, 0, 0, 56, 23, 159
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\base_const.py", "Python", 24, 0, 0, 10, 7, 41
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\base_db_service.py", "Python", 234, 0, 0, 165, 68, 467
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\base_redis_service.py", "Python", 264, 0, 0, 229, 87, 580
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\cert_utils.py", "Python", 261, 0, 0, 164, 59, 484
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\common_app_config.py", "Python", 125, 0, 0, 42, 28, 195
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\common_base_webservice.py", "Python", 408, 0, 0, 297, 90, 795
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\common_base_webservice_for_stream.py", "Python", 33, 0, 0, 20, 12, 65
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\logined_user.py", "Python", 53, 0, 0, 27, 15, 95
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\md5_utils.py", "Python", 15, 0, 0, 14, 5, 34
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\rsa_utils.py", "Python", 36, 0, 0, 49, 14, 99
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\send_notices_utils.py", "Python", 176, 0, 0, 84, 58, 318
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\util_methods.py", "Python", 305, 0, 0, 59, 27, 391
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_base.py", "Python", 880, 0, 0, 361, 137, 1378
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_get_cluster_info\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_get_cluster_info\cluster_info.py", "Python", 69, 0, 0, 54, 13, 136
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_get_cluster_info\get_cluster_info_utils.py", "Python", 1221, 0, 0, 208, 146, 1575
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_http\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_http\call_k8s_api_utils.py", "Python", 227, 0, 0, 81, 28, 336
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_http\http_cookie.py", "Python", 22, 0, 0, 25, 8, 55
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_http\http_utils.py", "Python", 131, 0, 0, 230, 28, 389
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s\cr_utils.py", "Python", 148, 0, 0, 94, 25, 267
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s\k8s_api_object_utils.py", "Python", 3036, 0, 0, 615, 269, 3920
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s\k8s_api_object_utils_v2.py", "Python", 1399, 0, 0, 526, 162, 2087
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s\k8s_api_objects.py", "Python", 890, 0, 0, 141, 87, 1118
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s\k8s_model.py", "Python", 43, 0, 0, 22, 15, 80
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s\k8s_utils.py", "Python", 629, 0, 0, 279, 85, 993
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s_istio\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s_knative\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s_knative\knative_service_obj.py", "Python", 516, 0, 0, 228, 151, 895
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s_knative\knative_utils.py", "Python", 86, 0, 0, 44, 16, 146
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s_knative\tekton_taskrun_obj.py", "Python", 28, 0, 0, 23, 10, 61
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_k8s_knative\tekton_utils.py", "Python", 82, 0, 0, 43, 16, 141
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\base_app_vpc_utils.py", "Python", 224, 0, 0, 96, 26, 346
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\base_const_for_mesh_mng.py", "Python", 95, 0, 0, 10, 29, 134
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\base_model_for_mesh_mng.py", "Python", 68, 0, 0, 30, 17, 115
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\base_utils_for_mesh_mng.py", "Python", 202, 0, 0, 42, 21, 265
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\ca_source_info.py", "Python", 41, 0, 0, 17, 13, 71
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\cluster_istio.py", "Python", 1236, 0, 0, 248, 248, 1732
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\csm_instance.py", "Python", 258, 0, 0, 60, 54, 372
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\csm_instance_cluster.py", "Python", 110, 0, 0, 38, 28, 176
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\csm_instance_db_service.py", "Python", 581, 0, 0, 181, 78, 840
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\cuk_clb_info.py", "Python", 35, 0, 0, 24, 13, 72
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\describe_cluster_istio.py", "Python", 1085, 0, 0, 196, 152, 1433
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\maintain_func_utils.py", "Python", 1186, 0, 0, 347, 152, 1685
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\manage_istio_in_k8s.py", "Python", 236, 0, 0, 31, 23, 290
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\query_istio_in_k8s.py", "Python", 2116, 0, 0, 556, 264, 2936
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\spire_config.py", "Python", 28, 0, 0, 20, 11, 59
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\spire_func_utils.py", "Python", 955, 0, 0, 204, 155, 1314
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_mesh_mng\thread_delete_maintain_res_svc.py", "Python", 50, 0, 0, 12, 12, 74
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_promapi\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_promapi\prom_config.py", "Python", 12, 0, 0, 15, 5, 32
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_promapi\prom_result_vector.py", "Python", 59, 0, 0, 20, 16, 95
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_promapi\prom_utils.py", "Python", 243, 0, 0, 38, 23, 304
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_billing\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_billing\billing_create_order_info.py", "Python", 51, 0, 0, 20, 14, 85
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_billing\billing_feededuct_info.py", "Python", 29, 0, 0, 17, 8, 54
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_billing\billing_update_order_info.py", "Python", 19, 0, 0, 15, 8, 42
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_billing\billing_utils.py", "Python", 143, 0, 0, 85, 46, 274
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_configcenter\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_configcenter\configcenter_region_quota.py", "Python", 70, 0, 0, 34, 20, 124
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_configcenter\configcenter_response.py", "Python", 19, 0, 0, 18, 9, 46
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_configcenter\configcenter_utils.py", "Python", 247, 0, 0, 94, 49, 390
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_iam\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_iam\iam_instance.py", "Python", 14, 0, 0, 16, 11, 41
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_iam\iam_response.py", "Python", 9, 0, 0, 12, 6, 27
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_iam\iam_utils.py", "Python", 268, 0, 0, 110, 58, 436
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_sso\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_sso\sso_utils.py", "Python", 165, 0, 0, 63, 39, 267
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_vpc\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_tg_vpc\vpc_utils.py", "Python", 541, 0, 0, 102, 85, 728
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_v2.py", "Python", 52, 0, 0, 26, 15, 93
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_webservice\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_webservice\change_logging_level.py", "Python", 40, 0, 0, 19, 16, 75
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_webservice\common_base_webservice_for_stream_v2.py", "Python", 75, 0, 0, 22, 17, 114
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_webservice\common_base_webservice_v2.py", "Python", 351, 0, 0, 200, 82, 633
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\ludq_utils\utils_webservice\show_logging_level.py", "Python", 14, 0, 0, 13, 7, 34
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_anykeyvalue_utils.py", "Python", 65, 0, 0, 17, 24, 106
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_baseexception.py", "Python", 88, 0, 0, 81, 30, 199
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_basehttpsrvlet.py", "Python", 451, 0, 0, 17, 122, 590
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_datahandle\__init__.py", "Python", 0, 0, 0, 0, 1, 1
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_datahandle\const.py", "Python", 81, 0, 0, 24, 13, 118
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_datahandle\datahandle_utility.py", "Python", 222, 0, 0, 132, 33, 387
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_servicehandle.py", "Python", 486, 0, 0, 33, 117, 636
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_stringutils.py", "Python", 15, 0, 0, 41, 9, 65
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_structure_utils.py", "Python", 1046, 0, 0, 55, 253, 1354
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\my_utils.py", "Python", 167, 0, 0, 128, 47, 342
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\mysql_utils.py", "Python", 172, 0, 0, 131, 45, 348
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\redishanlde.py", "Python", 236, 0, 0, 172, 74, 482
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\simple_sql_opt.py", "Python", 137, 0, 0, 20, 12, 169
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\sky_baseexception.py", "Python", 126, 0, 0, 35, 39, 200
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\sky_httptrans.py", "Python", 164, 0, 0, 96, 49, 309
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\__init__.py", "Python", 8, 0, 0, 0, 1, 9
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\cke_cluster_info.py", "Python", 164, 0, 0, 2, 14, 180
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\common_dao.py", "Python", 252, 0, 0, 122, 30, 404
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\common_func.py", "Python", 323, 0, 0, 120, 33, 476
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\const.py", "Python", 243, 0, 0, 39, 40, 322
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\csk_cluster_info.py", "Python", 159, 0, 0, 2, 14, 175
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\cuk_cluster_info.py", "Python", 163, 0, 0, 9, 14, 186
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\kube_cluster_info_get.py", "Python", 194, 0, 0, 42, 18, 254
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\login_verify.py", "Python", 181, 0, 0, 2, 15, 198
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\login_verify_low_require.py", "Python", 47, 0, 0, 2, 7, 56
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\namespace_opt.py", "Python", 99, 0, 0, 31, 10, 140
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\cucc_common_pkg\util_pkg\resource_obj_opt.py", "Python", 130, 0, 0, 85, 11, 226
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\requirements.txt", "pip requirements", 0, 46, 0, 0, 1, 47
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\setup.py", "Python", 73, 0, 0, 11, 4, 88
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\__init__.py", "Python", 0, 0, 0, 10, 1, 11
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_flask_wrapper.py", "Python", 16, 0, 0, 10, 9, 35
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_httptrans.py", "Python", 64, 0, 0, 13, 23, 100
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_k8s_op.py", "Python", 136, 0, 0, 15, 40, 191
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_ludq_k8s_utils.py", "Python", 202, 0, 0, 284, 30, 516
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_ludq_utils_v2.py", "Python", 21, 0, 0, 15, 9, 45
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_my_anykeyvalue_tils.py", "Python", 21, 0, 0, 10, 11, 42
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_my_baseexception.py", "Python", 69, 0, 0, 10, 18, 97
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_my_servicehandle.py", "Python", 202, 0, 0, 10, 72, 284
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_my_stringutils.py", "Python", 30, 0, 0, 10, 16, 56
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_my_structure_utils.py", "Python", 402, 0, 0, 10, 49, 461
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_mysqlutils.py", "Python", 90, 0, 0, 10, 28, 128
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_redis_sentinel_handle.py", "Python", 43, 0, 0, 15, 18, 76
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_redishandle.py", "Python", 76, 0, 0, 18, 33, 127
"e:\MyDesktop\MyProgram\PythonProject\common_pkg\test\test_utility.py", "Python", 409, 0, 0, 10, 112, 531
"Total", "-", 31157, 46, 53, 10094, 5540, 46890
\ No newline at end of file
This diff is collapsed.
# Summary
Date : 2023-10-27 16:38:11
Directory e:\\MyDesktop\\MyProgram\\PythonProject\\common_pkg
Total : 138 files, 31256 codes, 10094 comments, 5540 blanks, all 46890 lines
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
## Languages
| language | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
| Python | 136 | 31,157 | 10,094 | 5,511 | 46,762 |
| Markdown | 1 | 53 | 0 | 28 | 81 |
| pip requirements | 1 | 46 | 0 | 1 | 47 |
## Directories
| path | files | code | comment | blank | total |
| :--- | ---: | ---: | ---: | ---: | ---: |
| . | 138 | 31,256 | 10,094 | 5,540 | 46,890 |
| . (Files) | 3 | 119 | 11 | 6 | 136 |
| cucc_common_pkg | 120 | 29,356 | 9,633 | 5,065 | 44,054 |
| cucc_common_pkg (Files) | 22 | 4,593 | 1,515 | 1,223 | 7,331 |
| cucc_common_pkg\\ludq_utils | 83 | 22,497 | 7,506 | 3,588 | 33,591 |
| cucc_common_pkg\\ludq_utils (Files) | 19 | 3,095 | 1,738 | 701 | 5,534 |
| cucc_common_pkg\\ludq_utils\\utils_get_cluster_info | 3 | 1,290 | 272 | 160 | 1,722 |
| cucc_common_pkg\\ludq_utils\\utils_http | 4 | 380 | 346 | 65 | 791 |
| cucc_common_pkg\\ludq_utils\\utils_k8s | 7 | 6,145 | 1,687 | 644 | 8,476 |
| cucc_common_pkg\\ludq_utils\\utils_k8s_istio | 1 | 0 | 10 | 1 | 11 |
| cucc_common_pkg\\ludq_utils\\utils_k8s_knative | 5 | 712 | 348 | 194 | 1,254 |
| cucc_common_pkg\\ludq_utils\\utils_mesh_mng | 18 | 8,506 | 2,122 | 1,297 | 11,925 |
| cucc_common_pkg\\ludq_utils\\utils_promapi | 4 | 314 | 83 | 45 | 442 |
| cucc_common_pkg\\ludq_utils\\utils_tg_billing | 5 | 242 | 147 | 77 | 466 |
| cucc_common_pkg\\ludq_utils\\utils_tg_configcenter | 4 | 336 | 156 | 79 | 571 |
| cucc_common_pkg\\ludq_utils\\utils_tg_iam | 4 | 291 | 148 | 76 | 515 |
| cucc_common_pkg\\ludq_utils\\utils_tg_sso | 2 | 165 | 73 | 40 | 278 |
| cucc_common_pkg\\ludq_utils\\utils_tg_vpc | 2 | 541 | 112 | 86 | 739 |
| cucc_common_pkg\\ludq_utils\\utils_webservice | 5 | 480 | 264 | 123 | 867 |
| cucc_common_pkg\\my_datahandle | 3 | 303 | 156 | 47 | 506 |
| cucc_common_pkg\\util_pkg | 12 | 1,963 | 456 | 207 | 2,626 |
| test | 15 | 1,781 | 450 | 469 | 2,700 |
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
\ No newline at end of file
This diff is collapsed.
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
.idea/*
.idea/
.idea
*.idea/
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
.static_storage/
.media/
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
.idea/
*.iml
.vscode/
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Version: 1.0
@Python Version:3.6.6
@Author: ludq1
@Email: ludq1@chinaunicom.cn
@date: 2023/04/07 11:40:00
@Description:
"""
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Version: 1.0
@Python Version:3.6.6
@Author: ludq1
@Email: ludq1@chinaunicom.cn
@date: 2023/04/07 11:40:00
@Description:
"""
import os
from .globalconst import RedisConnConst, RedisSentinelConnConst, RedisSentinelConnEnvConst, RedisConnEnvConst, \
RedisInfoKeysConst
class CfgInfoHandle:
def __init__(self, flask_app=None):
r"""
登录处理初始化
Args:
flask_app: flask app
list_filter_url: url过滤,不需要被登录检查的 list[dict]
"""
# 初始化,处理是否接入flask
self.app = flask_app
if flask_app is not None:
self.init_app(flask_app)
@classmethod
def init_app(self, app):
r"""
初始化flask变量,走所有服务之前去验证登录
Args:
app:
Returns:
"""
pass
def get_redis_info(self, str_master_ip_port: str = None, str_slave_ip_port: str = None, str_redis_auth: str = None,
str_redis_db: str = None) -> dict:
r"""
获取redis环境信息
Args:
str_master_ip_port: redis 主节点信息
str_slave_ip_port: redis 从节点信息
str_redis_auth: redis 密码
str_redis_db: redis 库index
Returns: 返回redis连接信息
"""
env_dist = os.environ # environ是在os.py中定义的一个dict environ = {}
if str_master_ip_port is not None:
master_ip = str_master_ip_port.split(':')[0]
master_port = str_master_ip_port.split(':')[1]
else:
master_ip = env_dist.get(RedisConnEnvConst.CONN_MR_IP) if env_dist.get(
RedisConnEnvConst.CONN_MR_IP) else "csm-redis-master"
master_port = env_dist.get(RedisConnEnvConst.CONN_MR_PORT) if env_dist.get(
RedisConnEnvConst.CONN_MR_PORT) else "6379"
if str_slave_ip_port is not None:
slave_ip = str_slave_ip_port.split(':')[0]
slave_port = str_slave_ip_port.split(':')[1]
else:
slave_ip = env_dist.get(RedisConnEnvConst.CONN_SL_IP) if env_dist.get(
RedisConnEnvConst.CONN_SL_IP) else "csm-redis-slave"
slave_port = env_dist.get(RedisConnEnvConst.CONN_SL_PORT) if env_dist.get(
RedisConnEnvConst.CONN_SL_PORT) else "6379"
if str_redis_auth is not None:
redis_auth = str_redis_auth
else:
redis_auth = env_dist.get(RedisConnEnvConst.CONN_MR_AUTH) if env_dist.get(
RedisConnEnvConst.CONN_MR_AUTH) else "!@#rjyjy"
if str_redis_db is not None:
redis_index = str_redis_db
else:
redis_index = env_dist.get(RedisConnEnvConst.CONN_MR_DB) if env_dist.get(
RedisConnEnvConst.CONN_MR_DB) else "9"
master_dict_conn = {
RedisConnConst.CONN_IP: master_ip
, RedisConnConst.CONN_PORT: master_port
, RedisConnConst.CONN_AUTH: redis_auth
, RedisConnConst.CONN_DB: redis_index
}
slave_dict_conn = {
RedisConnConst.CONN_IP: slave_ip
, RedisConnConst.CONN_PORT: slave_port
, RedisConnConst.CONN_AUTH: redis_auth
, RedisConnConst.CONN_DB: redis_index
}
dict_conn = {
RedisInfoKeysConst.REDIS_MASTER_KEY: master_dict_conn
, RedisInfoKeysConst.REDIS_SLAVE_KEY: slave_dict_conn
}
return dict_conn
def get_redis_sentinel_info(self, list_sentinels: list = None, str_clustername: str = None,
str_redis_auth: str = None, str_redis_db: str = None) -> dict:
r"""
获取redis的sentinel信息
Args:
list_sentinels: 哨兵集群,内部是tuple
str_clustername: 哨兵集群名称
str_redis_auth: redis密码
str_redis_db: 当前操作的redis库
Returns:
"""
env_dist = os.environ # environ是在os.py中定义的一个dict environ = {}
if list_sentinels is not None:
sentinel_cluster_hosts = list_sentinels
else:
sentinel_cluster_hosts = env_dist.get(RedisSentinelConnEnvConst.CONN_HOSTS) if env_dist.get(
RedisSentinelConnEnvConst.CONN_HOSTS) else [('redis-sentinel', '26379')]
if str_clustername is not None:
sentinel_cluster_name = str_clustername
else:
sentinel_cluster_name = env_dist.get(RedisSentinelConnEnvConst.CONN_CLUSTERNAME) if env_dist.get(
RedisSentinelConnEnvConst.CONN_CLUSTERNAME) else "csmredis"
if str_redis_auth is not None:
redis_auth = str_redis_auth
else:
redis_auth = env_dist.get(RedisSentinelConnEnvConst.CONN_AUTH) if env_dist.get(
RedisSentinelConnEnvConst.CONN_AUTH) else "!@#rjyjy"
if str_redis_db is not None:
redis_index = str_redis_db
else:
redis_index = env_dist.get(RedisSentinelConnEnvConst.CONN_DB) if env_dist.get(
RedisSentinelConnEnvConst.CONN_DB) else "9"
dict_conn = {
RedisSentinelConnConst.CONN_HOSTS: sentinel_cluster_hosts
, RedisSentinelConnConst.CONN_CLUSTERNAME: sentinel_cluster_name
, RedisConnConst.CONN_AUTH: redis_auth
, RedisConnConst.CONN_DB: redis_index
}
return dict_conn
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Version: 1.0
@Python Version:3.6.6
@Author: ludq1
@Email: ludq1@chinaunicom.cn
@date: 2023/04/07 11:40:00
@Description:
"""
import urllib.parse
import requests
from .globalconst import GlobalConst, HttpConst, SkyGlobalConst
from .my_utils import MyUtils
from .sky_baseexception import MyBaseException, create_base_exception
from .sky_httptrans import HttpTrans
class K8sOps(object):
# 标准API
STANDARD_API = "/api"
# 标准API版本
STANDARD_API_VERSION = "/v1"
# 自定义API
CRD_API = "/apis"
# k8s的ns固定路径
K8S_NS = "/namespaces"
def __init__(self, params):
'''
Constructor
'''
def crd_cs_list_obj(self, str_k8s_ip_port: str = None, str_k8s_token: str = None, str_prefix_url: str = CRD_API,
str_crd_group_version: str = None,
str_crd_obj: str = None, dict_args: dict = None) -> dict:
'''
获取自定义集群的对象列表
Args:
str_k8s_ip_port: k8s 端口
str_k8s_token: k8s token
str_prefix_url: k8s api固定前缀路径 ,/apis
str_crd_group_version: k8s crd 组和版本 /networking.istio.io/v1alpha3
str_crd_obj: k8s crd 对象名称 /virtualservices
dict_args: 查询传递参数 {"dd":"dd"}
Returns: 返回对象字典
'''
url_args = ''
if dict_args is not None:
url_args = '?'
for tmp_k, tmp_v in dict_args.items():
if url_args == '?':
url_args = url_args + tmp_k + '=' + urllib.parse.quote(tmp_v)
else:
url_args = "&" + url_args + tmp_k + '=' + urllib.parse.quote(tmp_v)
str_url = GlobalConst.DEFAULT_URLSCHEMA_SECRUE + str_k8s_ip_port + str_prefix_url + str_crd_group_version + str_crd_obj + url_args
http_trans = HttpTrans(None)
arg_extra_dict_header = {HttpConst.HEADER_KEY_CONTENT_TYPE: HttpConst.CONTENT_TYPE_JSON
, HttpConst.AUTH_KEY: HttpConst.AUTH_BEARER_PREFIX + str_k8s_token
}
try:
m_response = http_trans.get_data(
urlstr=str_url,
trans_data=dict_args,
dict_header=arg_extra_dict_header
)
ret_dict = {}
if not m_response.ok:
raise create_base_exception(
'访问url出错,访问地址:{0},返回码{1}'.format(str_url + ":" + m_response.text, m_response.status_code)
)
else:
ret_dict[SkyGlobalConst.RETKEY_RET_CODE] = SkyGlobalConst.RETCODE_SUCESS_CODE
ret_dict[SkyGlobalConst.RETKEY_RET_VAL] = SkyGlobalConst.RETCODE_SUCESS_CODE
str_ret = m_response.text
dict_ret = MyUtils.jsonstr2json(m_response.text)
if dict_ret is None:
raise create_base_exception(
'返回的内容不是有效的json字符串:{}'.format(str_ret)
)
ret_dict[SkyGlobalConst.RETKEY_DATAROWS] = dict_ret
except requests.exceptions.RequestException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except MyBaseException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except Exception as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
return ret_dict
def crd_ns_list_obj(self, str_k8s_ip_port: str = None, str_k8s_token: str = None, str_prefix_url: str = CRD_API,
str_crd_group_version: str = None,
str_crd_ns_url: str = K8S_NS, str_crd_ns_name: str = None, str_crd_obj: str = None,
dict_args: dict = None) -> dict:
'''
获取自定义集群的对象列表
Args:
str_k8s_ip_port: k8s 端口
str_k8s_token: k8s token
str_prefix_url: k8s api固定前缀路径 ,/apis
str_crd_ns_url: k8s 命名空间固定路径 ,/namespaces
str_crd_ns_name: k8s crd 集群命名空间 ,/csm
str_crd_group_version: k8s crd 组和版本 /networking.istio.io/v1alpha3
str_crd_obj: k8s crd 对象名称 /virtualservices
dict_args: 查询传递参数 {"dd":"dd"}
Returns: 返回对象字典
'''
url_args = ''
if dict_args is not None:
url_args = '?'
for tmp_k, tmp_v in dict_args.items():
if url_args == '?':
url_args = url_args + tmp_k + '=' + urllib.parse.quote(tmp_v)
else:
url_args = "&" + url_args + tmp_k + '=' + urllib.parse.quote(tmp_v)
str_url = GlobalConst.DEFAULT_URLSCHEMA_SECRUE + str_k8s_ip_port + str_prefix_url + str_crd_group_version + str_crd_ns_url + str_crd_ns_name + str_crd_obj + url_args
http_trans = HttpTrans(None)
arg_extra_dict_header = {HttpConst.HEADER_KEY_CONTENT_TYPE: HttpConst.CONTENT_TYPE_JSON
, HttpConst.AUTH_KEY: HttpConst.AUTH_BEARER_PREFIX + str_k8s_token
}
try:
m_response = http_trans.get_data(
urlstr=str_url,
trans_data=dict_args,
dict_header=arg_extra_dict_header
)
ret_dict = {}
if not m_response.ok:
raise create_base_exception(
'访问url出错,访问地址:{0},返回码{1}'.format(str_url + ":" + m_response.text, m_response.status_code)
)
else:
ret_dict[SkyGlobalConst.RETKEY_RET_CODE] = SkyGlobalConst.RETCODE_SUCESS_CODE
ret_dict[SkyGlobalConst.RETKEY_RET_VAL] = SkyGlobalConst.RETCODE_SUCESS_CODE
str_ret = m_response.text
dict_ret = MyUtils.jsonstr2json(m_response.text)
if dict_ret is None:
raise create_base_exception(
'返回的内容不是有效的json字符串:{}'.format(str_ret)
)
ret_dict[SkyGlobalConst.RETKEY_DATAROWS] = dict_ret
except requests.exceptions.RequestException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except MyBaseException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except Exception as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
return ret_dict
def crd_ns_create_obj(self, str_k8s_ip_port: str = None, str_k8s_token: str = None, str_prefix_url: str = CRD_API,
str_crd_group_version: str = None,
str_crd_ns_url: str = K8S_NS, str_crd_ns_name: str = None, str_crd_obj: str = None,
dict_args: dict = None) -> dict:
'''
创建自定义集群的对象列表
Args:
str_k8s_ip_port: k8s 端口
str_k8s_token: k8s token
str_prefix_url: k8s api固定前缀路径 ,/apis
str_crd_ns_url: k8s 命名空间固定路径 ,/namespaces
str_crd_ns_name: k8s crd 集群命名空间 ,/csm
str_crd_group_version: k8s crd 组和版本 /networking.istio.io/v1alpha3
str_crd_obj: k8s crd 对象名称 /virtualservices
dict_args: 查询传递参数 {"dd":"dd"}
Returns: 返回对象字典
'''
str_url = GlobalConst.DEFAULT_URLSCHEMA_SECRUE + str_k8s_ip_port + str_prefix_url + str_crd_group_version + str_crd_ns_url + str_crd_ns_name + str_crd_obj
http_trans = HttpTrans(None)
arg_extra_dict_header = {HttpConst.HEADER_KEY_CONTENT_TYPE: HttpConst.CONTENT_TYPE_JSON
, HttpConst.AUTH_KEY: HttpConst.AUTH_BEARER_PREFIX + str_k8s_token
}
try:
m_response = http_trans.post_encodeddata_standard(
urlstr=str_url,
trans_data=dict_args,
dict_header=arg_extra_dict_header
)
ret_dict = {}
if not m_response.ok:
raise create_base_exception(
'访问url出错,访问地址:{0},返回码{1}'.format(str_url + ":" + m_response.text, m_response.status_code)
)
else:
ret_dict[SkyGlobalConst.RETKEY_RET_CODE] = SkyGlobalConst.RETCODE_SUCESS_CODE
ret_dict[SkyGlobalConst.RETKEY_RET_VAL] = SkyGlobalConst.RETCODE_SUCESS_CODE
str_ret = m_response.text
dict_ret = MyUtils.jsonstr2json(m_response.text)
if dict_ret is None:
raise create_base_exception(
'返回的内容不是有效的json字符串:{}'.format(str_ret)
)
ret_dict[SkyGlobalConst.RETKEY_DATAROWS] = dict_ret
except requests.exceptions.RequestException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except MyBaseException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except Exception as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
return ret_dict
def crd_ns_patch_obj(self, str_k8s_ip_port: str = None, str_k8s_token: str = None, str_prefix_url: str = CRD_API,
str_crd_group_version: str = None,
str_crd_ns_url: str = K8S_NS, str_crd_ns_name: str = None, str_crd_obj: str = None,
str_crd_obj_name: str = None,
dict_args: dict = None) -> dict:
'''
更新自定义集群的对象列表
Args:
str_k8s_ip_port: k8s 端口
str_k8s_token: k8s token
str_prefix_url: k8s api固定前缀路径 ,/apis
str_crd_ns_url: k8s 命名空间固定路径 ,/namespaces
str_crd_ns_name: k8s crd 集群命名空间 ,/csm
str_crd_group_version: k8s crd 组和版本 /networking.istio.io/v1alpha3
str_crd_obj: k8s crd 对象名称 /virtualservices
str_crd_obj_name: k8s crd 对象实例名称 /wen-gateway
dict_args: 查询传递参数 {"dd":"dd"}
Returns: 返回对象字典
'''
str_url = GlobalConst.DEFAULT_URLSCHEMA_SECRUE + str_k8s_ip_port + str_prefix_url + str_crd_group_version + str_crd_ns_url + str_crd_ns_name + str_crd_obj + str_crd_obj_name
http_trans = HttpTrans(None)
arg_extra_dict_header = {HttpConst.HEADER_KEY_CONTENT_TYPE: HttpConst.CONTENT_TYPE_PATH_JSON
, HttpConst.AUTH_KEY: HttpConst.AUTH_BEARER_PREFIX + str_k8s_token
}
try:
m_response = http_trans.patch_encodeddata_standard(
urlstr=str_url,
trans_data=dict_args,
dict_header=arg_extra_dict_header
)
ret_dict = {}
if not m_response.ok:
raise create_base_exception(
'访问url出错,访问地址:{0},返回码{1}'.format(str_url + ":" + m_response.text, m_response.status_code)
)
else:
ret_dict[SkyGlobalConst.RETKEY_RET_CODE] = SkyGlobalConst.RETCODE_SUCESS_CODE
ret_dict[SkyGlobalConst.RETKEY_RET_VAL] = SkyGlobalConst.RETCODE_SUCESS_CODE
str_ret = m_response.text
dict_ret = MyUtils.jsonstr2json(m_response.text)
if dict_ret is None:
raise create_base_exception(
'返回的内容不是有效的json字符串:{}'.format(str_ret)
)
ret_dict[SkyGlobalConst.RETKEY_DATAROWS] = dict_ret
except requests.exceptions.RequestException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except MyBaseException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except Exception as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
return ret_dict
def crd_ns_get_obj(self, str_k8s_ip_port: str = None, str_k8s_token: str = None, str_prefix_url: str = CRD_API,
str_crd_group_version: str = None,
str_crd_ns_url: str = K8S_NS, str_crd_ns_name: str = None, str_crd_obj: str = None,
str_crd_obj_name: str = None,
dict_args: dict = None) -> dict:
'''
获取自定义集群的对象信息
Args:
str_k8s_ip_port: k8s 端口
str_k8s_token: k8s token
str_prefix_url: k8s api固定前缀路径 ,/apis
str_crd_ns_url: k8s 命名空间固定路径 ,/namespaces
str_crd_ns_name: k8s crd 集群命名空间 ,/csm
str_crd_group_version: k8s crd 组和版本 /networking.istio.io/v1alpha3
str_crd_obj: k8s crd 对象名称 /virtualservices
str_crd_obj_name: k8s crd 对象实例名称 /wen-gateway
dict_args: 查询传递参数 {"dd":"dd"}
Returns: 返回对象字典
'''
str_url = GlobalConst.DEFAULT_URLSCHEMA_SECRUE + str_k8s_ip_port + str_prefix_url + str_crd_group_version + str_crd_ns_url + str_crd_ns_name + str_crd_obj + str_crd_obj_name
http_trans = HttpTrans(None)
arg_extra_dict_header = {HttpConst.HEADER_KEY_CONTENT_TYPE: HttpConst.CONTENT_TYPE_PATH_JSON
, HttpConst.AUTH_KEY: HttpConst.AUTH_BEARER_PREFIX + str_k8s_token
}
try:
m_response = http_trans.get_data(
urlstr=str_url,
trans_data=dict_args,
dict_header=arg_extra_dict_header
)
ret_dict = {}
if not m_response.ok:
raise create_base_exception(
'访问url出错,访问地址:{0},返回码{1}'.format(str_url + ":" + m_response.text, m_response.status_code)
)
else:
ret_dict[SkyGlobalConst.RETKEY_RET_CODE] = SkyGlobalConst.RETCODE_SUCESS_CODE
ret_dict[SkyGlobalConst.RETKEY_RET_VAL] = SkyGlobalConst.RETCODE_SUCESS_CODE
str_ret = m_response.text
dict_ret = MyUtils.jsonstr2dict(m_response.text)
if dict_ret is None:
raise create_base_exception(
'返回的内容不是有效的json字符串:{}'.format(str_ret)
)
ret_dict[SkyGlobalConst.RETKEY_DATAROWS] = dict_ret
except requests.exceptions.RequestException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except MyBaseException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except Exception as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
return ret_dict
def crd_ns_delete_obj(self, str_k8s_ip_port: str = None, str_k8s_token: str = None, str_prefix_url: str = CRD_API,
str_crd_group_version: str = None,
str_crd_ns_url: str = K8S_NS, str_crd_ns_name: str = None, str_crd_obj: str = None,
str_crd_obj_name: str = None,
dict_args: dict = None) -> dict:
'''
删除自定义集群的对象信息
Args:
str_k8s_ip_port: k8s 端口
str_k8s_token: k8s token
str_prefix_url: k8s api固定前缀路径 ,/apis
str_crd_ns_url: k8s 命名空间固定路径 ,/namespaces
str_crd_ns_name: k8s crd 集群命名空间 ,/csm
str_crd_group_version: k8s crd 组和版本 /networking.istio.io/v1alpha3
str_crd_obj: k8s crd 对象名称 /virtualservices
str_crd_obj_name: k8s crd 对象实例名称 /wen-gateway
dict_args: 查询传递参数 {"dd":"dd"}
Returns: 返回对象字典
'''
str_url = GlobalConst.DEFAULT_URLSCHEMA_SECRUE + str_k8s_ip_port + str_prefix_url + str_crd_group_version + str_crd_ns_url + str_crd_ns_name + str_crd_obj + str_crd_obj_name
http_trans = HttpTrans(None)
arg_extra_dict_header = {HttpConst.HEADER_KEY_CONTENT_TYPE: HttpConst.CONTENT_TYPE_PATH_JSON
, HttpConst.AUTH_KEY: HttpConst.AUTH_BEARER_PREFIX + str_k8s_token
}
try:
m_response = http_trans.delete_encodeddata_standard(
urlstr=str_url,
trans_data=dict_args,
dict_header=arg_extra_dict_header
)
ret_dict = {}
if not m_response.ok:
raise create_base_exception(
'访问url出错,访问地址:{0},返回码{1}'.format(str_url + ":" + m_response.text, m_response.status_code)
)
else:
ret_dict[SkyGlobalConst.RETKEY_RET_CODE] = SkyGlobalConst.RETCODE_SUCESS_CODE
ret_dict[SkyGlobalConst.RETKEY_RET_VAL] = SkyGlobalConst.RETCODE_SUCESS_CODE
except requests.exceptions.RequestException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except MyBaseException as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
except Exception as exception:
return MyBaseException.format_exception_to_standard_dict(exception)
return ret_dict
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Version: 1.0
@Python Version:3.6.6
@Author: ludq1
@Email: ludq1@chinaunicom.cn
@date: 2023/04/07 11:40:00
@Description:
"""
import functools
import logging
from typing import List, Union
from flask import g, current_app, Flask
from .globalconst import GlobalConst
from .globalutility import Utility
from .my_baseexception import MyBaseException
from .my_stringutils import MyStringUtils
def get_current_app() -> Flask:
r'''
获取当前current_app
Returns:
'''
return current_app._get_current_object() # pylint: disable=protected-access
def get_app_logger() -> logging.Logger:
r'''
获取 current_app 的logger
Returns:
'''
return get_current_app().logger
def gen_userinfo(global_obj=None, redis_info: dict = None, key_userinfo: str = GlobalConst.G_KEY_USERINFO):
r'''
装饰器函数, 用于获取用户基本信息,角色信息,权限列表信息等
Args:
global_obj: 存储用户信息的全局变量,默认为 Flask.g
redis_info: 获取用户信息的 redis 信息 , 默认为使用环境变量读取指定配置文件的内容
key_userinfo: 存储用户信息时使用的key
Returns:
'''
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
try:
# LONG_TODO 访问redis 获取用户信息
print(redis_info)
dict_userinfo: dict = None
setattr(global_obj, key_userinfo, dict_userinfo)
except Exception:
pass
return func(*args, **kw)
return wrapper
return decorator
def login_required(global_obj=None, key_userinfo: str = GlobalConst.G_KEY_USERINFO,
key_usersystem_in_userinfo: str = GlobalConst.G_USERINFO_KEY_USER_SYSTEM,
key_userid_in_userinfo: str = GlobalConst.G_USERINFO_KEY_USER_ID,
expected_usersystem: str = None,
retcode: str = GlobalConst.RETCODE_FOR_NOT_LOGIN,
retval: str = GlobalConst.RETVAL_FOR_NOT_LOGIN):
r'''
装饰器函数, 用户判断用户是否已经登陆
Args:
global_obj: 获取用户信息时使用的全局变量,默认为 Flask.g
key_userinfo: 获取用户信息时使用的key
key_usersystem_in_userinfo: 获取用户所属系统时使用的key
key_userid_in_userinfo: 获取用户id时使用的key
expected_usersystem: 期望的用户所属系统,默认为None, 此时用户信息中的用户系统为 None 或 default 时即匹配
retcode_for_not_login:
retval_for_not_login:
Returns:
'''
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
# 加入一个环境变量, 用于更灵活的控制
if Utility.get_env(GlobalConst.ENV_LOGIN_REQUIRED) == '1':
# 从 g 中获取用户信息, 判断用户是否已经登陆
gg_used = global_obj or g
g_userinfo: dict = getattr(gg_used, key_userinfo, None)
if g_userinfo is None or not g_userinfo:
return MyBaseException.format_to_standard_dict(ret_code=retcode, ret_val=retval)
# 判断用户信息中的用户类型是否是期望的用户
default_usersystem = 'default'
g_usersystem = g_userinfo.get(key_usersystem_in_userinfo, default_usersystem)
m_expected_usersystem = expected_usersystem or default_usersystem
if not m_expected_usersystem == g_usersystem:
return MyBaseException.format_to_standard_dict(ret_code=retcode, ret_val=retval,
submitted_msg=Utility.join_str_with_none(
'已登陆的用户所属系统(', g_usersystem, ')不是期望值(',
m_expected_usersystem, ')'))
# 获取用户id不为空,确认用户登陆
g_userid = g_userinfo.get(key_userid_in_userinfo, None)
if MyStringUtils.is_empty(g_userid):
return MyBaseException.format_to_standard_dict(ret_code=retcode, ret_val=retval,
submitted_msg=Utility.join_str_with_none(
'已登陆的用户id为空'))
return func(*args, **kw)
return wrapper
return decorator
def permission_required(permissions: Union[List[Union[List, str]], str], global_obj=None,
key_userinfo: str = GlobalConst.G_KEY_USERINFO,
key_permission_in_userinfo: str = GlobalConst.G_USERINFO_KEY_PERMISSION,
retcode: str = GlobalConst.RETCODE_FOR_NO_PERMISSION,
retval: str = GlobalConst.RETVAL_FOR_NO_PERMISSION):
r'''
装饰器函数, 用户判断用户是否具备指定权限
Args:
global_obj: 获取用户信息时使用的全局变量,默认为 Flask.g
key_userinfo: 获取用户信息时使用的key
key_permission_in_userinfo: 获取用户权限时使用的key
permissions: 需要的权限或权限列表, 如果是字符串,则直接表示需要的权限,如果是列表,则表示列表中的任意权限满足即可,如果列表中的项还是列表(子列表),则子列表中的所有项都必须得到满足才认为该子项满足,同时该子项不能为空(为空认为无效)
retcode_for_not_login:
retval_for_not_login:
Returns:
'''
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
# 加入一个环境变量, 用于更灵活的控制
if Utility.get_env(GlobalConst.ENV_PERMISSION_REQUIRED) == '1':
# 从 g 中获取用户信息, 判断用户是否是否具备指定权限
# 判断用户是否已经登陆
gg_used = global_obj or g
g_userinfo: dict = getattr(gg_used, key_userinfo, None)
if not g_userinfo:
return MyBaseException.format_to_standard_dict(ret_code=retcode,
ret_val=retval,
submitted_msg=GlobalConst.RETVAL_FOR_NOT_LOGIN)
# 获取用户权限列表
g_permissions: tuple = g_userinfo.get(key_permission_in_userinfo, None)
if not g_permissions:
return MyBaseException.format_to_standard_dict(ret_code=retcode,
ret_val=retval, submitted_msg='用户权限列表的key不存在')
bool_satisfied = False
if isinstance(permissions, str):
# 如果需求的权限是字符串
if permissions in g_permissions:
bool_satisfied = True
else:
# 如果需求的权限不是字符串,则进行迭代遍历, 有一项满足即认为是满足
for tmp_required_content in permissions:
if isinstance(tmp_required_content, str):
# 如果迭代项是字符串, 有一项满足,即认为满足
if tmp_required_content in g_permissions:
bool_satisfied = True
break
else:
# 如果迭代项不是字符串, 则进行迭代遍历, 此时必须满足所有项才认为是满足
# 同时要求的权限不能为空
if tmp_required_content:
tmp_bool_satified = True
for tmp_tmp_required_content in tmp_required_content:
if not tmp_tmp_required_content in g_permissions:
tmp_bool_satified = False
break
if tmp_bool_satified:
bool_satisfied = True
break
if not bool_satisfied:
return MyBaseException.format_to_standard_dict(ret_code=retcode,
ret_val=retval,
submitted_msg=Utility.join_str('用户缺少权限',
permissions))
return func(*args, **kw)
return wrapper
return decorator
def role_required(roleids: Union[List[str], str], global_obj=None, key_userinfo: str = GlobalConst.G_KEY_USERINFO,
key_role_in_userinfo: str = GlobalConst.G_USERINFO_KEY_USERROLE,
retcode: str = GlobalConst.RETCODE_FOR_MISS_ROLE,
retval: str = GlobalConst.RETVAL_FOR_MISS_ROLE):
r'''
装饰器函数, 用户判断用户是否具备指定角色
Args:
global_obj: 获取用户信息时使用的全局变量,默认为 Flask.g
key_userinfo: 获取用户信息时使用的key
key_role_in_userinfo: 获取用户权限时使用的key
roleids: 需要的角色或角色列表, 如果是字符串,则直接表示需要的权限,如果是列表,则表示列表中的任意权限满足即可,如果列表中的项还是列表(子列表),则子列表中的所有项都必须得到满足该子项才算作是满足,同时该子项不能为空(为空认为无效)
retcode_for_not_login:
retval_for_not_login:
Returns:
'''
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
# 加入一个环境变量, 用于更灵活的控制
if Utility.get_env(GlobalConst.ENV_ROLE_REQUIRED) == '1':
# 从 g 中获取用户信息, 判断用户是否是否具备指定角色
# 判断用户是否已经登陆
gg_used = global_obj or g
g_userinfo: dict = getattr(gg_used, key_userinfo, None)
if not g_userinfo:
return MyBaseException.format_to_standard_dict(ret_code=retcode,
ret_val=retval,
submitted_msg=GlobalConst.RETVAL_FOR_NOT_LOGIN)
# 获取用户权限列表
g_roles: tuple = g_userinfo.get(key_role_in_userinfo, None)
if not g_roles:
return MyBaseException.format_to_standard_dict(ret_code=retcode,
ret_val=retval, submitted_msg='用户角色列表的key不存在')
bool_satisfied = False
if isinstance(roleids, str):
# 如果需求的权限是字符串
if roleids in g_roles:
bool_satisfied = True
else:
# 如果需求的权限不是字符串,则进行迭代遍历, 有一项满足即认为是满足
for tmp_required_content in roleids:
if isinstance(tmp_required_content, str):
# 如果迭代项是字符串, 有一项满足,即认为满足
if tmp_required_content in g_roles:
bool_satisfied = True
break
else:
# 如果迭代项不是字符串, 则进行迭代遍历, 此时必须满足所有项才认为是满足
# 同时要求的权限不能为空
if tmp_required_content:
tmp_bool_satified = True
for tmp_tmp_required_content in tmp_required_content:
if not tmp_tmp_required_content in g_roles:
tmp_bool_satified = False
break
if tmp_bool_satified:
bool_satisfied = True
break
if not bool_satisfied:
return MyBaseException.format_to_standard_dict(ret_code=retcode,
ret_val=retval,
submitted_msg=Utility.join_str('用户缺少角色',
roleids))
return func(*args, **kw)
return wrapper
return decorator
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Version: 1.0
@Python Version:3.6.6
@Author: ludq1
@Email: ludq1@chinaunicom.cn
@date: 2023/04/07 11:40:00
@Description:
"""
class EnvNameConst:
r"""
环境变量名称常量
"""
ENV_LOGIN_REQUIRED = 'ENV_LOGIN_REQUIRED'
ENV_PERMISSION_REQUIRED = 'ENV_PERMISSION_REQUIRED'
ENV_ROLE_REQUIRED = 'ENV_ROLE_REQUIRED'
ENV_DONT_OVERRITE_USERINFO_FROM_FRANT = "DontOverrideUserInfoFromFront"
ENV_LOCAL_RUN = "LOCAL_RUN"
ENV_MYSQLPOOL_SERVICE = "MYSQLPOOL_SERVICE"
class UserInfoKeyConst:
r"""
缓存中用户信息的key
"""
G_USERINFO = 'userinfo'
PERMISSION = 'permissions'
USERROLE = 'roles'
USER_SYSTEM = 'usersystem'
TENANT_ID = 'tenantid'
USER_ID = 'userid'
USER_NAME = 'username'
DEPT_NAME_SHORT = 'dept_name'
DEPT_NAME_FULL = 'deptname'
DEPT_ID = 'dept_id'
OU_ID = 'OUID'
OU_NAME = 'OU'
EMAIL = 'email'
class GlobalReqKeyConst:
r"""
全局的Http请求key常量
"""
TRANSJSONARRAY = "transjsonarray"
TRANSSQL = "transsql"
SQL = "sql"
PROCEDURENAME = "procedurename"
CONDITIONEXEC = "conditionexec"
QUERYSTR = "querystr"
CHECKCONTENT = "checkcontent"
COLUMNNAME = "columnname"
COLUMNTYPE = "columntype"
CHECKTYPE = "checktype"
COMPAREVALUE = "comparevalue"
CHECKTIPS = "checktips"
EXECTYPE = "exectype"
EXECKEYWHENTRUE = "execkeywhensuccess"
EXECKEYWHENFALSE = "execkeywhenfalse"
COLUMNTYPE_STRING = "string"
COLUMNTYPE_INT = "int"
COLUMNTYPE_LONG = "long"
COLUMNTYPE_DOUBLE = "double"
COLUMNTYPE_DATE = "date"
CHECKTYPE_EQ = "eq"
CHECKTYPE_REGEQ = "regeq"
CHECKTYPE_NOTEQ = "noteq"
CHECKTYPE_REGNOTEQ = "regnoteq"
CHECKTYPE_GT = "gt"
CHECKTYPE_GE = "ge"
CHECKTYPE_LT = "lt"
CHECKTYPE_LE = "le"
EXECTYPE_ROLLBACK = "rollback"
EXECTYPE_COMMIT = "commit"
EXECTYPE_CONTINUE = "continue"
EXECTYPE_BRANCH = "branch"
class GlobalRetKeyConst:
r"""
全局的Http请求返回的json的key常量
"""
RET_CODE = "RetCode"
RET_VAL = "RetVal"
SUBMITTEDWEBARG = "SubmittedWebArg"
DATAROWS = "DataRows"
ROWCOUNT = "RowCount"
PAGECOUNT = "PageCount"
class SkyGlobalRetKeyConst:
r"""
天宫全局的Http请求返回的json的key常量
"""
RET_CODE = "code"
RET_VAL = "message"
SUBMITTEDWEBARG = "SubmittedWebArg"
DATAROWS = "data"
ROWCOUNT = "RowCount"
PAGECOUNT = "PageCount"
class GlobalConst:
"""
全局常量类
"""
RETKEY_RET_CODE = GlobalRetKeyConst.RET_CODE
RETKEY_RET_VAL = GlobalRetKeyConst.RET_VAL
RETKEY_SUBMITTEDWEBARG = GlobalRetKeyConst.SUBMITTEDWEBARG
RETCODE_COMMON_ERROR = "0"
RETCODE_SUCESS_CODE = "1"
RETKEY_DATAROWS = GlobalRetKeyConst.DATAROWS
RETKEY_ROWCOUNT = GlobalRetKeyConst.ROWCOUNT
RETKEY_PAGECOUNT = GlobalRetKeyConst.PAGECOUNT
RETCODE_FOR_NOT_LOGIN = '10000'
RETVAL_FOR_NOT_LOGIN = '用户未登录'
RETCODE_FOR_NO_PERMISSION = '10001'
RETVAL_FOR_NO_PERMISSION = '权限不足'
RETCODE_FOR_MISS_ROLE = '10002'
RETVAL_FOR_MISS_ROLE = '缺少角色'
G_KEY_USERINFO = UserInfoKeyConst.G_USERINFO
G_USERINFO_KEY_USER_SYSTEM = UserInfoKeyConst.USER_SYSTEM
G_USERINFO_KEY_USER_ID = UserInfoKeyConst.USER_ID
G_USERINFO_KEY_PERMISSION = UserInfoKeyConst.PERMISSION
G_USERINFO_KEY_USERROLE = UserInfoKeyConst.USERROLE
ENV_LOGIN_REQUIRED = EnvNameConst.ENV_LOGIN_REQUIRED
ENV_PERMISSION_REQUIRED = EnvNameConst.ENV_PERMISSION_REQUIRED
ENV_ROLE_REQUIRED = EnvNameConst.ENV_ROLE_REQUIRED
CHARACTERENCODING_UTF8 = "UTF-8"
DEFAULTCONFIG_CHARACTERENCODING = CHARACTERENCODING_UTF8
DEFAULTCONFIG_CONTENTTYPE = "text/html;charset=utf-8"
DEFAULT_URLSCHEMA = "http://"
DEFAULT_URLSCHEMA_SECRUE = "https://"
RUNTIMEENV_PROD = "prod"
RUNTIMEENV_UAT = "uat"
RUNTIMEENV_DEV = "dev"
class SkyGlobalConst:
"""
全局常量类
"""
RETKEY_RET_CODE = SkyGlobalRetKeyConst.RET_CODE
RETKEY_RET_VAL = SkyGlobalRetKeyConst.RET_VAL
RETKEY_SUBMITTEDWEBARG = SkyGlobalRetKeyConst.SUBMITTEDWEBARG
RETCODE_COMMON_ERROR = "ERROR"
RETCODE_SUCESS_CODE = "OK"
RETKEY_DATAROWS = SkyGlobalRetKeyConst.DATAROWS
RETKEY_ROWCOUNT = SkyGlobalRetKeyConst.ROWCOUNT
RETKEY_PAGECOUNT = SkyGlobalRetKeyConst.PAGECOUNT
RETCODE_FOR_NOT_LOGIN = '10000'
RETVAL_FOR_NOT_LOGIN = '用户未登录'
RETCODE_FOR_NO_PERMISSION = '10001'
RETVAL_FOR_NO_PERMISSION = '权限不足'
RETCODE_FOR_MISS_ROLE = '10002'
RETVAL_FOR_MISS_ROLE = '缺少角色'
G_KEY_USERINFO = UserInfoKeyConst.G_USERINFO
G_USERINFO_KEY_USER_SYSTEM = UserInfoKeyConst.USER_SYSTEM
G_USERINFO_KEY_USER_ID = UserInfoKeyConst.USER_ID
G_USERINFO_KEY_PERMISSION = UserInfoKeyConst.PERMISSION
G_USERINFO_KEY_USERROLE = UserInfoKeyConst.USERROLE
ENV_LOGIN_REQUIRED = EnvNameConst.ENV_LOGIN_REQUIRED
ENV_PERMISSION_REQUIRED = EnvNameConst.ENV_PERMISSION_REQUIRED
ENV_ROLE_REQUIRED = EnvNameConst.ENV_ROLE_REQUIRED
CHARACTERENCODING_UTF8 = "UTF-8"
DEFAULTCONFIG_CHARACTERENCODING = CHARACTERENCODING_UTF8
DEFAULTCONFIG_CONTENTTYPE = "text/html;charset=utf-8"
DEFAULT_URLSCHEMA = "http://"
DEFAULT_URLSCHEMA_SECRUE = "https://"
RUNTIMEENV_PROD = "prod"
RUNTIMEENV_UAT = "uat"
RUNTIMEENV_DEV = "dev"
class HttpConst:
"""
http 常量
"""
HEADER_KEY_REQUEST_METHOD = "Request Method"
HEADER_KEY_CONTENT_TYPE = "Content-Type"
HEADER_KEY_COOKIE = "Cookie"
REQUEST_METHOD_GET = "GET"
REQUEST_METHOD_POST = "POST"
CONTENT_TYPE_URLENCODED = "application/x-www-form-urlencoded"
CONTENT_TYPE_JSON = "application/json"
CONTENT_TYPE_PATH_JSON = "application/merge-patch+json"
AUTH_KEY = "Authorization"
AUTH_BEARER_PREFIX = "Bearer "
HEADERKEY_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"
class RedisInfoKeysConst:
"""
redis 信息格式key
"""
REDIS_MASTER_KEY = "redis_master"
REDIS_SLAVE_KEY = "redis_slave"
class RedisConnEnvConst:
"""
redis 环境变量
"""
CONN_MR_IP = "REDIS_MR_CONN_IP"
CONN_MR_PORT = "REDIS_MR_PORT"
CONN_MR_AUTH = "REDIS_MR_AUTH"
CONN_MR_DB = "REDIS_MR_DB_INDEX"
CONN_SL_IP = "REDIS_SL_CONN_IP"
CONN_SL_PORT = "REDIS_SL_PORT"
CONN_SL_AUTH = "REDIS_SL_AUTH"
CONN_SL_DB = "REDIS_SL_DB_INDEX"
class RedisConnConst:
"""
redis 常量
"""
CONN_IP = "conn_ip"
CONN_PORT = "conn_port"
CONN_AUTH = "conn_auth"
CONN_DB = "conn_db"
class RedisSentinelConnEnvConst:
"""
redis哨兵 环境变量
"""
CONN_IP = "REDIS_SENTINEL_CONN_IP"
CONN_PORT = "REDIS_SENTINEL_PORT"
CONN_AUTH = "REDIS_SENTINEL_AUTH"
CONN_DB = "REDIS_SENTINEL_DB_INDEX"
class RedisSentinelConnConst:
"""
redis 常量
"""
CONN_IP = "conn_ip"
CONN_PORT = "conn_port"
CONN_CLUSTERNAME = "conn_clustername"
CONN_HOSTS = "conn_hosts"
class RedisConst:
"""
Redis常量
"""
# 最大周期
EXPIRE_TIME = "expire_time"
class RedisDbNumConst:
"""
Redis库分布
"""
# 验证码
ID_INFO = "9"
# 登录信息
LOGIN_INFO = "10"
class DateTimeConst:
r"""
日期常量类
"""
ALL_DATEFORMAT_PATTERNS = [
'%Y/%m/%d %H:%M:%S.%f',
'%Y-%m-%d %H:%M:%S.%f',
'%Y/%m/%d %H:%M:%S',
'%Y-%m-%d %H:%M:%S',
'%Y/%m/%d',
'%Y-%m-%d',
'%Y-%m-%dT%H:%M:%SZ'
]
COMMON_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
RFC3339_DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
COMMON_DATE_FORMAT = '%Y-%m-%d'
class RegexPatternConst:
r"""
正则表达式常量类
"""
URL_PATTERN = '^(https?):\\/\\/([\\w-]+(\\.[\\w-]+)*\\/?)+(\\?([\\w\\-\\.,@?^=%&:\\/~\\+#]*)+)?$'
class FlaskConfigIDConst:
r"""
flask 全局config id
"""
# InitFlaskInfo 在flask配置信息的唯一标识ID
FLASK_INIT = "chinaunicom.flask.init."
# 初始化信息
INIT_CONFIG_ID = FLASK_INIT + "cfg.handle.id"
# redis 类 id
REDIS_CLASS_ID = FLASK_INIT + "redis.handle.id"
class CookiesConstKey:
r"""
业务需要用的关键的key
"""
# CSM登录标识
LOGIN_SESSTION_KEY = "CSMSESSTIONID"
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Version: 1.0
@Python Version:3.6.6
@Author: ludq1
@Email: ludq1@chinaunicom.cn
@date: 2023/04/07 11:40:00
@Description:
"""
class HttpError:
"""
http错误信息
"""
ENV_LOGIN_REQUIRED = 'ENV_LOGIN_REQUIRED'
ENV_PERMISSION_REQUIRED = 'ENV_PERMISSION_REQUIRED'
ENV_ROLE_REQUIRED = 'ENV_ROLE_REQUIRED'
ENV_DONT_OVERRITE_USERINFO_FROM_FRANT = "DontOverrideUserInfoFromFront"
ENV_LOCAL_RUN = "LOCAL_RUN"
ENV_MYSQLPOOL_SERVICE = "MYSQLPOOL_SERVICE"
class RedisError:
"""
redis错误信息
"""
ERROR_INIT_CONN = '缺少初始化连接参数'
ERROR_LACK_CONN_PARM = '缺少连接参数'
ERROR_AUTH = '密码错误'
ERROR_CONN = '连接异常'
ERROR_CONN_POOL_NONE = '连接池为空'
ERROR_SENTI_MASTER_NOT_FOUND = '主节点未找到'
ERROR_SENTI_SLAVE_NOT_FOUND = '从节点未找到'
ERROR_INSERT_VALUE_TYPE = '插入值非字符串'
class CommonError:
"""
常用错误
"""
ERROR_LACK_PARM = '缺少参数'
ERROR_USER_UNLOGIN = '用户未登录,请先登录'
This diff is collapsed.
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Version: 1.0
@Python Version:3.6.6
@Author: ludq1
@Email: ludq1@chinaunicom.cn
@date: 2023/04/07 11:40:00
@Description:
"""
import json
import re
import requests
from .globalconst import HttpConst
from .my_baseexception import MyBaseException, create_base_exception
from .my_stringutils import MyStringUtils
from .my_utils import MyUtils
class HttpTrans:
"""
http传输处理
"""
# 定义要透传的header_key
_header_key = [
'Cookie'
, 'x-request-id'
, 'x-b3-traceid'
, 'x-b3-spanid'
, 'x-b3-parentspanid'
, 'x-b3-sampled'
, 'x-b3-flags'
, 'x-ot-span-context'
]
def __init__(self, http_header: dict = None):
r"""
Args:
http_header: dict http的请求头
"""
if http_header is not None:
try:
# 尝试将 http_header 转成 dict 并赋值
self._header = dict(http_header)
except:
raise ValueError('http_header 不能转换为字典')
else:
self._header = None
def generate_header(self, content_type: str = None,
dict_header: dict = None) -> dict:
"""
生成http头信息
Args:
content_type: string 传输类型
dict_header: dict 额外头信息
Returns: dict
"""
# 检查参数
if not (dict_header is None or isinstance(dict_header, dict)):
raise ValueError('dict_header 不是字典')
ret_header = {}
# 加入需要透传的 self._header
if self._header:
# 转换为标准的字符串kv字典
formatted_dict = MyUtils.format_dict_to_str_dict(self._header)
# 过滤出指定的key
filtered_keys = filter(lambda tmp_k: tmp_k in self._header_key, formatted_dict.keys())
# 生成过滤后的字典
filtered_dict = {tmp_k: formatted_dict.get(tmp_k) for tmp_k in filtered_keys}
# 更新 ret_dict
ret_header.update(filtered_dict)
# 设置参数默认值-- str_content_type
if not MyStringUtils.is_empty(content_type):
str_content_type = str(content_type)
else:
str_content_type = HttpConst.CONTENT_TYPE_URLENCODED
# 更新 ret_dict
ret_header.update({
HttpConst.HEADER_KEY_CONTENT_TYPE: str_content_type
})
# 加入额外的HEADER KEY
if dict_header:
formatted_dict = MyUtils.format_dict_to_str_dict(dict_header)
# 更新 ret_dict
ret_header.update(formatted_dict)
# 移除 Request Method 这个key,因为该key存在会造成requests请求失效
ret_header.pop(HttpConst.HEADER_KEY_REQUEST_METHOD, None)
return ret_header
def get_data(self, urlstr: str, trans_data: dict = None, dict_header: dict = None) -> requests.Response:
"""
post 传输数据
Args:
urlstr:
trans_data: 要附加到 urlstr 上的 key-value 字典 , kv 会自动编码
dict_header: 传输时使用的header
Returns:
"""
# 检查参数
if not (trans_data is None or isinstance(trans_data, dict)):
raise ValueError('trans_data 不是字典')
if trans_data:
trans_data = MyUtils.format_dict_to_str_dict(trans_data)
headers = self.generate_header(
content_type=HttpConst.CONTENT_TYPE_URLENCODED,
dict_header=dict_header
)
cookies = None
if HttpConst.HEADER_KEY_COOKIE in headers:
cookies = headers.get(HttpConst.HEADER_KEY_COOKIE)
return requests.get(url=urlstr, headers=headers, params=trans_data, cookies=cookies)
def post_encodeddata_standard(self, urlstr: str, trans_data: dict = None,
dict_header: dict = None) -> requests.Response:
"""
post 传输数据,返回 Response对象
Args:
urlstr: string httpurl
trans_data: 传输的内容 ,字典 , kv会自动编码
dict_header: 传输时使用的header
Returns:
"""
if not (trans_data is None or isinstance(trans_data, dict)):
raise ValueError('trans_data 不是字典')
trans_data_tmp = None
content_type = HttpConst.CONTENT_TYPE_URLENCODED
if dict_header is not None and HttpConst.HEADER_KEY_CONTENT_TYPE in dict_header.keys():
content_type = dict_header.get(HttpConst.HEADER_KEY_CONTENT_TYPE)
if HttpConst.CONTENT_TYPE_JSON == dict_header.get(HttpConst.HEADER_KEY_CONTENT_TYPE):
trans_data_tmp = json.dumps(trans_data)
if trans_data_tmp is None:
trans_data_tmp = MyUtils.format_dict_to_str_dict(trans_data)
headers = self.generate_header(
content_type=content_type,
dict_header=dict_header
)
regexp = (r'^https://')
match = re.search(regexp, urlstr.strip(), re.U)
if (match is not None):
return requests.post(url=urlstr, headers=headers, data=trans_data_tmp, verify=False)
else:
return requests.post(url=urlstr, headers=headers, data=trans_data_tmp)
def post_encodedata(self, urlstr: str,
trans_data: dict = None,
dict_header: dict = None,
**dict_arg) -> str:
"""
post 传输数据,返回rensponse内容字符串,传输异常时返回 标准错误的json字符串,所以该方法适用于标准的传输
Args:
urlstr: string httpurl
trans_data: 传输的内容 , 字典,kv会自动编码
dict_header: 传输时使用的header
**dict_arg: 额外参数
Returns: 标准格式的 json字符串
"""
# 以后额外扩展
# if dict_arg:
# pass
try:
m_response = self.post_encodeddata_standard(
urlstr=urlstr,
trans_data=trans_data,
dict_header=dict_header
)
if not m_response.ok:
raise create_base_exception(
'访问url出错,访问地址:{0},返回码{1}'.format(urlstr, m_response.status_code)
)
else:
str_ret = m_response.text
# 检查返回结果是不是有效的 jsonstr
dict_ret = MyUtils.jsonstr2dict(str_ret)
if dict_ret is None:
raise create_base_exception(
'返回的内容不是有效的json字符串:{}'.format(str_ret)
)
return str_ret
except requests.exceptions.RequestException as exception:
return MyUtils.dict2jsonstr(MyBaseException.format_exception_to_standard_dict(exception))
except MyBaseException as exception:
return MyUtils.dict2jsonstr(MyBaseException.format_exception_to_standard_dict(exception))
except Exception as exception:
return MyUtils.dict2jsonstr(MyBaseException.format_exception_to_standard_dict(exception))
def patch_encodeddata_standard(self, urlstr: str, trans_data: dict = None,
dict_header: dict = None) -> requests.Response:
"""
patch 传输数据,返回 Response对象
Args:
urlstr: string httpurl
trans_data: 传输的内容 ,字典 , kv会自动编码
dict_header: 传输时使用的header
Returns:
"""
if not (trans_data is None or isinstance(trans_data, dict)):
raise ValueError('trans_data 不是字典')
trans_data_tmp = None
content_type = HttpConst.CONTENT_TYPE_PATH_JSON
if dict_header is not None and HttpConst.HEADER_KEY_CONTENT_TYPE in dict_header.keys():
content_type = dict_header.get(HttpConst.HEADER_KEY_CONTENT_TYPE)
if HttpConst.CONTENT_TYPE_PATH_JSON == dict_header.get(HttpConst.HEADER_KEY_CONTENT_TYPE):
trans_data_tmp = json.dumps(trans_data)
if trans_data_tmp is None:
trans_data_tmp = MyUtils.format_dict_to_str_dict(trans_data)
headers = self.generate_header(
content_type=content_type,
dict_header=dict_header
)
return requests.patch(url=urlstr, headers=headers, data=trans_data_tmp)
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Version: 1.0
@Python Version:3.6.6
@Author: ludq1
@Email: ludq1@chinaunicom.cn
@date: 2023/04/07 11:40:00
@Description:
"""
from flask import current_app
from .cfginfohandle import CfgInfoHandle
from .globalconst import FlaskConfigIDConst
from .redishanlde import RedisHandle
class InitFlaskHandle:
def __init__(self, flask_app=None):
r"""
登录处理初始化
Args:
flask_app: flask app
list_filter_url: url过滤,不需要被登录检查的 list[dict]
"""
# 初始化,处理是否接入flask
self.app = flask_app
if flask_app is not None:
self.init_app(flask_app)
def init_app(self, app):
r"""
初始化flask变量,走所有服务之前去验证登录
Args:
app: flask全局的app
Returns:
"""
with app.app_context():
# 初始化需要的环境信息
cfgh = CfgInfoHandle()
current_app.config[FlaskConfigIDConst.INIT_CONFIG_ID] = cfgh
# 初始化redis实例信息
rh = RedisHandle()
current_app.config[FlaskConfigIDConst.REDIS_CLASS_ID] = rh
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment