Skip to content

Commit

Permalink
Fix subscribing to all services
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenLooman committed May 28, 2024
1 parent cd4d884 commit 6db8002
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.5.0'
rev: 'v4.6.0'
hooks:
- id: check-ast
- id: check-case-conflict
Expand All @@ -12,15 +12,15 @@ repos:
- id: trailing-whitespace
exclude: setup.cfg
- repo: https://github.com/psf/black
rev: '23.11.0'
rev: '24.4.2'
hooks:
- id: black
args:
- --safe
- --quiet
files: ^(async_upnp_client|tests)/.+\.py$
- repo: https://github.com/codespell-project/codespell
rev: 'v2.2.6'
rev: 'v2.3.0'
hooks:
- id: codespell
args:
Expand All @@ -29,15 +29,15 @@ repos:
exclude_types: [csv, json]
files: ^(async_upnp_client|tests)/.+\.py$
- repo: https://github.com/PyCQA/flake8
rev: '6.1.0'
rev: '7.0.0'
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings~=1.7.0
- pydocstyle~=6.3.0
files: ^(async_upnp_client|tests)/.+\.py$
- repo: https://github.com/PyCQA/pylint
rev: 'v3.0.2'
rev: 'v3.2.2'
hooks:
- id: pylint
additional_dependencies:
Expand All @@ -50,14 +50,14 @@ repos:
- pytest-aiohttp~=1.0.5
files: ^(async_upnp_client|tests)/.+\.py$
- repo: https://github.com/PyCQA/isort
rev: '5.12.0'
rev: '5.13.2'
hooks:
- id: isort
args:
- --profile=black
files: ^(async_upnp_client|tests)/.+\.py$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.7.0'
rev: 'v1.10.0'
hooks:
- id: mypy
args: [--ignore-missing-imports]
Expand Down
2 changes: 1 addition & 1 deletion async_upnp_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ async def subscribe(description_url: str, service_names: Any) -> None:

# gather all wanted services
if "*" in service_names:
service_names = device.services.keys()
service_names = [service.service_type for service in device.all_services]

services = []
for service_name in service_names:
Expand Down
2 changes: 1 addition & 1 deletion async_upnp_client/profiles/dlna.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _lower_split_commas(input_: str) -> Set[str]:
def _cached_from_xml_string(
xml: str,
) -> List[Union[didl_lite.DidlObject, didl_lite.Descriptor]]:
return didl_lite.from_xml_string(xml, strict=False)
return didl_lite.from_xml_string(xml, strict=False) # type: ignore


class ConnectionManagerMixin(UpnpProfileDevice):
Expand Down
7 changes: 3 additions & 4 deletions async_upnp_client/profiles/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ def is_profile_device(cls, device: UpnpDevice) -> bool:

# Check that every service required by the subclass is declared by the device
device_service_ids = {
service.service_id for service in profile_device.services.values()
service.service_id for service in profile_device.all_services
}

if not cls.SERVICE_IDS.issubset(device_service_ids):
return False

Expand Down Expand Up @@ -347,7 +346,7 @@ async def async_subscribe_services(
await self._async_resubscribe_services(now)
else:
# Subscribe to services we are interested in
for service in self.profile_device.services.values():
for service in self.profile_device.all_services:
if not self._interesting_service(service):
continue

Expand Down Expand Up @@ -399,7 +398,7 @@ async def _async_unsubscribe_service(self, sid: str) -> None:

async def async_unsubscribe_services(self) -> None:
"""Unsubscribe from all of our subscribed services."""
# Delete list of subscriptions and cancel renewal before unsubcribing
# Delete list of subscriptions and cancel renewal before unsubscribing
# to avoid unsub-resub race.
sids = list(self._subscriptions)
self._subscriptions.clear()
Expand Down

0 comments on commit 6db8002

Please sign in to comment.