Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wsdl_dir path resolving more robust #10967

Merged
merged 1 commit into from
Apr 13, 2024

Conversation

mweinelt
Copy link
Contributor

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.

>>> from importlib.util import find_spec
>>> from pathlib import Path
>>> Path(find_spec("onvif").origin).parent / "../wsdl"
PosixPath('/nix/store/awkcfajc6a0frwhvzib4pmmx0awa4bgj-python3-3.11.8-env/lib/python3.11/site-packages/onvif/../wsdl')

The ONVIFCamera object passes wsdl_dir into os.path.join, which accepts path-like objects since Python 3.6.

https://github.com/quatanium/python-onvif/blob/09ffc65b8cd9d141b6a386804e7af7028755034e/onvif/client.py#L343
https://docs.python.org/3/library/os.path.html#os.path.join

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.
Copy link

netlify bot commented Apr 13, 2024

Deploy Preview for frigate-docs ready!

Name Link
🔨 Latest commit fe51fb2
🔍 Latest deploy log https://app.netlify.com/sites/frigate-docs/deploys/661a8c4d6a930a0008f17f70
😎 Deploy Preview https://deploy-preview-10967--frigate-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@blakeblackshear blakeblackshear merged commit b65656f into blakeblackshear:dev Apr 13, 2024
10 checks passed
@mweinelt mweinelt deleted the onvif-wsdl-resolve branch April 13, 2024 17:27
@NickM-27
Copy link
Collaborator

NickM-27 commented Apr 16, 2024

in testing this doesn't seem to work

Onvif connection to office_cam failed: Unknown error: No such file: /usr/local/lib/python3.9/dist-packages/onvif/../wsdl/devicemgmt.wsdl

@NickM-27
Copy link
Collaborator

NickM-27 commented Apr 16, 2024

it should be finding site-packages but it is keying in to dist-packages

edit: addressed in #10998

@mweinelt
Copy link
Contributor Author

Where does an onvif-zeep dist-package come from in the first place? AIUI dist-packages is a Debianism, and there is no python3-onvif-zeep Debian package.

@NickM-27
Copy link
Collaborator

it isn't, it is installed via pip and the wsdl is only saved in site packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants