1
1
import datetime
2
2
import logging
3
- import os . path
3
+ import os
4
4
import typing
5
5
6
6
import zeep .client
@@ -103,9 +103,6 @@ def __init__(
103
103
use_token_digest : bool = True ,
104
104
device_time_drift : typing .Optional [datetime .timedelta ] = None ,
105
105
):
106
- if not os .path .isfile (url ):
107
- raise exceptions .ONVIFError (f"{ url !r} doesn't exist!" )
108
-
109
106
self .url = url
110
107
self .xaddr = xaddr
111
108
@@ -204,7 +201,6 @@ class ONVIFCamera:
204
201
:param port: Camera port.
205
202
:param username: Camera username.
206
203
:param password: Camera user password.
207
- :param wsdl_dir: Directory with WSDL definitions, use the bundled one by default.
208
204
:param use_token_digest: Use password digest for WSSE authentication.
209
205
:param adjust_time: Allows authentication on cameras without being time synchronized.
210
206
NOTE: Please note that using NTP on both end is the recommended
@@ -218,7 +214,6 @@ def __init__(
218
214
port : int ,
219
215
username : str ,
220
216
password : str ,
221
- wsdl_dir : typing .Optional [str ] = None ,
222
217
use_token_digest : bool = True ,
223
218
adjust_time : bool = False ,
224
219
):
@@ -230,7 +225,6 @@ def __init__(
230
225
self ._port = port
231
226
self ._username = username
232
227
self ._password = password
233
- self ._wsdl_dir = wsdl_dir
234
228
self ._use_token_digest = use_token_digest
235
229
self ._adjust_time = adjust_time
236
230
@@ -245,10 +239,6 @@ def __init__(
245
239
246
240
self .to_dict = ONVIFService .to_dict
247
241
248
- # TODO: Better to handle with pathlib
249
- if self ._wsdl_dir is None :
250
- self ._wsdl_dir = os .path .join (os .path .dirname (__file__ ), 'wsdl' )
251
-
252
242
async def update_xaddrs (self ):
253
243
"""Update xaddrs for services."""
254
244
@@ -306,9 +296,7 @@ def get_definition(self, name, port_type=None):
306
296
namespace += '/' + port_type
307
297
308
298
# TODO: Cache or load asynchronously
309
- wsdlpath = os .path .join (self ._wsdl_dir , wsdl_file )
310
- if not os .path .isfile (wsdlpath ):
311
- raise exceptions .ONVIFError (f'No such file: { wsdlpath !r} ' )
299
+ wsdl_path = str (wsdl .WSDL_DIR / wsdl_file )
312
300
313
301
# XAddr for devicemgmt is fixed
314
302
if name == 'devicemgmt' :
@@ -318,14 +306,14 @@ def get_definition(self, name, port_type=None):
318
306
host = f'http://{ self ._host } '
319
307
320
308
xaddr = f'{ host } :{ self ._port } /onvif/device_service'
321
- return xaddr , wsdlpath , binding_name
309
+ return xaddr , wsdl_path , binding_name
322
310
323
311
# Get XAddr
324
312
xaddr = self ._xaddrs .get (namespace )
325
313
if not xaddr :
326
314
raise exceptions .ONVIFError (f"Device doesn't support service: { name !r} " )
327
315
328
- return xaddr , wsdlpath , binding_name
316
+ return xaddr , wsdl_path , binding_name
329
317
330
318
def create_onvif_service (
331
319
self ,
0 commit comments