atk-common 1.51.0__py3-none-any.whl → 1.53.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atk_common/datetime_utils.py +41 -0
- atk_common/http_response_utils.py +13 -2
- {atk_common-1.51.0.dist-info → atk_common-1.53.0.dist-info}/METADATA +1 -1
- {atk_common-1.51.0.dist-info → atk_common-1.53.0.dist-info}/RECORD +7 -7
- {atk_common-1.51.0.dist-info → atk_common-1.53.0.dist-info}/WHEEL +0 -0
- {atk_common-1.51.0.dist-info → atk_common-1.53.0.dist-info}/licenses/license.txt +0 -0
- {atk_common-1.51.0.dist-info → atk_common-1.53.0.dist-info}/top_level.txt +0 -0
atk_common/datetime_utils.py
CHANGED
@@ -60,3 +60,44 @@ def convert_to_utc(dt_str):
|
|
60
60
|
# Convert to UTC
|
61
61
|
dt_utc =dt_with_tz.astimezone(timezone.utc)
|
62
62
|
return dt_utc.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
63
|
+
|
64
|
+
# Original datetime string, handles:
|
65
|
+
# dt_str = '2023-02-01 14:13:08.653133 +01:00'
|
66
|
+
def convert_to_utc_image_dt(dt_str):
|
67
|
+
dt_str = dt_str.strip()
|
68
|
+
# Detect offset
|
69
|
+
if '+' in dt_str:
|
70
|
+
parts = dt_str.split('+')
|
71
|
+
sign = '+'
|
72
|
+
elif '-' in dt_str[10:]: # avoid confusion with date part
|
73
|
+
parts = dt_str.split('-')
|
74
|
+
sign = '-'
|
75
|
+
else:
|
76
|
+
parts = [dt_str]
|
77
|
+
sign = None
|
78
|
+
|
79
|
+
if len(parts) == 2:
|
80
|
+
dt_part = parts[0].strip()
|
81
|
+
offset_part = parts[1].strip()
|
82
|
+
if sign == '-':
|
83
|
+
offset_part = '-' + offset_part
|
84
|
+
else:
|
85
|
+
offset_part = '+' + offset_part
|
86
|
+
else:
|
87
|
+
dt_part = parts[0].strip()
|
88
|
+
offset_part = None
|
89
|
+
|
90
|
+
dt_part = adjust_millisescond(dt_part)
|
91
|
+
dt_naive = datetime.fromisoformat(dt_part)
|
92
|
+
|
93
|
+
if offset_part is None:
|
94
|
+
dt_aware = dt_naive.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
95
|
+
dt_utc = dt_aware.astimezone(ZoneInfo("UTC"))
|
96
|
+
else:
|
97
|
+
offset_hours, offset_minutes = map(int, offset_part.split(':'))
|
98
|
+
delta = timedelta(hours=offset_hours, minutes=offset_minutes)
|
99
|
+
tz = timezone(delta)
|
100
|
+
dt_aware = dt_naive.replace(tzinfo=tz)
|
101
|
+
dt_utc = dt_aware.astimezone(timezone.utc)
|
102
|
+
|
103
|
+
return dt_utc.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
@@ -6,6 +6,17 @@ from atk_common.error_utils import get_error_entity, resend_error_entity
|
|
6
6
|
from atk_common.http_utils import is_http_status_internal, is_http_status_ok
|
7
7
|
from atk_common.internal_response_utils import is_response_http
|
8
8
|
|
9
|
+
def convert_response_data(data):
|
10
|
+
if isinstance(data, dict):
|
11
|
+
return json.dumps(data)
|
12
|
+
elif isinstance(data, list):
|
13
|
+
return json.dumps(data)
|
14
|
+
elif isinstance(data, str):
|
15
|
+
json_data = json.loads(data)
|
16
|
+
return json.dumps(json_data)
|
17
|
+
else:
|
18
|
+
return data
|
19
|
+
|
9
20
|
# If response['status'] == 0 (OK, http status = 200): create Response and return response['responseMsg']
|
10
21
|
# If http status == 500:
|
11
22
|
# If response['status'] == 1 (HTTP): resend received error entity
|
@@ -14,12 +25,12 @@ from atk_common.internal_response_utils import is_response_http
|
|
14
25
|
def http_response(method, response, container_info):
|
15
26
|
if is_http_status_ok(response['statusCode']):
|
16
27
|
return Response(
|
17
|
-
response=
|
28
|
+
response=convert_response_data(response['responseMsg']),
|
18
29
|
status=HTTPStatus.OK,
|
19
30
|
mimetype=response['contentType'],
|
20
31
|
headers=response['httpHeaders']
|
21
32
|
)
|
22
|
-
|
33
|
+
elif is_http_status_internal(response['statusCode']):
|
23
34
|
if is_response_http(response):
|
24
35
|
return resend_error_entity(response['responseMsg'])
|
25
36
|
return get_error_entity(response['responseMsg'], method, ApiErrorType.INTERNAL, response['statusCode'], container_info)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
atk_common/__init__.py,sha256=d_2XoFaQx5CGiBqbTdA3hx-yZ-CAXd-xXYk1DNBAXMg,1978
|
2
|
-
atk_common/datetime_utils.py,sha256=
|
2
|
+
atk_common/datetime_utils.py,sha256=v5WKmx49mUUSXW3oTBHKP_ryZwWf0hGZ0K2oQAI0SVo,3447
|
3
3
|
atk_common/db_utils.py,sha256=odUtXcS7Mumw5eGyVyVimL_U_lP7TqMX9v8nWO5nMvg,902
|
4
4
|
atk_common/docker_utils.py,sha256=nkUhp2OhwJsm41JDujHDY-JxQfdDjy91duprH59Esfk,2084
|
5
5
|
atk_common/env_utils.py,sha256=66v-S0vlkJNaun6ay1XcOGRtYJb4Ce4odJsWxuaHsQc,373
|
6
6
|
atk_common/error_utils.py,sha256=kO-VQlajD8SO9MBxj8MHZRTK_uBXgPa09hy6pfjqZBY,2622
|
7
7
|
atk_common/file_utils.py,sha256=UDwcRquO9IrqRrlUM0t-_g4R1-FKt8ZqQinSEqXOAk8,112
|
8
8
|
atk_common/hash_utils.py,sha256=S_9o89CdI4lUQbVaqc85TDcqyDNuo30_E3VBaOrZKko,1047
|
9
|
-
atk_common/http_response_utils.py,sha256=
|
9
|
+
atk_common/http_response_utils.py,sha256=xS3d3AkfpNDkvRRGSfdGhSaIR6MM0ZIC5N9ZoJs4cNo,1794
|
10
10
|
atk_common/http_utils.py,sha256=Av6wMa9984zQqXSrU3jndxLQO1xwv9U7YDFvJqZQAuo,664
|
11
11
|
atk_common/internal_response_utils.py,sha256=2X9eLFEy1pO3Aesj1IRXg2yprwNcBDM5_dXaA5vfmMI,694
|
12
12
|
atk_common/log_utils.py,sha256=tw6Ph8oTpxrGYe_BcDTYkgrYmFAb1IxTXTodqctAIiY,504
|
@@ -52,7 +52,7 @@ atk_common/enums/speed_control_status_type_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe
|
|
52
52
|
atk_common/enums/speed_control_stop_reason.py,sha256=pvLS6fpDhsCiIDAmiQBsHctxZnq-Dl2BOgJOxQnT5Hc,200
|
53
53
|
atk_common/enums/test_image_type_enum.py,sha256=HUjxJorehnzRXMNF2uHk2DrAJ3Y_ajQvp0jW-mtlOhU,140
|
54
54
|
atk_common/enums/violation_type_enum.py,sha256=01qTHOj-O8bOc-nwIHVnxLosm4cusD_YuqXM3ZsiRRk,86
|
55
|
-
atk_common-1.
|
55
|
+
atk_common-1.53.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
|
56
56
|
atk_package/__init__.py,sha256=NcsmwFadivgIeWV0-5ACZxqmfo4EzTkJX0r4N6DFAdg,820
|
57
57
|
atk_package/datetime_utils.py,sha256=qsVF7l90P1-xukG2tV_jLqG9J_Yfl5wTpyfrdPBlyMo,239
|
58
58
|
atk_package/env_utils.py,sha256=bXOrxM3fZUslqfmZt75iphbEJHbG4riJa8XOVzPwIII,313
|
@@ -65,7 +65,7 @@ atk_package/enums/__init__.py,sha256=EtUr_--MQj1Rc_R0sF_ELXIThmhpfmhDWq3YaK9oQMk
|
|
65
65
|
atk_package/enums/command_status_enum.py,sha256=M2Nln27a_DbzI07-gfytWQk2X087JhkU6Fmard5qVHs,127
|
66
66
|
atk_package/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
|
67
67
|
shared_python_atk_enforcement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
68
|
-
atk_common-1.
|
69
|
-
atk_common-1.
|
70
|
-
atk_common-1.
|
71
|
-
atk_common-1.
|
68
|
+
atk_common-1.53.0.dist-info/METADATA,sha256=SCo6wDQsXbRv78Eu04goLCm8xtvbY8GgSj1O40g7S3c,1464
|
69
|
+
atk_common-1.53.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
70
|
+
atk_common-1.53.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
|
71
|
+
atk_common-1.53.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|