atk-common 3.8.0__py3-none-any.whl → 3.10.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.
@@ -60,10 +60,10 @@ class ErrorHandler(IErrorHandler):
60
60
 
61
61
  def handle_error(self, resp, status):
62
62
  if is_http_status_internal(resp.status_code):
63
- self.logger.info(resp.json().get('message'))
63
+ self.logger.error(resp.json().get('message'))
64
64
  return create_response(status, resp.status_code, resp.json())
65
65
  else:
66
- self.logger.info(resp.text)
66
+ self.logger.error(resp.text)
67
67
  return create_response(status, resp.status_code, resp.text)
68
68
 
69
69
  def get_response_error(self, resp):
@@ -4,12 +4,13 @@ from http import HTTPStatus
4
4
  from atk_common.enums.api_error_type_enum import ApiErrorType
5
5
  from atk_common.utils.http_utils import is_http_status_internal, is_http_status_ok
6
6
  from atk_common.utils.internal_response_utils import is_response_http
7
- from atk_common.interfaces import IErrorHandler
7
+ from atk_common.interfaces import IErrorHandler, ILogger
8
8
  from atk_common.interfaces import IHttpResponseHandler
9
9
 
10
10
  class HttpResponseHandler(IHttpResponseHandler):
11
- def __init__(self, error_handler: IErrorHandler):
11
+ def __init__(self, logger: ILogger, error_handler: IErrorHandler):
12
12
  self.error_handler = error_handler
13
+ self.logger = logger
13
14
 
14
15
  def _convert_response_data(self, data):
15
16
  if isinstance(data, dict):
@@ -28,15 +29,16 @@ class HttpResponseHandler(IHttpResponseHandler):
28
29
  # If response['status'] == 2 (INTERNAL): create new error entity and return as response
29
30
  # If http status other value: create new error entity and return as response
30
31
  def http_response(self, method, response):
31
- if is_http_status_ok(response['statusCode']):
32
+ self.logger.debug(f'http_response: method={method}, statusCode={response.get('statusCode')}')
33
+ if is_http_status_ok(response.get('statusCode')):
32
34
  return Response(
33
- response=self._convert_response_data(response['responseMsg']),
35
+ response=self._convert_response_data(response.get('responseMsg')),
34
36
  status=HTTPStatus.OK,
35
- mimetype=response['contentType'],
36
- headers=response['httpHeaders']
37
+ mimetype=response.get('contentType'),
38
+ headers=response.get('httpHeaders')
37
39
  )
38
- elif is_http_status_internal(response['statusCode']):
40
+ elif is_http_status_internal(response('statusCode')):
39
41
  if is_response_http(response):
40
- return self.error_handler.resend_error_entity(response['responseMsg'])
41
- return self.error_handler.get_error_entity(response['responseMsg'], method, ApiErrorType.INTERNAL, response['statusCode'])
42
- return self.error_handler.get_error_entity(response['responseMsg'], method, ApiErrorType.CONNECTION, response['statusCode'])
42
+ return self.error_handler.resend_error_entity(response('responseMsg'))
43
+ return self.error_handler.get_error_entity(response('responseMsg'), method, ApiErrorType.INTERNAL, response('statusCode'))
44
+ return self.error_handler.get_error_entity(response('responseMsg'), method, ApiErrorType.CONNECTION, response('statusCode'))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atk_common
3
- Version: 3.8.0
3
+ Version: 3.10.0
4
4
  Summary: ATK common methods
5
5
  Home-page: https://github.com/pypa/atk_common
6
6
  Author: Roger
@@ -20,8 +20,8 @@ atk_common/classes/__init__.py,sha256=O_VHYxAilmoz3i9L6jkwS-JZ4UaTezdhFiA5liNl1l
20
20
  atk_common/classes/bo_logger.py,sha256=wo1-BNWZjzSnlcM7c0LB7tK__2g3BENXvSvCLEiTOME,2065
