From 680417834e11f6383e19610045e9818e7adba47e Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Wed, 24 Jan 2024 22:15:52 -0500 Subject: [PATCH 01/31] Dev bump --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3accbc43..9fab4e34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "blinkpy" -version = "0.22.6" +version = "0.23.0b7" license = {text = "MIT"} description = "A Blink camera Python Library." readme = "README.rst" From 0f5c5dac31897814f2aaf59dba3a67243e8b61ef Mon Sep 17 00:00:00 2001 From: -rb <65059254+dashrb@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:15:14 -0500 Subject: [PATCH 02/31] readd battery_voltage and wifi_strength these fields do exist, --- blinkpy/camera.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blinkpy/camera.py b/blinkpy/camera.py index e0283439..078e99f7 100644 --- a/blinkpy/camera.py +++ b/blinkpy/camera.py @@ -30,6 +30,7 @@ def __init__(self, sync): self._version = None self.motion_enabled = None self.battery_level = None + self.battery_voltage = None self.clip = None # A clip remains in the recent clips list until is has # been downloaded or has been expired. @@ -59,6 +60,7 @@ def attributes(self): "temperature_calibrated": self.temperature_calibrated, "battery": self.battery, "battery_level": self.battery_level, + "battery_voltage": self.battery_voltage, "thumbnail": self.thumbnail, "video": self.clip, "recent_clips": self.recent_clips, @@ -246,14 +248,14 @@ def extract_config_info(self, config): self.serial = config.get("serial") self._version = config.get("fw_version") self.motion_enabled = config.get("enabled", "unknown") + self.battery_voltage = config.get("battery_voltage", None) self.battery_state = config.get("battery_state") or config.get("battery") + self.wifi_strength = config.get("wifi_strength") if signals := config.get("signals"): - self.wifi_strength = signals.get("wifi") self.battery_level = signals.get("battery") self.sync_signal_strength = signals.get("lfr") self.temperature = signals.get("temp") else: - self.wifi_strength = config.get("wifi_strength") self.temperature = config.get("temperature") self.product_type = config.get("type") From 1ded4eb76a70df37207bb7a9c1374b7657a09a8d Mon Sep 17 00:00:00 2001 From: -rb <65059254+dashrb@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:18:37 -0500 Subject: [PATCH 03/31] only cache mini and doorbells Note that the "full" cameras have their own URL API which must be queried for their attributes. --- blinkpy/sync_module.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blinkpy/sync_module.py b/blinkpy/sync_module.py index 860b79da..8ebbaaa2 100644 --- a/blinkpy/sync_module.py +++ b/blinkpy/sync_module.py @@ -49,10 +49,11 @@ def __init__(self, blink, network_name, network_id, camera_list): self.last_records = {} self.camera_list = camera_list self.available = False + # type_key_map is only for the mini's and the doorbells. + # Outdoor cameras have their own URL API which must be queried. self.type_key_map = { "mini": "owls", "doorbell": "doorbells", - "outdoor": "cameras", } self._names_table = {} self._local_storage = { From c7bb408b5db1ac4431beef9cad8b480a276a52ba Mon Sep 17 00:00:00 2001 From: -rb <65059254+dashrb@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:44:42 -0500 Subject: [PATCH 04/31] include tests for battery_voltage and wifi_strength --- tests/test_camera_functions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_camera_functions.py b/tests/test_camera_functions.py index f2a353ef..f90ab952 100644 --- a/tests/test_camera_functions.py +++ b/tests/test_camera_functions.py @@ -22,6 +22,8 @@ "serial": "12345678", "enabled": False, "battery_state": "ok", + "battery_voltage": 163, + "wifi_strength": -38, "signals": {"lfr": 5, "wifi": 4, "battery": 3, "temp": 68}, "thumbnail": "/thumb", } @@ -68,7 +70,8 @@ async def test_camera_update(self, mock_resp): self.assertEqual(self.camera.temperature, 68) self.assertEqual(self.camera.temperature_c, 20) self.assertEqual(self.camera.temperature_calibrated, 71) - self.assertEqual(self.camera.wifi_strength, 4) + self.assertEqual(self.camera.battery_voltage, 163) + self.assertEqual(self.camera.wifi_strength, -38) self.assertEqual( self.camera.thumbnail, "https://rest-test.immedia-semi.com/thumb.jpg" ) From 9f059a0bb6b897939c1bbaea8b29d7e87f0ec628 Mon Sep 17 00:00:00 2001 From: -rb <65059254+dashrb@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:52:01 -0500 Subject: [PATCH 05/31] update missing tests the wifi_strength key is no longer missing --- tests/test_camera_functions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_camera_functions.py b/tests/test_camera_functions.py index f90ab952..0ca75699 100644 --- a/tests/test_camera_functions.py +++ b/tests/test_camera_functions.py @@ -381,5 +381,4 @@ async def test_missing_keys(self, mock_resp): mresp.MockResponse({"foobar": 200}, 200, raw_data="foobar"), ] await self.camera.update(config, expire_clips=False, force=True) - self.assertEqual(self.camera.wifi_strength, None) self.assertEqual(self.camera.battery_level, None) From a4453531164735dcd81bc65db4a2e46dfd181b35 Mon Sep 17 00:00:00 2001 From: -rb <65059254+dashrb@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:00:53 -0500 Subject: [PATCH 06/31] Update CONTRIBUTING.rst with typo fix --- CONTRIBUTING.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 8cb6df4f..cadcef8b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -85,7 +85,7 @@ You can then run all of the tests with the following command: **Tips** -If you only want to see if you can pass the local tests, you can run ``tox -e py37`` (or whatever python version you have installed. Only ``py36``, ``py37``, and ``py38`` will be accepted). If you just want to check for style violations, you can run ``tox -e lint``. Regardless, when you submit a pull request, your code MUST pass both the unit tests, and the linters. +If you only want to see if you can pass the local tests, you can run ``tox -e py39`` (or whatever python version you have installed. Only ``py39`` through ``py312`` will be accepted). If you just want to check for style violations, you can run ``tox -e lint``. Regardless, when you submit a pull request, your code MUST pass both the unit tests, and the linters. If you need to change anything in ``requirements.txt`` for any reason, you'll want to regenerate the virtual envrionments used by ``tox`` by running with the ``-r`` flag: ``tox -r`` @@ -104,7 +104,7 @@ If your code is taking a while to develop, you may be behind the ``dev`` branch, If rebase detects conflicts, repeat the following process until all changes have been resolved: -1. ``git status`` shows you the filw with a conflict. You will need to edit that file and resolve the lines between ``<<<< | >>>>``. +1. ``git status`` shows you the file with a conflict. You will need to edit that file and resolve the lines between ``<<<< | >>>>``. 2. Add the modified file: ``git add `` or ``git add .``. 3. Continue rebase: ``git rebase --continue``. 4. Repeat until all conflicts resolved. From a50c42561fbadfe2315c05a96f83046f690e49e1 Mon Sep 17 00:00:00 2001 From: -rb <65059254+dashrb@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:08:16 -0500 Subject: [PATCH 07/31] expose battery_voltage as a property for easy access from HA --- blinkpy/camera.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/blinkpy/camera.py b/blinkpy/camera.py index 078e99f7..7498df26 100644 --- a/blinkpy/camera.py +++ b/blinkpy/camera.py @@ -30,7 +30,7 @@ def __init__(self, sync): self._version = None self.motion_enabled = None self.battery_level = None - self.battery_voltage = None + self._battery_voltage = None self.clip = None # A clip remains in the recent clips list until is has # been downloaded or has been expired. @@ -60,7 +60,7 @@ def attributes(self): "temperature_calibrated": self.temperature_calibrated, "battery": self.battery, "battery_level": self.battery_level, - "battery_voltage": self.battery_voltage, + "battery_voltage": self._battery_voltage, "thumbnail": self.thumbnail, "video": self.clip, "recent_clips": self.recent_clips, @@ -80,6 +80,11 @@ def battery(self): """Return battery as string.""" return self.battery_state + @property + def battery_voltage(self): + """Return battery voltage as a number in 100ths of volts, e.g. 165 means 1.65v.""" + return self._battery_voltage + @property def temperature_c(self): """Return temperature in celsius.""" @@ -248,7 +253,7 @@ def extract_config_info(self, config): self.serial = config.get("serial") self._version = config.get("fw_version") self.motion_enabled = config.get("enabled", "unknown") - self.battery_voltage = config.get("battery_voltage", None) + self._battery_voltage = config.get("battery_voltage", None) self.battery_state = config.get("battery_state") or config.get("battery") self.wifi_strength = config.get("wifi_strength") if signals := config.get("signals"): From 575e37a562cd89ca00ea628662417625970e58cb Mon Sep 17 00:00:00 2001 From: -rb <65059254+dashrb@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:12:14 -0500 Subject: [PATCH 08/31] shorten comment to appease lint gods --- blinkpy/camera.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blinkpy/camera.py b/blinkpy/camera.py index 7498df26..95e8c35a 100644 --- a/blinkpy/camera.py +++ b/blinkpy/camera.py @@ -82,7 +82,7 @@ def battery(self): @property def battery_voltage(self): - """Return battery voltage as a number in 100ths of volts, e.g. 165 means 1.65v.""" + """Return battery voltage as a number in 100ths of volts, so 165 = 1.65v.""" return self._battery_voltage @property From 7e6b3caab8215cd9708ac2170d6ba9231ffa1af3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:59:23 +0000 Subject: [PATCH 09/31] Bump pytest-sugar from 0.9.7 to 1.0.0 Bumps [pytest-sugar](https://github.com/Teemu/pytest-sugar) from 0.9.7 to 1.0.0. - [Release notes](https://github.com/Teemu/pytest-sugar/releases) - [Changelog](https://github.com/Teemu/pytest-sugar/blob/main/CHANGES.rst) - [Commits](https://github.com/Teemu/pytest-sugar/compare/v0.9.7...v1.0.0) --- updated-dependencies: - dependency-name: pytest-sugar dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index d03c3dbb..9c841f3f 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -4,7 +4,7 @@ build==1.0.3 coverage==7.4.0 pytest==7.4.4 pytest-cov==4.1.0 -pytest-sugar==0.9.7 +pytest-sugar==1.0.0 pytest-timeout==2.2.0 restructuredtext-lint==1.4.0 pygments==2.17.2 From 14665e7a92e66cd3c8501e92cf00c3dc7913ebbe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:59:33 +0000 Subject: [PATCH 10/31] Bump ruff from 0.1.14 to 0.2.0 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.14 to 0.2.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.1.14...v0.2.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index d03c3dbb..894ea255 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,4 @@ -ruff==0.1.14 +ruff==0.2.0 black==23.12.1 build==1.0.3 coverage==7.4.0 From 8d3801cd8c639e35442af34835a23ee5cac11962 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:08:48 +0000 Subject: [PATCH 11/31] Bump pytest from 7.4.4 to 8.0.2 Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.4.4 to 8.0.2. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/7.4.4...8.0.2) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 894ea255..9535c143 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -2,7 +2,7 @@ ruff==0.2.0 black==23.12.1 build==1.0.3 coverage==7.4.0 -pytest==7.4.4 +pytest==8.0.2 pytest-cov==4.1.0 pytest-sugar==0.9.7 pytest-timeout==2.2.0 From eacd157025799a84eba9ab36feac0bf311635bd0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 18:48:32 +0000 Subject: [PATCH 12/31] Bump ruff from 0.2.0 to 0.3.0 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.2.0 to 0.3.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.2.0...v0.3.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 894ea255..71a9b41a 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,4 @@ -ruff==0.2.0 +ruff==0.3.0 black==23.12.1 build==1.0.3 coverage==7.4.0 From 851451f202b22ddafb1b2e832c5db1028446501e Mon Sep 17 00:00:00 2001 From: mkmer Date: Wed, 6 Mar 2024 15:54:33 -0500 Subject: [PATCH 13/31] Test for none type in command function --- blinkpy/api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/blinkpy/api.py b/blinkpy/api.py index 60a177ad..942d29d8 100644 --- a/blinkpy/api.py +++ b/blinkpy/api.py @@ -514,8 +514,9 @@ async def wait_for_command(blink, json_data: dict) -> bool: _LOGGER.debug("Making GET request waiting for command") status = await request_command_status(blink, network_id, command_id) _LOGGER.debug("command status %s", status) - if status.get("status_code", 0) != 908: - return False - if status.get("complete"): - return True + if status: + if status.get("status_code", 0) != 908: + return False + if status.get("complete"): + return True await sleep(COMMAND_POLL_TIME) From d704a014cc45cbdc0fb98db027dfa2e08d8b2105 Mon Sep 17 00:00:00 2001 From: mkmer Date: Thu, 7 Mar 2024 01:37:47 +0000 Subject: [PATCH 14/31] Fix test --- tests/test_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 86edb1fd..2b3a850d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -176,9 +176,9 @@ async def test_wait_for_command(self, mock_resp): response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) assert response - mock_resp.side_effect = (COMMAND_NOT_COMPLETE, {}) - response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) - self.assertFalse(response) + # mock_resp.side_effect = (COMMAND_NOT_COMPLETE, COMMAND_NOT_COMPLETE, None) + # response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) + # self.assertFalse(response) mock_resp.side_effect = (COMMAND_COMPLETE_BAD, {}) response = await api.wait_for_command(self.blink, COMMAND_RESPONSE) From 85ab1f1d8f03a29b8ea029b30e2da57076b32046 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 18:26:18 +0000 Subject: [PATCH 15/31] Bump pytest-timeout from 2.2.0 to 2.3.1 Bumps [pytest-timeout](https://github.com/pytest-dev/pytest-timeout) from 2.2.0 to 2.3.1. - [Commits](https://github.com/pytest-dev/pytest-timeout/compare/2.2.0...2.3.1) --- updated-dependencies: - dependency-name: pytest-timeout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 753d2076..ebe3309b 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -5,7 +5,7 @@ coverage==7.4.0 pytest==8.0.2 pytest-cov==4.1.0 pytest-sugar==1.0.0 -pytest-timeout==2.2.0 +pytest-timeout==2.3.1 restructuredtext-lint==1.4.0 pygments==2.17.2 testtools>=2.4.0 From 7abee33fd50700eccadf7c914c112cb7e8078098 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:04:08 +0000 Subject: [PATCH 16/31] Bump pytest from 8.0.2 to 8.1.1 Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.0.2 to 8.1.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.0.2...8.1.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 753d2076..f4076fab 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -2,7 +2,7 @@ ruff==0.3.0 black==23.12.1 build==1.0.3 coverage==7.4.0 -pytest==8.0.2 +pytest==8.1.1 pytest-cov==4.1.0 pytest-sugar==1.0.0 pytest-timeout==2.2.0 From 5e73b3705c1ef90a95cea4de025706f68da67003 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:27:53 +0000 Subject: [PATCH 17/31] Bump pytest-cov from 4.1.0 to 5.0.0 Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 4.1.0 to 5.0.0. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v4.1.0...v5.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 753d2076..b4bb9b8b 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -3,7 +3,7 @@ black==23.12.1 build==1.0.3 coverage==7.4.0 pytest==8.0.2 -pytest-cov==4.1.0 +pytest-cov==5.0.0 pytest-sugar==1.0.0 pytest-timeout==2.2.0 restructuredtext-lint==1.4.0 From 381123556ca77b2205115db220b962bfeed1b585 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 12 Apr 2024 11:47:40 +0000 Subject: [PATCH 18/31] TIdy up the aiofiles imports fix warnings in pyproect.toml --- blinkpy/blinkpy.py | 5 ++--- blinkpy/helpers/util.py | 6 +++--- blinkpy/sync_module.py | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/blinkpy/blinkpy.py b/blinkpy/blinkpy.py index 3e681517..974f79ca 100644 --- a/blinkpy/blinkpy.py +++ b/blinkpy/blinkpy.py @@ -16,8 +16,7 @@ import time import logging import datetime -import aiofiles -from aiofiles import ospath +from aiofiles import ospath, open from requests.structures import CaseInsensitiveDict from dateutil.parser import parse @@ -419,7 +418,7 @@ async def _parse_downloaded_items(self, result, camera, path, delay, debug): continue response = await self.do_http_get(address) - async with aiofiles.open(filename, "wb") as vidfile: + async with open(filename, "wb") as vidfile: await vidfile.write(await response.read()) _LOGGER.info("Downloaded video to %s", filename) diff --git a/blinkpy/helpers/util.py b/blinkpy/helpers/util.py index 88838836..6c174269 100644 --- a/blinkpy/helpers/util.py +++ b/blinkpy/helpers/util.py @@ -6,7 +6,7 @@ import time import secrets import re -import aiofiles +from aiofiles import open from asyncio import sleep from calendar import timegm from functools import wraps @@ -21,7 +21,7 @@ async def json_load(file_name): """Load json credentials from file.""" try: - async with aiofiles.open(file_name, "r") as json_file: + async with open(file_name, "r") as json_file: test = await json_file.read() data = json.loads(test) return data @@ -34,7 +34,7 @@ async def json_load(file_name): async def json_save(data, file_name): """Save data to file location.""" - async with aiofiles.open(file_name, "w") as json_file: + async with open(file_name, "w") as json_file: await json_file.write(json.dumps(data, indent=4)) diff --git a/blinkpy/sync_module.py b/blinkpy/sync_module.py index 8ebbaaa2..0de63292 100644 --- a/blinkpy/sync_module.py +++ b/blinkpy/sync_module.py @@ -4,7 +4,7 @@ import datetime import traceback import asyncio -import aiofiles +from aiofiles import open from sortedcontainers import SortedSet from requests.structures import CaseInsensitiveDict from blinkpy import api @@ -732,7 +732,7 @@ async def download_video(self, blink, file_name, max_retries=4) -> bool: url = blink.urls.base_url + self.url() video = await api.http_get(blink, url, json=False) if video.status == 200: - async with aiofiles.open(file_name, "wb") as vidfile: + async with open(file_name, "wb") as vidfile: await vidfile.write(await video.read()) # download the video return True seconds = backoff_seconds(retry=retry, default_time=3) From c7bb530515aff8fafffc9fe6c155de945cb84c75 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 12 Apr 2024 11:47:53 +0000 Subject: [PATCH 19/31] Fix pyproject.toml warnings --- pyproject.toml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9fab4e34..a8885ec2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ include-package-data = true include = ["blinkpy*"] [tool.ruff] -select = [ +lint.select = [ "C", # complexity "D", # docstrings "E", # pydocstyle @@ -54,11 +54,11 @@ select = [ "Q000", # Double quotes found but single quotes preferred "SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys() "TRY004", # Prefer TypeError exception for invalid type - "TRY200", # Use raise from to specify exception cause + "B904", # Use raise from to specify exception cause "UP", # pyupgrade "W", # pycodestyle ] -ignore = [ +lint.ignore = [ "D202", # No blank lines allowed after function docstring "D203", # 1 blank line required before class docstring "D212", # Multi-line docstring summary should start at the first line @@ -86,10 +86,9 @@ ignore = [ line-length = 88 -target-version = "py311" +target-version = "py312" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] - -[tool.ruff.mccabe] -max-complexity = 25 +[tool.ruff.lint.mccabe] + max-complexity = 25 From e769d54f2eecb0e77df80bf6fbd43d8da735369e Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 12 Apr 2024 12:42:23 +0000 Subject: [PATCH 20/31] Update to node20 --- .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b1887704..4ffae839 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -33,7 +33,7 @@ jobs: run: | tox -r -e cov - name: Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} flags: unittests From 49744c0742e1de821ecbcb61cb3d76d6538be712 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 12 Apr 2024 13:27:13 +0000 Subject: [PATCH 21/31] Fix lint errors don't redefine builtin functions --- blinkpy/blinkpy.py | 7 +++---- blinkpy/helpers/util.py | 6 +++--- blinkpy/sync_module.py | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/blinkpy/blinkpy.py b/blinkpy/blinkpy.py index 974f79ca..027e2fff 100644 --- a/blinkpy/blinkpy.py +++ b/blinkpy/blinkpy.py @@ -16,8 +16,7 @@ import time import logging import datetime -from aiofiles import ospath, open - +import aiofiles from requests.structures import CaseInsensitiveDict from dateutil.parser import parse from slugify import slugify @@ -413,12 +412,12 @@ async def _parse_downloaded_items(self, result, camera, path, delay, debug): filename = os.path.join(path, filename) if not debug: - if await ospath.isfile(filename): + if await aiofiles.ospath.isfile(filename): _LOGGER.info("%s already exists, skipping...", filename) continue response = await self.do_http_get(address) - async with open(filename, "wb") as vidfile: + async with aiofiles.open(filename, "wb") as vidfile: await vidfile.write(await response.read()) _LOGGER.info("Downloaded video to %s", filename) diff --git a/blinkpy/helpers/util.py b/blinkpy/helpers/util.py index 6c174269..524ab175 100644 --- a/blinkpy/helpers/util.py +++ b/blinkpy/helpers/util.py @@ -6,11 +6,11 @@ import time import secrets import re -from aiofiles import open from asyncio import sleep from calendar import timegm from functools import wraps from getpass import getpass +import aiofiles import dateutil.parser from blinkpy.helpers import constants as const @@ -21,7 +21,7 @@ async def json_load(file_name): """Load json credentials from file.""" try: - async with open(file_name, "r") as json_file: + async with aiofiles.open(file_name, "r") as json_file: test = await json_file.read() data = json.loads(test) return data @@ -34,7 +34,7 @@ async def json_load(file_name): async def json_save(data, file_name): """Save data to file location.""" - async with open(file_name, "w") as json_file: + async with aiofiles.open(file_name, "w") as json_file: await json_file.write(json.dumps(data, indent=4)) diff --git a/blinkpy/sync_module.py b/blinkpy/sync_module.py index 0de63292..8ebbaaa2 100644 --- a/blinkpy/sync_module.py +++ b/blinkpy/sync_module.py @@ -4,7 +4,7 @@ import datetime import traceback import asyncio -from aiofiles import open +import aiofiles from sortedcontainers import SortedSet from requests.structures import CaseInsensitiveDict from blinkpy import api @@ -732,7 +732,7 @@ async def download_video(self, blink, file_name, max_retries=4) -> bool: url = blink.urls.base_url + self.url() video = await api.http_get(blink, url, json=False) if video.status == 200: - async with open(file_name, "wb") as vidfile: + async with aiofiles.open(file_name, "wb") as vidfile: await vidfile.write(await video.read()) # download the video return True seconds = backoff_seconds(retry=retry, default_time=3) From 0a4a08b08f054d5ee8a715e95016cc97924ab8eb Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Fri, 12 Apr 2024 10:30:26 -0400 Subject: [PATCH 22/31] Update coverage.yml --- .github/workflows/coverage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4ffae839..9e9a34dd 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -34,8 +34,9 @@ jobs: tox -r -e cov - name: Codecov uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: - token: ${{ secrets.CODECOV_TOKEN }} flags: unittests file: ./coverage.xml name: blinkpy From 5b38e5de896d62e2f0949221aefec0a3c857344c Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Fri, 12 Apr 2024 10:42:04 -0400 Subject: [PATCH 23/31] Update codecov.yml --- codecov.yml | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/codecov.yml b/codecov.yml index 42f2739b..b96624fa 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,15 +1,18 @@ -codecov: - branch: dev -coverage: - status: - project: - default: - target: 80% - threshold: 2% - patch: - default: - target: 60% - threshold: 5% - -comment: true -require_ci_to_pass: yes +codecov: + branch: dev + bot: "codecov-io" + max_report_age: 24 + disable_default_path_fixes: no + require_ci_to_pass: yes + notify: + wait_for_ci: yes + + coverage: + precision: 1 + round: down + range: "85..100" + status: + project: + default: + target: auto + threshold: 5% From e35596997526290b1fbf08274a8d8ad22aea7295 Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Fri, 12 Apr 2024 10:51:18 -0400 Subject: [PATCH 24/31] Update codecov.yml --- codecov.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codecov.yml b/codecov.yml index b96624fa..71256a18 100644 --- a/codecov.yml +++ b/codecov.yml @@ -5,8 +5,7 @@ codecov: disable_default_path_fixes: no require_ci_to_pass: yes notify: - wait_for_ci: yes - + wait_for_ci: yes coverage: precision: 1 round: down From 7e0f7b7b3df06f0a3d1c926c15d6c9a3caa38d58 Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Fri, 12 Apr 2024 10:58:06 -0400 Subject: [PATCH 25/31] Update codecov.yml --- codecov.yml | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/codecov.yml b/codecov.yml index 71256a18..bc87e9c5 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,17 +1,18 @@ -codecov: - branch: dev - bot: "codecov-io" - max_report_age: 24 - disable_default_path_fixes: no - require_ci_to_pass: yes - notify: - wait_for_ci: yes - coverage: - precision: 1 - round: down - range: "85..100" - status: - project: - default: - target: auto - threshold: 5% +codecov: + branch: dev + bot: codecov-io + max_report_age: 24 + disable_default_path_fixes: no + require_ci_to_pass: yes + notify: + wait_for_ci: yes +coverage: + precision: 1 + round: down + range: 85..100 + status: + project: + default: + target: auto + threshold: 5% + From e7c7aad4bd60b1c0058027fa8a33d33cec3e4f42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:17:44 +0000 Subject: [PATCH 26/31] Bump ruff from 0.3.0 to 0.3.7 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.3.0 to 0.3.7. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.3.0...v0.3.7) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 1133eb12..89be1694 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,4 @@ -ruff==0.3.0 +ruff==0.3.7 black==23.12.1 build==1.0.3 coverage==7.4.0 From ffd72977fcf17323c85d32cc4623b52d174682d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:18:03 +0000 Subject: [PATCH 27/31] Bump coverage from 7.4.0 to 7.4.4 Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.4.0 to 7.4.4. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/7.4.0...7.4.4) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 3cd09ea4..e1a3870e 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,7 +1,7 @@ ruff==0.3.0 black==23.12.1 build==1.0.3 -coverage==7.4.0 +coverage==7.4.4 pytest==8.1.1 pytest-cov==5.0.0 pytest-sugar==1.0.0 From 9a7d9fc3908da4852966638137aade6a2bf8fd73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:18:07 +0000 Subject: [PATCH 28/31] Bump build from 1.0.3 to 1.2.1 Bumps [build](https://github.com/pypa/build) from 1.0.3 to 1.2.1. - [Release notes](https://github.com/pypa/build/releases) - [Changelog](https://github.com/pypa/build/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pypa/build/compare/1.0.3...1.2.1) --- updated-dependencies: - dependency-name: build dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 3cd09ea4..77065696 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,6 +1,6 @@ ruff==0.3.0 black==23.12.1 -build==1.0.3 +build==1.2.1 coverage==7.4.0 pytest==8.1.1 pytest-cov==5.0.0 From aea5d771d42c3e8ce6904a805b26a3065deace02 Mon Sep 17 00:00:00 2001 From: mkmer Date: Fri, 12 Apr 2024 17:43:23 +0000 Subject: [PATCH 29/31] Reformat to enable black 24.3.0 --- blinkapp/blinkapp.py | 1 + blinkpy/auth.py | 1 + blinkpy/camera.py | 1 + blinkpy/sync_module.py | 1 + requirements_test.txt | 2 +- tests/mock_responses.py | 1 + tests/test_blink_functions.py | 1 + tests/test_blinkpy.py | 21 ++++++++++++--------- tests/test_doorbell_as_sync.py | 1 + tests/test_errors.py | 1 + tests/test_mini_as_sync.py | 1 + tests/test_sync_module.py | 3 ++- 12 files changed, 24 insertions(+), 11 deletions(-) diff --git a/blinkapp/blinkapp.py b/blinkapp/blinkapp.py index f0bd65df..840ff58d 100644 --- a/blinkapp/blinkapp.py +++ b/blinkapp/blinkapp.py @@ -1,4 +1,5 @@ """Script to run blinkpy as an blinkapp.""" + from os import environ import asyncio from datetime import datetime, timedelta diff --git a/blinkpy/auth.py b/blinkpy/auth.py index 250a081a..78db9d9a 100644 --- a/blinkpy/auth.py +++ b/blinkpy/auth.py @@ -1,4 +1,5 @@ """Login handler for blink.""" + import logging from aiohttp import ( ClientSession, diff --git a/blinkpy/camera.py b/blinkpy/camera.py index 95e8c35a..39a134fb 100644 --- a/blinkpy/camera.py +++ b/blinkpy/camera.py @@ -1,4 +1,5 @@ """Defines Blink cameras.""" + import copy import string import os diff --git a/blinkpy/sync_module.py b/blinkpy/sync_module.py index 8ebbaaa2..63b6aef6 100644 --- a/blinkpy/sync_module.py +++ b/blinkpy/sync_module.py @@ -1,4 +1,5 @@ """Defines a sync module for Blink.""" + import logging import string import datetime diff --git a/requirements_test.txt b/requirements_test.txt index efb3c729..a68f87f1 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,5 +1,5 @@ ruff==0.3.7 -black==23.12.1 +black==24.3.0 build==1.2.1 coverage==7.4.0 pytest==8.1.1 diff --git a/tests/mock_responses.py b/tests/mock_responses.py index 43a6d608..96c953bb 100644 --- a/tests/mock_responses.py +++ b/tests/mock_responses.py @@ -1,4 +1,5 @@ """Simple mock responses definitions.""" + from unittest import mock diff --git a/tests/test_blink_functions.py b/tests/test_blink_functions.py index afd62a2f..eedebfd3 100644 --- a/tests/test_blink_functions.py +++ b/tests/test_blink_functions.py @@ -1,4 +1,5 @@ """Tests camera and system functions.""" + from unittest import mock, IsolatedAsyncioTestCase import time import random diff --git a/tests/test_blinkpy.py b/tests/test_blinkpy.py index 6745d6c6..9c01eb04 100644 --- a/tests/test_blinkpy.py +++ b/tests/test_blinkpy.py @@ -69,9 +69,12 @@ async def test_throttle(self, mock_time): self.assertEqual(self.blink.last_refresh, None) self.assertEqual(self.blink.check_if_ok_to_update(), True) self.assertEqual(self.blink.last_refresh, None) - with mock.patch( - "blinkpy.sync_module.BlinkSyncModule.refresh", return_value=True - ), mock.patch("blinkpy.blinkpy.Blink.get_homescreen", return_value=True): + with ( + mock.patch( + "blinkpy.sync_module.BlinkSyncModule.refresh", return_value=True + ), + mock.patch("blinkpy.blinkpy.Blink.get_homescreen", return_value=True), + ): await self.blink.refresh(force=True) self.assertEqual(self.blink.last_refresh, now) @@ -81,12 +84,12 @@ async def test_throttle(self, mock_time): async def test_not_available_refresh(self): """Check that setup_post_verify executes on refresh when not avialable.""" self.blink.available = False - with mock.patch( - "blinkpy.sync_module.BlinkSyncModule.refresh", return_value=True - ), mock.patch( - "blinkpy.blinkpy.Blink.get_homescreen", return_value=True - ), mock.patch( - "blinkpy.blinkpy.Blink.setup_post_verify", return_value=True + with ( + mock.patch( + "blinkpy.sync_module.BlinkSyncModule.refresh", return_value=True + ), + mock.patch("blinkpy.blinkpy.Blink.get_homescreen", return_value=True), + mock.patch("blinkpy.blinkpy.Blink.setup_post_verify", return_value=True), ): self.assertTrue(await self.blink.refresh(force=True)) with mock.patch("time.time", return_value=time.time() + 4): diff --git a/tests/test_doorbell_as_sync.py b/tests/test_doorbell_as_sync.py index 154c0727..d4ecd6a6 100644 --- a/tests/test_doorbell_as_sync.py +++ b/tests/test_doorbell_as_sync.py @@ -1,4 +1,5 @@ """Tests camera and system functions.""" + from unittest import mock from unittest import IsolatedAsyncioTestCase import pytest diff --git a/tests/test_errors.py b/tests/test_errors.py index 356b0a4e..83985b91 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -1,4 +1,5 @@ """Test blink Utils errors.""" + import unittest from blinkpy.helpers.errors import ( USERNAME, diff --git a/tests/test_mini_as_sync.py b/tests/test_mini_as_sync.py index 5c6f3e68..538f6648 100644 --- a/tests/test_mini_as_sync.py +++ b/tests/test_mini_as_sync.py @@ -1,4 +1,5 @@ """Tests camera and system functions.""" + from unittest import mock from unittest import IsolatedAsyncioTestCase import pytest diff --git a/tests/test_sync_module.py b/tests/test_sync_module.py index 0e41b12c..a1c81cbf 100644 --- a/tests/test_sync_module.py +++ b/tests/test_sync_module.py @@ -1,4 +1,5 @@ """Tests camera and system functions.""" + import datetime import logging from unittest import IsolatedAsyncioTestCase @@ -31,7 +32,7 @@ def setUp(self): self.blink: Blink = Blink(motion_interval=0, session=mock.AsyncMock()) self.blink.last_refresh = 0 self.blink.urls = BlinkURLHandler("test") - self.blink.sync["test"]: (BlinkSyncModule) = BlinkSyncModule( + self.blink.sync["test"]: BlinkSyncModule = BlinkSyncModule( self.blink, "test", "1234", [] ) self.blink.sync["test"].network_info = {"network": {"armed": True}} From 705c143a9028fcd4ccc57e4b08f09e7acd3b9272 Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Mon, 15 Apr 2024 11:13:57 -0400 Subject: [PATCH 30/31] Update CHANGES.rst --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e48065ed..35dc28cc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,11 @@ Changelog A list of changes between each release +0.22.7 (2024-04-15) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +See release notes: (`0.22.7 `__) + 0.22.6 (2024-01-24) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From e9048d6af26d01a4e838b8b68a6a2d1f87ae4328 Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Mon, 15 Apr 2024 11:15:21 -0400 Subject: [PATCH 31/31] Version bump --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a8885ec2..48f6f5d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "blinkpy" -version = "0.23.0b7" +version = "0.22.7" license = {text = "MIT"} description = "A Blink camera Python Library." readme = "README.rst"