Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions go2rtc_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from aiohttp import ClientError, ClientResponse, ClientSession
from aiohttp.client import _RequestOptions
from awesomeversion import AwesomeVersion
from awesomeversion import AwesomeVersion, AwesomeVersionException
from mashumaro.codecs.basic import BasicDecoder
from mashumaro.mixins.dict import DataClassDictMixin
from yarl import URL
Expand All @@ -21,7 +21,8 @@
_LOGGER = logging.getLogger(__name__)

_API_PREFIX = "/api"
_SUPPORTED_VERSION: Final = AwesomeVersion("1.9.4")
_MIN_VERSION_SUPPORTED: Final = AwesomeVersion("1.9.4")
_MIN_VERSION_UNSUPPORTED: Final = AwesomeVersion("2.0.0")


class _BaseClient:
Expand Down Expand Up @@ -145,4 +146,14 @@ def __init__(self, websession: ClientSession, server_url: str) -> None:
async def validate_server_version(self) -> bool:
"""Validate the server version is compatible."""
application_info = await self.application.get_info()
return application_info.version == _SUPPORTED_VERSION
try:
return (
_MIN_VERSION_SUPPORTED
<= application_info.version
< _MIN_VERSION_UNSUPPORTED
)
except AwesomeVersionException:
_LOGGER.exception(
"Invalid version received from server: %s", application_info.version
)
return False
2 changes: 1 addition & 1 deletion tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def test_streams_add(
("0.0.0", False),
("1.9.3", False),
("1.9.4", True),
("1.9.5", False),
("1.9.5", True),
("2.0.0", False),
("BLAH", False),
],
Expand Down