kisa-utils 0.42.15__py3-none-any.whl → 0.42.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.
- kisa_utils/remote.py +8 -5
- {kisa_utils-0.42.15.dist-info → kisa_utils-0.42.16.dist-info}/METADATA +1 -1
- {kisa_utils-0.42.15.dist-info → kisa_utils-0.42.16.dist-info}/RECORD +5 -5
- {kisa_utils-0.42.15.dist-info → kisa_utils-0.42.16.dist-info}/WHEEL +0 -0
- {kisa_utils-0.42.15.dist-info → kisa_utils-0.42.16.dist-info}/top_level.txt +0 -0
kisa_utils/remote.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import requests
|
|
2
|
+
from kisa_utils.dataStructures import KDict
|
|
2
3
|
|
|
3
|
-
def sendRequest(url:str|bytes, method:str|bytes='post', jsonPayload:dict={}, timeout:int=180, **requestKwargs:dict) ->
|
|
4
|
+
def sendRequest(url:str|bytes, method:str|bytes='post', jsonPayload:dict={}, timeout:int=180, **requestKwargs:dict) -> KDict:
|
|
4
5
|
'''
|
|
5
6
|
attempt to send request with JSON payload.
|
|
6
7
|
Args:
|
|
@@ -23,7 +24,7 @@ def sendRequest(url:str|bytes, method:str|bytes='post', jsonPayload:dict={}, tim
|
|
|
23
24
|
@return {'status':BOOL, 'log':STR, }
|
|
24
25
|
'''
|
|
25
26
|
|
|
26
|
-
reply = {'status':False, 'log':'', 'response':None}
|
|
27
|
+
reply = KDict({'status':False, 'log':'', 'response':None, 'statusCode': None})
|
|
27
28
|
|
|
28
29
|
method = method.lower()
|
|
29
30
|
if method not in ['get','post']:
|
|
@@ -39,6 +40,8 @@ def sendRequest(url:str|bytes, method:str|bytes='post', jsonPayload:dict={}, tim
|
|
|
39
40
|
reply['log'] = 'invalid method given'
|
|
40
41
|
return reply
|
|
41
42
|
|
|
43
|
+
reply.statusCode = response.status_code
|
|
44
|
+
|
|
42
45
|
if response.status_code!=200:
|
|
43
46
|
try: reply['response'] = response.json()
|
|
44
47
|
except: pass
|
|
@@ -48,11 +51,11 @@ def sendRequest(url:str|bytes, method:str|bytes='post', jsonPayload:dict={}, tim
|
|
|
48
51
|
|
|
49
52
|
try:
|
|
50
53
|
responseJSON = response.json()
|
|
51
|
-
reply['response'] = responseJSON
|
|
54
|
+
reply['response'] = KDict(responseJSON) if isinstance(responseJSON, dict) else responseJSON
|
|
52
55
|
reply['status'] = True
|
|
53
56
|
return reply
|
|
54
|
-
except:
|
|
55
|
-
reply['log'] = 'no JSON reply got'
|
|
57
|
+
except Exception as e:
|
|
58
|
+
reply['log'] = f'no JSON reply got: {e}'
|
|
56
59
|
return reply
|
|
57
60
|
|
|
58
61
|
except requests.exceptions.Timeout:
|
|
@@ -9,7 +9,7 @@ kisa_utils/encryption.py,sha256=nFzNpzWV_D9uSEq4FsgCnlS7FQtqWP9fvM_81rsfcLo,4218
|
|
|
9
9
|
kisa_utils/figures.py,sha256=pYIpQzu1OXRSsY1d98GhgPifnIRmgl-r7S32ai-Ms0c,3731
|
|
10
10
|
kisa_utils/functionUtils.py,sha256=PlXjnmU1uJWNdISlJJ3SCgavTsgNBoebaa9dtWSFhRA,6553
|
|
11
11
|
kisa_utils/log.py,sha256=0TYdxcIBts026RCSuVIQBcZ-CW1ES7n3M1nEIjmeLTM,2295
|
|
12
|
-
kisa_utils/remote.py,sha256=
|
|
12
|
+
kisa_utils/remote.py,sha256=z5QTKC0Mb_wMWVHWfUHR1XOOek-A2fNjo1GyFPhAB8s,2373
|
|
13
13
|
kisa_utils/response.py,sha256=asETUBkeF5OlSTwa-coa7lZDCKmQlHCmHf6eaZFl8CU,4560
|
|
14
14
|
kisa_utils/standardize.py,sha256=nt-uzHQFoKxGscD_MpDYXw65Teg3724whAqa6Kh_zhE,2231
|
|
15
15
|
kisa_utils/storage.py,sha256=6NdEVrHMS7WB_vmCwiGigIinu-EjxalFJhk1kj-_vWs,5990
|
|
@@ -27,7 +27,7 @@ kisa_utils/servers/flask.py,sha256=XZYY1pWnP1mSvaS5Uv8G3EFJV5BJBQtU2gDbO8suvLc,4
|
|
|
27
27
|
kisa_utils/structures/__init__.py,sha256=JBU1j3A42jQ62ALKnsS1Hav9YXcYwjDw1wQJtohXPbU,83
|
|
28
28
|
kisa_utils/structures/utils.py,sha256=665rXIapGwFqejizeJwy3DryeskCQOdgP25BCdLkGvk,2898
|
|
29
29
|
kisa_utils/structures/validator.py,sha256=oCSgY_itst6bZdC5g8yVU4-lSH2xnUsOx3X-oPyV7nA,4626
|
|
30
|
-
kisa_utils-0.42.
|
|
31
|
-
kisa_utils-0.42.
|
|
32
|
-
kisa_utils-0.42.
|
|
33
|
-
kisa_utils-0.42.
|
|
30
|
+
kisa_utils-0.42.16.dist-info/METADATA,sha256=QpmdDDEFdlFivDSSUJHi96YMgxbauPELUz7BD8DO4Zk,478
|
|
31
|
+
kisa_utils-0.42.16.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
32
|
+
kisa_utils-0.42.16.dist-info/top_level.txt,sha256=GFOLXZYqpBG9xtscGa2uGJAEiZ5NwsqHBH9NylnB29M,11
|
|
33
|
+
kisa_utils-0.42.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|