Skip to content

Commit fe51fb2

Browse files
committed
Make wsdl_dir path resolving more robust
Relying on importlib to resolve the path to the wsdl directory is more robust, since it traverses all site-packages directories, that are part of the PYTHONPATH.
1 parent 11dc407 commit fe51fb2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

frigate/ptz/onvif.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Configure and control camera via onvif."""
22

33
import logging
4-
import site
54
from enum import Enum
5+
from importlib.util import find_spec
6+
from pathlib import Path
67

78
import numpy
89
from onvif import ONVIFCamera, ONVIFError
@@ -50,10 +51,7 @@ def __init__(
5051
cam.onvif.port,
5152
cam.onvif.user,
5253
cam.onvif.password,
53-
wsdl_dir=site.getsitepackages()[0].replace(
54-
"dist-packages", "site-packages"
55-
)
56-
+ "/wsdl",
54+
wsdl_dir=Path(find_spec("onvif").origin).parent / "../wsdl",
5755
),
5856
"init": False,
5957
"active": False,

0 commit comments

Comments
 (0)