Add async APIs throughout#193
Merged
flacjacket merged 1 commit intotchellomello:masterfrom Sep 16, 2021
Merged
Conversation
Add a full suite of API functions that are able to use asyncio-based calls. The async http requests are provided through httpx, which is able to provide both basic auth and digest auth through its async client. Using the async functions and the new async keywords requires removing Python 3.6 support. In particular, this allows us to use async and await keywoards. Setting up the async APIs unfortunately requires a rough doubling of the API to add both sync and async code to get functions of the appropriate color. Where there is a reasonable amount of non-I/O logic, this is refactored out into common functions.
houndci-bot
reviewed
Sep 16, 2021
| """Return if any audio stream enabled on the given channel.""" | ||
| is_enabled = utils.extract_audio_video_enabled( | ||
| f"{stream}Format[{stream_type}].Audio", | ||
| await self.async_encode_media, # type: ignore[attr-defined] |
There was a problem hiding this comment.
undefined name 'attr'
undefined name 'defined'
undefined name 'ignore'
| if key == "data": | ||
| value = { | ||
| data_key.replace('"', ""): data_value.replace('"', "") | ||
| for data_key, data_value in _REG_PARSE_MALFORMED_JSON.findall( |
There was a problem hiding this comment.
line too long (82 > 79 characters)
| ) | ||
| return ret.content.decode() | ||
|
|
||
| async def async_log_show( |
| return ret.content.decode() | ||
|
|
||
| async def async_ptz_presets_list(self, *, channel: int = 0) -> str: | ||
| ret = await self.async_command( |
| return await self._async_get_config("Record") | ||
|
|
||
| async def async_set_record_config(self, rec_opt: str) -> str: | ||
| ret = await self.async_command( |
| 1-Extra Stream 1 (Sub Stream) | ||
| 2-Extra Stream 2 (Sub Stream) | ||
| """ | ||
| return self._build_rtsp_url(self.rtsp_config, channel, typeno) # type: ignore[attr-defined] |
There was a problem hiding this comment.
line too long (100 > 79 characters)
undefined name 'attr'
undefined name 'defined'
undefined name 'ignore'
|
|
||
| @property | ||
| async def async_storage_device_info(self) -> str: | ||
| ret = await self.async_command( |
|
|
||
| return self._user_manager(cmd) | ||
|
|
||
| async def async_modify_user( |
|
|
||
|
|
||
| def to_unit(value: Union[str, int, float], unit: str = "B") -> Tuple[str, str]: | ||
| def to_unit( |
|
|
||
| @property | ||
| async def async_video_max_extra_streams(self) -> int: | ||
| ret = await self._async_magic_box( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a full suite of API functions that are able to use asyncio-based
calls. The async http requests are provided through httpx, which is
able to provide both basic auth and digest auth through its async
client. Using the async functions and the new async keywords requires
removing Python 3.6 support. In particular, this allows us to use async
and await keywoards. Setting up the async APIs unfortunately requires a
rough doubling of the API to add both sync and async code to get
functions of the appropriate color. Where there is a reasonable amount
of non-I/O logic, this is refactored out into common functions.