atk-common 1.9.0__tar.gz → 1.11.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.9.0 → atk_common-1.11.0}/PKG-INFO +1 -1
- {atk_common-1.9.0 → atk_common-1.11.0}/setup.py +1 -1
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/__init__.py +8 -5
- atk_common-1.11.0/src/atk_common/enums/__init__.py +12 -0
- atk_common-1.11.0/src/atk_common/enums/api_error_type_enum.py +5 -0
- atk_common-1.11.0/src/atk_common/enums/response_status_enum.py +6 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/error_utils.py +8 -5
- atk_common-1.11.0/src/atk_common/http_utils.py +21 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/log_utils.py +2 -1
- atk_common-1.11.0/src/atk_common/mq_utils.py +0 -0
- atk_common-1.11.0/src/atk_common/response_utils.py +11 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common.egg-info/PKG-INFO +1 -1
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common.egg-info/SOURCES.txt +4 -0
- atk_common-1.11.0/src/shared_python_atk_enforcement/__init__.py +0 -0
- atk_common-1.9.0/src/atk_common/enums/__init__.py +0 -8
- atk_common-1.9.0/src/atk_common/http_utils.py +0 -33
- atk_common-1.9.0/src/atk_common/response_utils.py +0 -6
- {atk_common-1.9.0 → atk_common-1.11.0}/README.md +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/license.txt +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/pyproject.toml +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/setup.cfg +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/datetime_utils.py +0 -0
- /atk_common-1.9.0/src/shared_python_atk_enforcement/__init__.py → /atk_common-1.11.0/src/atk_common/db_utils.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/docker_utils.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/enums/command_status_enum.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/enums/speed_control_status_enum.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/env_utils.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common/rabbitmq_consumer.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common.egg-info/dependency_links.txt +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common.egg-info/requires.txt +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/src/atk_common.egg-info/top_level.txt +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/tests/test_docker_utils.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/tests/test_error_utils.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.0}/tests/test_http_utils.py +0 -0
- {atk_common-1.9.0 → atk_common-1.11.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.11.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
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# __init__.py
|
2
2
|
from atk_common.datetime_utils import date_time_utc, get_utc_date_time
|
3
3
|
from atk_common.env_utils import get_env_value
|
4
|
-
from atk_common.error_utils import get_message, get_error_entity, handle_error, get_response_error, get_error_type
|
5
|
-
from atk_common.http_utils import
|
4
|
+
from atk_common.error_utils import get_message, create_error_log, get_error_entity, handle_error, get_response_error, get_error_type
|
5
|
+
from atk_common.http_utils import is_http_status_ok, is_http_status_internal, get_test_response
|
6
6
|
from atk_common.log_utils import add_log_item, add_log_item_http
|
7
7
|
from atk_common.rabbitmq_consumer import RabbitMQConsumer
|
8
|
-
from atk_common.response_utils import
|
8
|
+
from atk_common.response_utils import create_response, is_response_ok
|
9
9
|
from atk_common.docker_utils import get_current_container_info
|
10
10
|
|
11
11
|
__all__ = [
|
@@ -13,15 +13,18 @@ __all__ = [
|
|
13
13
|
'get_utc_date_time',
|
14
14
|
'get_env_value',
|
15
15
|
'get_message',
|
16
|
+
'create_error_log',
|
16
17
|
'get_error_entity',
|
17
18
|
'handle_error',
|
18
19
|
'get_response_error',
|
19
20
|
'get_error_type',
|
20
|
-
'
|
21
|
+
'is_http_status_ok',
|
22
|
+
'is_http_status_internal',
|
21
23
|
'get_test_response',
|
22
24
|
'add_log_item',
|
23
25
|
'add_log_item_http',
|
24
26
|
'RabbitMQConsumer',
|
25
|
-
'
|
27
|
+
'create_response',
|
28
|
+
'is_response_ok',
|
26
29
|
'get_current_container_info',
|
27
30
|
]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# __init__.py
|
2
|
+
from atk_common.enums.command_status_enum import CommandStatusType
|
3
|
+
from atk_common.enums.speed_control_status_enum import SpeedControlStatusType
|
4
|
+
from atk_common.enums.api_error_type_enum import ApiErrorType
|
5
|
+
from atk_common.enums.response_status_enum import ResponseStatus
|
6
|
+
|
7
|
+
__all__ = [
|
8
|
+
'CommandStatusType',
|
9
|
+
'SpeedControlStatusType',
|
10
|
+
'ApiErrorType',
|
11
|
+
'ResponseStatus',
|
12
|
+
]
|
@@ -1,6 +1,9 @@
|
|
1
|
+
from http import HTTPStatus
|
1
2
|
from datetime import datetime
|
2
3
|
import json
|
3
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.http_utils import is_http_status_internal
|
4
7
|
from atk_common.log_utils import add_log_item
|
5
8
|
from atk_common.response_utils import create_save_resp
|
6
9
|
|
@@ -35,13 +38,13 @@ def get_error_entity(app, error, method, error_type, status_code, container_info
|
|
35
38
|
if app is not None:
|
36
39
|
return app.response_class(
|
37
40
|
response=json.dumps(data),
|
38
|
-
status=
|
41
|
+
status=HTTPStatus.INTERNAL_SERVER_ERROR,
|
39
42
|
mimetype='application/json'
|
40
43
|
)
|
41
44
|
return None
|
42
45
|
|
43
46
|
def handle_error(resp, status):
|
44
|
-
if resp.status_code
|
47
|
+
if is_http_status_internal(resp.status_code):
|
45
48
|
add_log_item(resp.json().get('message'))
|
46
49
|
return create_save_resp(status, resp.status_code, resp.json())
|
47
50
|
else:
|
@@ -49,7 +52,7 @@ def handle_error(resp, status):
|
|
49
52
|
return create_save_resp(status, resp.status_code, resp.text)
|
50
53
|
|
51
54
|
def get_response_error(resp):
|
52
|
-
if resp.status_code
|
55
|
+
if is_http_status_internal(resp.status_code):
|
53
56
|
return resp.json()
|
54
57
|
else:
|
55
58
|
return resp.text
|
@@ -59,5 +62,5 @@ def get_response_error(resp):
|
|
59
62
|
# 2 - Internal error
|
60
63
|
def get_error_type(conn):
|
61
64
|
if conn is None:
|
62
|
-
return
|
63
|
-
return
|
65
|
+
return ApiErrorType.CONNECTION
|
66
|
+
return ApiErrorType.INTERNAL
|
@@ -0,0 +1,21 @@
|
|
1
|
+
from http import HTTPStatus
|
2
|
+
import json
|
3
|
+
from atk_common.datetime_utils import get_utc_date_time
|
4
|
+
from atk_common.docker_utils import get_current_container_info
|
5
|
+
from atk_common.env_utils import get_env_value
|
6
|
+
|
7
|
+
def is_http_status_ok(status_code):
|
8
|
+
return status_code >= HTTPStatus.OK.value and status_code < HTTPStatus.MULTIPLE_CHOICES.value
|
9
|
+
|
10
|
+
def is_http_status_internal(status_code):
|
11
|
+
return status_code >= HTTPStatus.INTERNAL_SERVER_ERROR.value
|
12
|
+
|
13
|
+
def get_test_response(docker_container_data, component):
|
14
|
+
data = {}
|
15
|
+
data['utcDateTime'] = get_utc_date_time()
|
16
|
+
if docker_container_data is None:
|
17
|
+
data['containerData'] = None
|
18
|
+
data['component'] = component
|
19
|
+
else:
|
20
|
+
data['containerData'] = docker_container_data
|
21
|
+
return data
|
@@ -1,4 +1,5 @@
|
|
1
1
|
from atk_common.datetime_utils import get_utc_date_time
|
2
|
+
from atk_common.http_utils import is_http_status_internal
|
2
3
|
|
3
4
|
def create_date_time():
|
4
5
|
date_time = get_utc_date_time()
|
@@ -8,7 +9,7 @@ def add_log_item(text):
|
|
8
9
|
print(create_date_time() + text)
|
9
10
|
|
10
11
|
def add_log_item_http(resp):
|
11
|
-
if resp.status_code
|
12
|
+
if is_http_status_internal(resp.status_code):
|
12
13
|
err_resp_json = resp.json().get('message')
|
13
14
|
add_log_item(err_resp_json)
|
14
15
|
else:
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from atk_common.enums.response_status_enum import ResponseStatus
|
2
|
+
|
3
|
+
def create_response(status, status_code, response_msg):
|
4
|
+
data = {}
|
5
|
+
data['status'] = status
|
6
|
+
data['statusCode'] = status_code
|
7
|
+
data['responseMsg'] = response_msg
|
8
|
+
return data
|
9
|
+
|
10
|
+
def is_response_ok(response):
|
11
|
+
return response['status'] == ResponseStatus.OK
|
@@ -5,11 +5,13 @@ setup.cfg
|
|
5
5
|
setup.py
|
6
6
|
src/atk_common/__init__.py
|
7
7
|
src/atk_common/datetime_utils.py
|
8
|
+
src/atk_common/db_utils.py
|
8
9
|
src/atk_common/docker_utils.py
|
9
10
|
src/atk_common/env_utils.py
|
10
11
|
src/atk_common/error_utils.py
|
11
12
|
src/atk_common/http_utils.py
|
12
13
|
src/atk_common/log_utils.py
|
14
|
+
src/atk_common/mq_utils.py
|
13
15
|
src/atk_common/rabbitmq_consumer.py
|
14
16
|
src/atk_common/response_utils.py
|
15
17
|
src/atk_common.egg-info/PKG-INFO
|
@@ -18,7 +20,9 @@ src/atk_common.egg-info/dependency_links.txt
|
|
18
20
|
src/atk_common.egg-info/requires.txt
|
19
21
|
src/atk_common.egg-info/top_level.txt
|
20
22
|
src/atk_common/enums/__init__.py
|
23
|
+
src/atk_common/enums/api_error_type_enum.py
|
21
24
|
src/atk_common/enums/command_status_enum.py
|
25
|
+
src/atk_common/enums/response_status_enum.py
|
22
26
|
src/atk_common/enums/speed_control_status_enum.py
|
23
27
|
src/shared_python_atk_enforcement/__init__.py
|
24
28
|
tests/test_docker_utils.py
|
File without changes
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
from atk_common.datetime_utils import get_utc_date_time
|
3
|
-
from atk_common.docker_utils import get_current_container_info
|
4
|
-
from atk_common.env_utils import get_env_value
|
5
|
-
|
6
|
-
def is_status_code_ok(status_code):
|
7
|
-
return status_code >= 200 and status_code < 300
|
8
|
-
|
9
|
-
def get_test_response():
|
10
|
-
data = {}
|
11
|
-
container_info = get_current_container_info()
|
12
|
-
if container_info is not None:
|
13
|
-
data['imageName'] = container_info['imageName']
|
14
|
-
data['imageVersion'] = container_info['imageVersion']
|
15
|
-
data['containerName'] = container_info['containerName']
|
16
|
-
data['containerPorts'] = container_info['ports']
|
17
|
-
else:
|
18
|
-
data['imageName'] = None
|
19
|
-
data['imageVersion'] = None
|
20
|
-
data['containerName'] = None
|
21
|
-
data['containerPorts'] = None
|
22
|
-
data['timestamp'] = get_utc_date_time()
|
23
|
-
return data
|
24
|
-
|
25
|
-
def get_test_response(docker_container_data, component):
|
26
|
-
data = {}
|
27
|
-
data['utcDateTime'] = get_utc_date_time()
|
28
|
-
if docker_container_data is None:
|
29
|
-
data['containerData'] = None
|
30
|
-
data['component'] = component
|
31
|
-
else:
|
32
|
-
data['containerData'] = docker_container_data
|
33
|
-
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
|