python3-commons 0.6.14__py3-none-any.whl → 0.6.16__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.
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  from contextlib import asynccontextmanager
2
3
  from datetime import datetime, UTC
3
4
  from json import dumps
@@ -13,6 +14,9 @@ from python3_commons.helpers import request_to_curl
13
14
  from python3_commons.serializers.json import CustomJSONEncoder
14
15
 
15
16
 
17
+ logger = logging.getLogger(__name__)
18
+
19
+
16
20
  async def _store_response_for_audit(
17
21
  response: ClientResponse,
18
22
  audit_name: str,
@@ -22,15 +26,16 @@ async def _store_response_for_audit(
22
26
  ):
23
27
  response_text = await response.text()
24
28
 
25
- now = datetime.now(tz=UTC)
26
- date_path = now.strftime('%Y/%m/%d')
27
- timestamp = now.strftime('%H%M%S_%f')
29
+ if response_text:
30
+ now = datetime.now(tz=UTC)
31
+ date_path = now.strftime('%Y/%m/%d')
32
+ timestamp = now.strftime('%H%M%S_%f')
28
33
 
29
- await audit.write_audit_data(
30
- s3_settings,
31
- f'{date_path}/{audit_name}/{uri_path}/{method}_{timestamp}_{request_id}_response.txt',
32
- response_text.encode('utf-8')
33
- )
34
+ await audit.write_audit_data(
35
+ s3_settings,
36
+ f'{date_path}/{audit_name}/{uri_path}/{method}_{timestamp}_{request_id}_response.txt',
37
+ response_text.encode('utf-8')
38
+ )
34
39
 
35
40
 
36
41
  @asynccontextmanager
@@ -70,9 +75,11 @@ async def request(
70
75
  )
71
76
  client_method = getattr(client, method)
72
77
 
78
+ logger.debug(f'Requesting {method} {url}')
79
+
73
80
  try:
74
81
  if method == 'get':
75
- async with client_method(url, params=query) as response:
82
+ async with client_method(url, params=query, headers=headers) as response:
76
83
  if audit_name:
77
84
  await _store_response_for_audit(response, audit_name, uri_path, method, request_id)
78
85
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: python3-commons
3
- Version: 0.6.14
3
+ Version: 0.6.16
4
4
  Summary: Re-usable Python3 code
5
5
  Author-email: Oleg Korsak <kamikaze.is.waiting.you@gmail.com>
6
6
  License: gpl-3
@@ -1,5 +1,5 @@
1
1
  python3_commons/__init__.py,sha256=0KgaYU46H_IMKn-BuasoRN3C4Hi45KlkHHoPbU9cwiA,189
2
- python3_commons/api_client.py,sha256=yxK-uvDayrxbuSi1iFeGoFx6S8VGgnCDTFCs-LxSusk,3561
2
+ python3_commons/api_client.py,sha256=yt15XtnHl_9oqlwuepabq_IUjozNrO_KM9sQ1NaGdxI,3734
3
3
  python3_commons/audit.py,sha256=DMQ-nrWSs0qilD7wkz_8PV4jXcee75O8FgAm2YIuOiY,6256
4
4
  python3_commons/conf.py,sha256=qm2a2yWOhfawicBPjWnUett8TrsMtoyQXDxEJ_N-v-Y,637
5
5
  python3_commons/db.py,sha256=qhaDIdzBWgFyeP_XPKfHZlYVlwS2bpBPYMv84yV6820,738
@@ -13,9 +13,9 @@ python3_commons/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
13
13
  python3_commons/serializers/json.py,sha256=P288wWz9ic38QWEMrpp_uwKPYkQiOgvE1cI4WZn6ZCg,808
14
14
  python3_commons/serializers/msgpack.py,sha256=tzIGGyDL3UpZnnouCtnxuYDx6InKM_C3PP1N4PN8wd4,1269
15
15
  python3_commons/serializers/msgspec.py,sha256=FuZVqOLJb0-lEKrs7dtjhwEbHIpfMUk5yu1hD64zRdc,2038
16
- python3_commons-0.6.14.dist-info/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
17
- python3_commons-0.6.14.dist-info/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
18
- python3_commons-0.6.14.dist-info/METADATA,sha256=FKyFkQ3-MALx9N8ZEb_pSs77F1z6ZHG_PGF5hfQGRJ0,986
19
- python3_commons-0.6.14.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
- python3_commons-0.6.14.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
21
- python3_commons-0.6.14.dist-info/RECORD,,
16
+ python3_commons-0.6.16.dist-info/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
17
+ python3_commons-0.6.16.dist-info/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
18
+ python3_commons-0.6.16.dist-info/METADATA,sha256=YqSUDK19JHf6iWREdjSSpCyENA4nzDw325Rg1rT4kWM,986
19
+ python3_commons-0.6.16.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
+ python3_commons-0.6.16.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
21
+ python3_commons-0.6.16.dist-info/RECORD,,