diff --git a/api/device.py b/api/device.py index 263a999..deee890 100644 --- a/api/device.py +++ b/api/device.py @@ -16,8 +16,8 @@ class DeviceAPIMixin: :return: bool """ body = [{"cmd": "Format", "action": 0, "param": {"HddInfo": {"id": hdd_id}}}] - r_data = self._execute_command('Format', body) - if r_data["value"]["rspCode"] == "200": + r_data = self._execute_command('Format', body)[0] + if r_data["value"]["rspCode"] == 200: return True print("Could not format HDD/SD. Camera responded with:", r_data["value"]) return False diff --git a/api/display.py b/api/display.py index 72380b4..bf2b4ae 100644 --- a/api/display.py +++ b/api/display.py @@ -40,8 +40,8 @@ class DisplayAPIMixin: "osdTime": {"enable": osd_time_enabled, "pos": osd_time_pos} } }}] - r_data = self._execute_command('SetOsd', body) - if r_data["value"]["rspCode"] == "200": + r_data = self._execute_command('SetOsd', body)[0] + if r_data["value"]["rspCode"] == 200: return True print("Could not set OSD. Camera responded with status:", r_data["value"]) return False diff --git a/api/user.py b/api/user.py index 7473901..9d430f6 100644 --- a/api/user.py +++ b/api/user.py @@ -28,8 +28,8 @@ class UserAPIMixin: """ body = [{"cmd": "AddUser", "action": 0, "param": {"User": {"userName": username, "password": password, "level": level}}}] - r_data = self._execute_command('AddUser', body) - if r_data["value"]["rspCode"] == "200": + r_data = self._execute_command('AddUser', body)[0] + if r_data["value"]["rspCode"] == 200: return True print("Could not add user. Camera responded with:", r_data["value"]) return False @@ -42,8 +42,8 @@ class UserAPIMixin: :return: whether the user was modified successfully """ body = [{"cmd": "ModifyUser", "action": 0, "param": {"User": {"userName": username, "password": password}}}] - r_data = self._execute_command('ModifyUser', body) - if r_data["value"]["rspCode"] == "200": + r_data = self._execute_command('ModifyUser', body)[0] + if r_data["value"]["rspCode"] == 200: return True print("Could not modify user:", username, "\nCamera responded with:", r_data["value"]) return False @@ -55,8 +55,8 @@ class UserAPIMixin: :return: whether the user was deleted successfully """ body = [{"cmd": "DelUser", "action": 0, "param": {"User": {"userName": username}}}] - r_data = self._execute_command('DelUser', body) - if r_data["value"]["rspCode"] == "200": + r_data = self._execute_command('DelUser', body)[0] + if r_data["value"]["rspCode"] == 200: return True print("Could not delete user:", username, "\nCamera responded with:", r_data["value"]) return False