21
21
  atk_common/classes/docker_handler.py,sha256=VNJecc2ZWcpwNBa61QTGM_kYrsoZTjktMcFRFGF4xI4,3048
22
22
  atk_common/classes/env_handler.py,sha256=h3snKwHwDvfc2dt1vgHasqv8n_vnsI9J2MAr-XM5oow,1283
23
- atk_common/classes/error_handler.py,sha256=D2oILLc8VeZmd16PuJsjfu7g0Q6kCWazt8FPa3gJamQ,3268
24
- atk_common/classes/http_response_handler.py,sha256=l8CfntLPRHbB1nfUPPGnmTvQMAM29CVK4THG4FK1_4k,2128
23
+ atk_common/classes/error_handler.py,sha256=DgRzWx4Yu8PKX1bqj55aWhrkqb92ebDaEwtxgKhTLls,3270
24
+ atk_common/classes/http_response_handler.py,sha256=gv-qmKrEn-Mus0MW1egryJ9mT9lLPe9asIkMMMN45IM,2303
25
25
  atk_common/classes/rabbitmq_consumer.py,sha256=jct1UnfP-PU3IeWW2S_9dQ7FxmY0_M8YwZadFMv52j8,2936
26
26
  atk_common/enums/__init__.py,sha256=hOSoKWIBUpRFaMN2tNJiel6iGI1MHj229OYnU1J8Jg0,2636
27
27
  atk_common/enums/api_error_type_enum.py,sha256=9oW6ZaZ3lhMwR8r2sVNWGliS9C_jV-otiOYdezAuTp0,91
@@ -81,7 +81,7 @@ atk_common/utils/http_utils.py,sha256=eSRuQeDgN0ISQdByZqE6cIGXoorcAXz7PEtVntHUKA
81
81
  atk_common/utils/internal_response_utils.py,sha256=2X9eLFEy1pO3Aesj1IRXg2yprwNcBDM5_dXaA5vfmMI,694
82
82
  atk_common/utils/mq_utils.py,sha256=DmVcXIZHG45p7cQVvgen6OT8QbW_UifFFJGJBybTkJQ,1835
83
83
  atk_common/utils/str_utils.py,sha256=sg3jwTTIfQvgGP-lcY5Xh4PXXhKWse_4HswBQYQKEo4,260
84
- atk_common-3.8.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
84
+ atk_common-3.10.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
85
85
  atk_package/__init__.py,sha256=okIFEefQhQrw6DZg6oCEVWsEdkVCk-57VXBW0IUG_wU,834
86
86
  atk_package/datetime_utils.py,sha256=qsVF7l90P1-xukG2tV_jLqG9J_Yfl5wTpyfrdPBlyMo,239
87
87
  atk_package/env_utils.py,sha256=bXOrxM3fZUslqfmZt75iphbEJHbG4riJa8XOVzPwIII,313
@@ -94,7 +94,7 @@ atk_package/enums/__init__.py,sha256=EtUr_--MQj1Rc_R0sF_ELXIThmhpfmhDWq3YaK9oQMk
94
94
  atk_package/enums/command_status_enum.py,sha256=M2Nln27a_DbzI07-gfytWQk2X087JhkU6Fmard5qVHs,127
95
95
  atk_package/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
96
96
  shared_python_atk_enforcement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
- atk_common-3.8.0.dist-info/METADATA,sha256=og3Q1fsls7xseAr--C-ShEPmkDU7uMPePfr411IkwU4,1760
98
- atk_common-3.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
99
- atk_common-3.8.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
100
- atk_common-3.8.0.dist-info/RECORD,,
97
+ atk_common-3.10.0.dist-info/METADATA,sha256=SQPwcQ0lVvaxbi8h0Kgv7zGdOC87k_bH7Vkd2ltgluw,1761
98
+ atk_common-3.10.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
99
+ atk_common-3.10.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
100
+ atk_common-3.10.0.dist-info/RECORD,,