Skip to content

Commit 17fb46f

Browse files
author
Max Ziermann
committed
Fix return value hints
None is never returned, its just possible that a exception is raised.
1 parent 3f6e0b2 commit 17fb46f

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

APIHandler.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def set_net_port(self, http_port=80, https_port=443, media_port=9000, onvif_port
126126
print("Successfully Set Network Ports")
127127
return True
128128

129-
def set_wifi(self, ssid, password) -> json or None:
129+
def set_wifi(self, ssid, password) -> json:
130130
body = [{"cmd": "SetWifi", "action": 0, "param": {
131131
"Wifi": {
132132
"ssid": ssid,
@@ -137,10 +137,10 @@ def set_wifi(self, ssid, password) -> json or None:
137137
###########
138138
# GET
139139
###########
140-
def get_net_ports(self) -> json or None:
140+
def get_net_ports(self) -> json:
141141
"""
142142
Get network ports
143-
:return:
143+
:return: response json
144144
"""
145145
body = [{"cmd": "GetNetPort", "action": 1, "param": {}},
146146
{"cmd": "GetUpnp", "action": 0, "param": {}},
@@ -162,20 +162,20 @@ def scan_wifi(self):
162162
###########
163163
# GET
164164
###########
165-
def get_osd(self) -> json or None:
165+
def get_osd(self) -> json:
166166
"""
167167
Get OSD information.
168168
See examples/response/GetOsd.json for example response data.
169-
:return: json or None
169+
:return: response json
170170
"""
171171
body = [{"cmd": "GetOsd", "action": 1, "param": {"channel": 0}}]
172172
return self._execute_command('GetOsd', body)
173173

174-
def get_mask(self) -> json or None:
174+
def get_mask(self) -> json:
175175
"""
176176
Get the camera mask information.
177177
See examples/response/GetMask.json for example response data.
178-
:return: json or None
178+
:return: response json
179179
"""
180180
body = [{"cmd": "GetMask", "action": 1, "param": {"channel": 0}}]
181181
return self._execute_command('GetMask', body)
@@ -195,7 +195,7 @@ def set_osd(self, bg_color: bool = 0, channel: int = 0, osd_channel_enabled: boo
195195
:param osd_channel_pos: string channel position ["Upper Left","Top Center","Upper Right","Lower Left","Bottom Center","Lower Right"]
196196
:param osd_time_enabled: bool
197197
:param osd_time_pos: string time position ["Upper Left","Top Center","Upper Right","Lower Left","Bottom Center","Lower Right"]
198-
:return:
198+
:return: whether the action was successful
199199
"""
200200
body = [{"cmd": "SetOsd", "action": 1, "param": {
201201
"Osd": {"bgcolor": bg_color, "channel": channel,
@@ -217,35 +217,36 @@ def set_osd(self, bg_color: bool = 0, channel: int = 0, osd_channel_enabled: boo
217217
###########
218218
# GET
219219
###########
220-
def get_general_system(self) -> json or None:
220+
def get_general_system(self) -> json:
221+
""":return: response json"""
221222
body = [{"cmd": "GetTime", "action": 1, "param": {}}, {"cmd": "GetNorm", "action": 1, "param": {}}]
222223
return self._execute_command('get_general_system', body, multi=True)
223224

224-
def get_performance(self) -> json or None:
225+
def get_performance(self) -> json:
225226
"""
226227
Get a snapshot of the current performance of the camera.
227228
See examples/response/GetPerformance.json for example response data.
228-
:return: json or None
229+
:return: response json
229230
"""
230231
body = [{"cmd": "GetPerformance", "action": 0, "param": {}}]
231232
return self._execute_command('GetPerformance', body)
232233

233-
def get_information(self) -> json or None:
234+
def get_information(self) -> json:
234235
"""
235236
Get the camera information
236237
See examples/response/GetDevInfo.json for example response data.
237-
:return: json or None
238+
:return: response json
238239
"""
239240
body = [{"cmd": "GetDevInfo", "action": 0, "param": {}}]
240241
return self._execute_command('GetDevInfo', body)
241242

242243
###########
243244
# SET
244245
###########
245-
def reboot_camera(self) -> bool:
246+
def reboot_camera(self) -> json:
246247
"""
247248
Reboots the camera
248-
:return: bool
249+
:return: response json
249250
"""
250251
body = [{"cmd": "Reboot", "action": 0, "param": {}}]
251252
return self._execute_command('Reboot', body)
@@ -257,20 +258,20 @@ def reboot_camera(self) -> bool:
257258
##########
258259
# GET
259260
##########
260-
def get_online_user(self) -> json or None:
261+
def get_online_user(self) -> json:
261262
"""
262263
Return a list of current logged-in users in json format
263264
See examples/response/GetOnline.json for example response data.
264-
:return: json or None
265+
:return: response json
265266
"""
266267
body = [{"cmd": "GetOnline", "action": 1, "param": {}}]
267268
return self._execute_command('GetOnline', body)
268269

269-
def get_users(self) -> json or None:
270+
def get_users(self) -> json:
270271
"""
271272
Return a list of user accounts from the camera in json format.
272273
See examples/response/GetUser.json for example response data.
273-
:return: json or None
274+
:return: response json
274275
"""
275276
body = [{"cmd": "GetUser", "action": 1, "param": {}}]
276277
return self._execute_command('GetUser', body)
@@ -284,7 +285,7 @@ def add_user(self, username: str, password: str, level: str = "guest") -> bool:
284285
:param username: The user's username
285286
:param password: The user's password
286287
:param level: The privilege level 'guest' or 'admin'. Default is 'guest'
287-
:return: bool
288+
:return: whether the user was added successfully
288289
"""
289290
body = [{"cmd": "AddUser", "action": 0,
290291
"param": {"User": {"userName": username, "password": password, "level": level}}}]
@@ -299,7 +300,7 @@ def modify_user(self, username: str, password: str) -> bool:
299300
Modify the user's password by specifying their username
300301
:param username: The user which would want to be modified
301302
:param password: The new password
302-
:return: bool
303+
:return: whether the user was modified successfully
303304
"""
304305
body = [{"cmd": "ModifyUser", "action": 0, "param": {"User": {"userName": username, "password": password}}}]
305306
r_data = self._execute_command('ModifyUser', body)
@@ -312,7 +313,7 @@ def delete_user(self, username: str) -> bool:
312313
"""
313314
Delete a user by specifying their username
314315
:param username: The user which would want to be deleted
315-
:return: bool
316+
:return: whether the user was deleted successfully
316317
"""
317318
body = [{"cmd": "DelUser", "action": 0, "param": {"User": {"userName": username}}}]
318319
r_data = self._execute_command('DelUser', body)
@@ -352,11 +353,11 @@ def get_snap(self, timeout: int = 3) -> Image or None:
352353
#########
353354
# Device
354355
#########
355-
def get_hdd_info(self) -> json or None:
356+
def get_hdd_info(self) -> json:
356357
"""
357358
Gets all HDD and SD card information from Camera
358359
See examples/response/GetHddInfo.json for example response data.
359-
:return: json or None
360+
:return: response json
360361
"""
361362
body = [{"cmd": "GetHddInfo", "action": 0, "param": {}}]
362363
return self._execute_command('GetHddInfo', body)
@@ -385,20 +386,20 @@ def format_hdd(self, hdd_id: [int] = [0]) -> bool:
385386
###########
386387
# GET
387388
###########
388-
def get_recording_encoding(self) -> json or None:
389+
def get_recording_encoding(self) -> json:
389390
"""
390391
Get the current camera encoding settings for "Clear" and "Fluent" profiles.
391392
See examples/response/GetEnc.json for example response data.
392-
:return: json or None
393+
:return: response json
393394
"""
394395
body = [{"cmd": "GetEnc", "action": 1, "param": {"channel": 0}}]
395396
return self._execute_command('GetEnc', body)
396397

397-
def get_recording_advanced(self) -> json or None:
398+
def get_recording_advanced(self) -> json:
398399
"""
399400
Get recording advanced setup data
400401
See examples/response/GetRec.json for example response data.
401-
:return: json or None
402+
:return: response json
402403
"""
403404
body = [{"cmd": "GetRec", "action": 1, "param": {"channel": 0}}]
404405
return self._execute_command('GetRec', body)

0 commit comments

Comments
 (0)