Skip to content

Commit

Permalink
Version 4.2.1
Browse files Browse the repository at this point in the history
- fix self.base not set when a ClientSession is given as a parameter
- fix format
  • Loading branch information
autinerd committed Jan 12, 2024
1 parent 842a67e commit a576bde
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion openwebif/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Top-level package for openwebif."""

__version__ = "4.2.0"
__version__ = "4.2.1"
17 changes: 12 additions & 5 deletions openwebif/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from re import sub
from time import time
from typing import Any, Mapping
from typing import Any, Mapping, cast

import aiohttp
from yarl import URL
Expand Down Expand Up @@ -42,6 +42,7 @@ def enable_logging() -> None:
logging.basicConfig(level=logging.INFO)


# pylint: disable=too-many-instance-attributes
@dataclass
class OpenWebIfServiceEvent:
"""Represent a OpenWebIf service event."""
Expand All @@ -59,6 +60,7 @@ class OpenWebIfServiceEvent:
station: str | None = None


# pylint: disable=too-many-instance-attributes
@dataclass
class OpenWebIfStatus:
"""Repesent a OpenWebIf status."""
Expand All @@ -74,6 +76,7 @@ class OpenWebIfStatus:
is_recording_playback: bool | None = False


# pylint: disable=too-many-instance-attributes, disable=too-many-public-methods
class OpenWebIfDevice:
"""Represent a OpenWebIf client device."""

Expand Down Expand Up @@ -122,6 +125,7 @@ def __init__(
)
self._session = aiohttp.ClientSession(self.base)
elif isinstance(host, aiohttp.ClientSession):
self.base = cast(URL, host._base_url)
self._session = host
self.turn_off_to_deep = turn_off_to_deep
self.source_bouquet = source_bouquet
Expand Down Expand Up @@ -273,7 +277,12 @@ def get_screen_grab_url(
:return: The URL for the screen grab
"""
return self.base.with_path(PATH_GRAB).with_query(
{"mode": mode.value, "format": file_format.value, "t": int(time()), "r": resolution}
{
"mode": mode.value,
"format": file_format.value,
"t": int(time()),
"r": resolution,
}
)

async def turn_off(self) -> bool:
Expand Down Expand Up @@ -446,9 +455,7 @@ async def get_bouquet_sources(self, bouquet: str | None = None) -> dict[str, Any
# load first bouquet
all_bouquets = await self.get_all_bouquets()
if not all_bouquets:
_LOGGER.debug(
"%s get_all_bouquets: No bouquets were found.", self.base
)
_LOGGER.debug("%s get_all_bouquets: No bouquets were found.", self.base)
return sources

if "bouquets" in all_bouquets:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_openwebifpy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests the api."""
# pylint: disable=protected-access
import pytest

import openwebif.api
Expand All @@ -9,7 +8,7 @@ def test_create() -> None:
"""Test creating a new device."""
# Bogus config
with pytest.raises(TypeError):
openwebif.api.OpenWebIfDevice()
openwebif.api.OpenWebIfDevice() # type: ignore[call-arg]


def test_get_picon_name() -> None:
Expand Down

0 comments on commit a576bde

Please sign in to comment.