Skip to content

Commit eaf3d1e

Browse files
authored
Add a supported version range instead of a single version (#13)
1 parent 510ef45 commit eaf3d1e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

go2rtc_client/rest.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from aiohttp import ClientError, ClientResponse, ClientSession
99
from aiohttp.client import _RequestOptions
10-
from awesomeversion import AwesomeVersion
10+
from awesomeversion import AwesomeVersion, AwesomeVersionException
1111
from mashumaro.codecs.basic import BasicDecoder
1212
from mashumaro.mixins.dict import DataClassDictMixin
1313
from yarl import URL
@@ -21,7 +21,8 @@
2121
_LOGGER = logging.getLogger(__name__)
2222

2323
_API_PREFIX = "/api"
24-
_SUPPORTED_VERSION: Final = AwesomeVersion("1.9.4")
24+
_MIN_VERSION_SUPPORTED: Final = AwesomeVersion("1.9.4")
25+
_MIN_VERSION_UNSUPPORTED: Final = AwesomeVersion("2.0.0")
2526

2627

2728
class _BaseClient:
@@ -145,4 +146,14 @@ def __init__(self, websession: ClientSession, server_url: str) -> None:
145146
async def validate_server_version(self) -> bool:
146147
"""Validate the server version is compatible."""
147148
application_info = await self.application.get_info()
148-
return application_info.version == _SUPPORTED_VERSION
149+
try:
150+
return (
151+
_MIN_VERSION_SUPPORTED
152+
<= application_info.version
153+
< _MIN_VERSION_UNSUPPORTED
154+
)
155+
except AwesomeVersionException:
156+
_LOGGER.exception(
157+
"Invalid version received from server: %s", application_info.version
158+
)
159+
return False

tests/test_rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async def test_streams_add(
100100
("0.0.0", False),
101101
("1.9.3", False),
102102
("1.9.4", True),
103-
("1.9.5", False),
103+
("1.9.5", True),
104104
("2.0.0", False),
105105
("BLAH", False),
106106
],

0 commit comments

Comments
 (0)