@@ -20,34 +20,36 @@ async def send_command(
20
20
** parameters : Any ,
21
21
) -> dict :
22
22
url = f"http://{ self .ip } :{ self .port } /api/{ command } "
23
- try :
24
- async with httpx .AsyncClient (
25
- transport = settings .transport (),
26
- ) as client :
27
- if parameters .get ("post" , False ):
28
- parameters .pop ("post" )
29
- data = await client .post (
30
- url ,
31
- timeout = settings .get ("api_function_timeout" , 3 ),
32
- json = parameters ,
33
- )
34
- elif parameters .get ("patch" , False ):
35
- parameters .pop ("patch" )
36
- data = await client .patch (
37
- url ,
38
- timeout = settings .get ("api_function_timeout" , 3 ),
39
- json = parameters ,
40
- )
41
- else :
42
- data = await client .get (url )
43
- except httpx .HTTPError :
44
- pass
45
- else :
46
- if data .status_code == 200 :
23
+ async with httpx .AsyncClient (transport = settings .transport ()) as client :
24
+ for _ in range (settings .get ("get_data_retries" , 1 )):
47
25
try :
48
- return data .json ()
49
- except json .decoder .JSONDecodeError :
26
+ if parameters .get ("post" , False ):
27
+ parameters .pop ("post" )
28
+ data = await client .post (
29
+ url ,
30
+ timeout = settings .get ("api_function_timeout" , 3 ),
31
+ json = parameters ,
32
+ )
33
+ elif parameters .get ("patch" , False ):
34
+ parameters .pop ("patch" )
35
+ data = await client .patch (
36
+ url ,
37
+ timeout = settings .get ("api_function_timeout" , 3 ),
38
+ json = parameters ,
39
+ )
40
+ else :
41
+ data = await client .get (
42
+ url ,
43
+ timeout = settings .get ("api_function_timeout" , 5 ),
44
+ )
45
+ except httpx .HTTPError :
50
46
pass
47
+ else :
48
+ if data .status_code == 200 :
49
+ try :
50
+ return data .json ()
51
+ except json .decoder .JSONDecodeError :
52
+ pass
51
53
52
54
async def multicommand (
53
55
self , * commands : str , ignore_errors : bool = False , allow_warning : bool = True
0 commit comments