atk-common 1.35.0__tar.gz → 1.37.0__tar.gz
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.
- {atk_common-1.35.0 → atk_common-1.37.0}/PKG-INFO +1 -1
- {atk_common-1.35.0 → atk_common-1.37.0}/setup.py +1 -1
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/__init__.py +4 -2
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/error_utils.py +8 -0
- atk_common-1.37.0/src/atk_common/http_utils.py +42 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common.egg-info/PKG-INFO +1 -1
- atk_common-1.35.0/src/atk_common/http_utils.py +0 -18
- {atk_common-1.35.0 → atk_common-1.37.0}/README.md +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/license.txt +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/pyproject.toml +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/setup.cfg +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/datetime_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/db_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/docker_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/__init__.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/api_error_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/camera_cabinet_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/camera_role_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/certificate_issuer_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/command_status_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/command_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/detection_status_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/encryption_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/file_exists_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/history_status_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/image_encoding_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/image_part_category_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/image_part_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/metering_direction_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/piezo_vehicle_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/process_status_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/response_status_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/section_role_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/sensor_order_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/sensor_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/speed_control_status_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/violation_type_enum.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/env_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/file_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/log_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/mq_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/rabbitmq_consumer.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/response_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common.egg-info/SOURCES.txt +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common.egg-info/dependency_links.txt +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common.egg-info/requires.txt +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common.egg-info/top_level.txt +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/src/shared_python_atk_enforcement/__init__.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/tests/test_docker_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/tests/test_error_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/tests/test_http_utils.py +0 -0
- {atk_common-1.35.0 → atk_common-1.37.0}/tests/test_log_utils.py +0 -0
@@ -36,7 +36,7 @@ setup(
|
|
36
36
|
# For a discussion on single-sourcing the version across setup.py and the
|
37
37
|
# project code, see
|
38
38
|
# https://packaging.python.org/guides/single-sourcing-package-version/
|
39
|
-
version="1.
|
39
|
+
version="1.37.0", # Required
|
40
40
|
# This is a one-line description or tagline of what your project does. This
|
41
41
|
# corresponds to the "Summary" metadata field:
|
42
42
|
# https://packaging.python.org/specifications/core-metadata/#summary
|
@@ -3,8 +3,8 @@ from atk_common.datetime_utils import get_utc_date_time, seconds_to_utc_timestam
|
|
3
3
|
from atk_common.db_utils import sql, sql_with_record, convert_none_to_null, date_time_utc_column
|
4
4
|
from atk_common.docker_utils import get_current_container_info
|
5
5
|
from atk_common.env_utils import get_env_value
|
6
|
-
from atk_common.error_utils import get_message, create_error_log, get_error_entity, handle_error, get_response_error, get_error_type
|
7
|
-
from atk_common.http_utils import is_http_status_ok, is_http_status_internal, get_test_response
|
6
|
+
from atk_common.error_utils import get_message, create_error_log, get_error_entity, resend_error_entity, handle_error, get_response_error, get_error_type
|
7
|
+
from atk_common.http_utils import is_http_status_ok, is_http_status_internal, get_test_response, create_http_response
|
8
8
|
from atk_common.file_utils import get_image_file_type
|
9
9
|
from atk_common.log_utils import add_log_item, add_log_item_http
|
10
10
|
from atk_common.rabbitmq_consumer import RabbitMQConsumer
|
@@ -24,12 +24,14 @@ __all__ = [
|
|
24
24
|
'get_message',
|
25
25
|
'create_error_log',
|
26
26
|
'get_error_entity',
|
27
|
+
'resend_error_entity',
|
27
28
|
'handle_error',
|
28
29
|
'get_response_error',
|
29
30
|
'get_error_type',
|
30
31
|
'is_http_status_ok',
|
31
32
|
'is_http_status_internal',
|
32
33
|
'get_test_response',
|
34
|
+
'create_http_response',
|
33
35
|
'get_image_file_type',
|
34
36
|
'add_log_item',
|
35
37
|
'add_log_item_http',
|
@@ -43,6 +43,14 @@ def get_error_entity(error, method, error_type, status_code, container_info):
|
|
43
43
|
mimetype='application/json'
|
44
44
|
)
|
45
45
|
|
46
|
+
def resend_error_entity(error_entity):
|
47
|
+
create_error_log(error_entity)
|
48
|
+
return Response(
|
49
|
+
response=json.dumps(error_entity),
|
50
|
+
status=HTTPStatus.INTERNAL_SERVER_ERROR,
|
51
|
+
mimetype='application/json'
|
52
|
+
)
|
53
|
+
|
46
54
|
def handle_error(resp, status):
|
47
55
|
if is_http_status_internal(resp.status_code):
|
48
56
|
add_log_item(resp.json().get('message'))
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from flask import Response
|
2
|
+
import json
|
3
|
+
from http import HTTPStatus
|
4
|
+
from atk_common.datetime_utils import get_utc_date_time
|
5
|
+
from atk_common.enums.api_error_type_enum import ApiErrorType
|
6
|
+
from atk_common.error_utils import get_error_entity, resend_error_entity
|
7
|
+
from atk_common.response_utils import is_response_http
|
8
|
+
|
9
|
+
def is_http_status_ok(status_code):
|
10
|
+
return status_code >= HTTPStatus.OK.value and status_code < HTTPStatus.MULTIPLE_CHOICES.value
|
11
|
+
|
12
|
+
def is_http_status_internal(status_code):
|
13
|
+
return status_code >= HTTPStatus.INTERNAL_SERVER_ERROR.value
|
14
|
+
|
15
|
+
def get_test_response(docker_container_data, component):
|
16
|
+
data = {}
|
17
|
+
data['utcDateTime'] = get_utc_date_time()
|
18
|
+
if docker_container_data is None:
|
19
|
+
data['containerData'] = None
|
20
|
+
data['component'] = component
|
21
|
+
else:
|
22
|
+
data['containerData'] = docker_container_data
|
23
|
+
return data
|
24
|
+
|
25
|
+
# If response['status'] == 0 (OK, http status = 200): create Response and return response['responseMsg']
|
26
|
+
# If http status == 500:
|
27
|
+
# If response['status'] == 1 (HTTP): resend received error entity
|
28
|
+
# If response['status'] == 2 (INTERNAL): create new error entity and return as response
|
29
|
+
# If http status other value: create new error entity and return as response
|
30
|
+
def create_http_response(method, response, container_info):
|
31
|
+
if is_http_status_ok(response['statusCode']):
|
32
|
+
return Response(
|
33
|
+
response=json.dumps(response['responseMsg']),
|
34
|
+
status=HTTPStatus.OK,
|
35
|
+
mimetype='application/json'
|
36
|
+
)
|
37
|
+
if is_http_status_internal(response['statusCode']):
|
38
|
+
if is_response_http(response):
|
39
|
+
resend_error_entity(response['responseMsg'])
|
40
|
+
return get_error_entity(response['responseMsg'], method, ApiErrorType.INTERNAL, response['statusCode'], container_info)
|
41
|
+
return get_error_entity(response['responseMsg'], method, ApiErrorType.CONNECTION, response['statusCode'], container_info)
|
42
|
+
|
@@ -1,18 +0,0 @@
|
|
1
|
-
from http import HTTPStatus
|
2
|
-
from atk_common.datetime_utils import get_utc_date_time
|
3
|
-
|
4
|
-
def is_http_status_ok(status_code):
|
5
|
-
return status_code >= HTTPStatus.OK.value and status_code < HTTPStatus.MULTIPLE_CHOICES.value
|
6
|
-
|
7
|
-
def is_http_status_internal(status_code):
|
8
|
-
return status_code >= HTTPStatus.INTERNAL_SERVER_ERROR.value
|
9
|
-
|
10
|
-
def get_test_response(docker_container_data, component):
|
11
|
-
data = {}
|
12
|
-
data['utcDateTime'] = get_utc_date_time()
|
13
|
-
if docker_container_data is None:
|
14
|
-
data['containerData'] = None
|
15
|
-
data['component'] = component
|
16
|
-
else:
|
17
|
-
data['containerData'] = docker_container_data
|
18
|
-
return data
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{atk_common-1.35.0 → atk_common-1.37.0}/src/atk_common/enums/speed_control_status_type_enum.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|