Skip to content

Commit 7761ca7

Browse files
author
Max Ziermann
committed
1 parent 6548040 commit 7761ca7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

APIHandler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def login(self) -> bool:
5757
param = {"cmd": "Login", "token": "null"}
5858
response = Request.post(self.url, data=body, params=param)
5959
if response is not None:
60-
data = json.loads(response.text)[0]
60+
data = response.json()[0]
6161
code = data["code"]
6262
if int(code) == 0:
6363
self.token = data["value"]["Token"]["name"]
@@ -89,7 +89,7 @@ def _execute_command(self, command, data, multi=False):
8989
if self.token is None:
9090
raise ValueError("Login first")
9191
response = Request.post(self.url, data=data, params=params)
92-
return json.loads(response.text)
92+
return response.json()
9393
except Exception as e:
9494
print(f"Command {command} failed: {e}")
9595
raise
@@ -159,7 +159,7 @@ def get_net_ports(self) -> json or None:
159159
{"cmd": "GetP2p", "action": 0, "param": {}}]
160160
param = {"token": self.token}
161161
response = Request.post(self.url, data=body, params=param)
162-
return json.loads(response.text)
162+
return response.json()
163163
except Exception as e:
164164
print("Get Network Ports", e)
165165

@@ -266,7 +266,7 @@ def get_general_system(self) -> json or None:
266266
param = {"token": self.token}
267267
response = Request.post(self.url, data=body, params=param)
268268
if response.status_code == 200:
269-
return json.loads(response.text)
269+
return response.json()
270270
except Exception as e:
271271
print("Could not get General System settings\n", e)
272272
raise

0 commit comments

Comments
 (0)