Skip to content

Commit 52172f4

Browse files
authored
Merge pull request #5 from hunterjm/httpx
Bump to Zeep 4.0/httpx and add get snapshot
2 parents ed416c1 + 660dfe6 commit 52172f4

File tree

17 files changed

+421
-562
lines changed

17 files changed

+421
-562
lines changed

.pre-commit-config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v2.7.2
4+
hooks:
5+
- id: pyupgrade
6+
args: [--py36-plus]
7+
- repo: https://github.com/psf/black
8+
rev: 20.8b1
9+
hooks:
10+
- id: black
11+
args:
12+
- --safe
13+
- --quiet
14+
files: ^((xbox|tests)/.+)?[^/]+\.py$
15+
- repo: https://gitlab.com/pycqa/flake8
16+
rev: 3.8.3
17+
hooks:
18+
- id: flake8
19+
additional_dependencies:
20+
# - flake8-docstrings==1.5.0
21+
- pydocstyle==5.1.1
22+
files: ^(xbox)/.+\.py$
23+
- repo: https://github.com/PyCQA/bandit
24+
rev: 1.6.2
25+
hooks:
26+
- id: bandit
27+
args:
28+
- --quiet
29+
- --format=custom
30+
- --configfile=bandit.yaml
31+
files: ^(xbox|tests)/.+\.py$
32+
- repo: https://github.com/PyCQA/isort
33+
rev: 5.5.3
34+
hooks:
35+
- id: isort
36+
- repo: https://github.com/pre-commit/pre-commit-hooks
37+
rev: v3.2.0
38+
hooks:
39+
- id: check-executables-have-shebangs
40+
stages: [manual]
41+
- id: check-json
42+
- repo: https://github.com/prettier/prettier
43+
rev: 2.0.4
44+
hooks:
45+
- id: prettier
46+
stages: [manual]
47+

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
2+
3+
clean-build: ## remove build artifacts
4+
rm -fr build/
5+
rm -fr dist/
6+
rm -fr .eggs/
7+
find . -name '*.egg-info' -exec rm -fr {} +
8+
find . -name '*.egg' -exec rm -fr {} +
9+
10+
clean-pyc: ## remove Python file artifacts
11+
find . -name '*.pyc' -exec rm -f {} +
12+
find . -name '*.pyo' -exec rm -f {} +
13+
find . -name '*~' -exec rm -f {} +
14+
find . -name '__pycache__' -exec rm -fr {} +
15+
16+
clean-test: ## remove test and coverage artifacts
17+
rm -fr .tox/
18+
rm -f .coverage
19+
rm -fr htmlcov/
20+
21+
lint: ## check style with flake8
22+
flake8 onvif tests
23+
pylint onvif
24+
25+
test: ## run tests quickly with the default Python
26+
pytest --cov=onvif --cov-report html tests/
27+
28+
release: clean ## package and upload a release
29+
python3 -m twine upload dist/*
30+
31+
dist: clean ## builds source and wheel package
32+
python setup.py sdist
33+
python setup.py bdist_wheel
34+
ls -l dist
35+
36+
install: clean ## install the package to the active Python's site-packages
37+
pip3 install -r requirements.txt
38+
pre-commit install
39+
pip3 install -e .

bandit.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# https://bandit.readthedocs.io/en/latest/config.html
2+
3+
tests:
4+
- B108
5+
- B306
6+
- B307
7+
- B313
8+
- B314
9+
- B315
10+
- B316
11+
- B317
12+
- B318
13+
- B319
14+
- B320
15+
- B325
16+
- B602
17+
- B604

examples/continuous_move.py

Lines changed: 0 additions & 159 deletions
This file was deleted.

examples/events.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Example to fetch pullpoint events."""
22
import asyncio
33
import datetime as dt
4-
from pytz import UTC
54
import logging
5+
6+
from pytz import UTC
67
from zeep import xsd
78

89
from onvif import ONVIFCamera
@@ -24,7 +25,7 @@ async def run():
2425
print("PullPoint not supported")
2526
return
2627

27-
event_service = mycam.get_service("events")
28+
event_service = mycam.create_events_service()
2829
properties = await event_service.GetEventProperties()
2930
print(properties)
3031
capabilities = await event_service.GetServiceCapabilities()
@@ -39,11 +40,14 @@ async def run():
3940
print(messages)
4041

4142
subscription = mycam.create_subscription_service("PullPointSubscription")
42-
# req = subscription.zeep_client.get_element("ns5:Renew")
43-
# req.TerminationTime = str(dt.datetime.now(UTC) + dt.timedelta(minutes=10))
44-
termination_time = (dt.datetime.now(UTC) + dt.timedelta(minutes=10)).isoformat()
43+
termination_time = (
44+
(dt.datetime.utcnow() + dt.timedelta(days=1))
45+
.isoformat(timespec="seconds")
46+
.replace("+00:00", "Z")
47+
)
4548
await subscription.Renew(termination_time)
4649
await subscription.Unsubscribe()
50+
await mycam.close()
4751

4852

4953
if __name__ == "__main__":

examples/rotate_image.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import asyncio
2+
23
from onvif import ONVIFCamera
34

5+
46
async def rotate_image_180():
5-
''' Rotate the image '''
7+
""" Rotate the image """
68

79
# Create the media service
8-
mycam = ONVIFCamera('192.168.0.112', 80, 'admin', '12345')
10+
mycam = ONVIFCamera("192.168.0.112", 80, "admin", "12345")
911
await mycam.update_xaddrs()
1012
media_service = mycam.create_media_service()
1113

@@ -21,18 +23,20 @@ async def rotate_image_180():
2123
video_source_configuration = configurations_list[0]
2224

2325
# Enable rotate
24-
video_source_configuration.Extension[0].Rotate[0].Mode[0] = 'OFF'
26+
video_source_configuration.Extension[0].Rotate[0].Mode[0] = "OFF"
2527

2628
# Create request type instance
27-
request = media_service.create_type('SetVideoSourceConfiguration')
29+
request = media_service.create_type("SetVideoSourceConfiguration")
2830
request.Configuration = video_source_configuration
2931

3032
# ForcePersistence is obsolete and should always be assumed to be True
3133
request.ForcePersistence = True
3234

3335
# Set the video source configuration
3436
await media_service.SetVideoSourceConfiguration(request)
37+
await mycam.close()
38+
3539

36-
if __name__ == '__main__':
40+
if __name__ == "__main__":
3741
loop = asyncio.get_event_loop()
3842
loop.run_until_complete(rotate_image_180())

0 commit comments

Comments
 (0)