From 25b7d69989eca88673dc7196210c56afd7885b0d Mon Sep 17 00:00:00 2001 From: Tom de Brouwer Date: Tue, 3 Dec 2019 20:29:41 +0100 Subject: [PATCH 1/2] Some fixes found during HA integration of the library --- toonapilib/toonapilib.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/toonapilib/toonapilib.py b/toonapilib/toonapilib.py index 067978d..f8d29a6 100755 --- a/toonapilib/toonapilib.py +++ b/toonapilib/toonapilib.py @@ -33,7 +33,6 @@ import logging -import backoff import coloredlogs from cachetools import TTLCache, cached from requests import Session @@ -170,7 +169,6 @@ def _reset(self): @property @cached(STATE_CACHE) - @backoff.on_exception(backoff.expo, IncompleteStatus) def status(self): """The status of toon, cached for 300 seconds.""" url = '{api_url}/status'.format(api_url=self._api_url) @@ -178,7 +176,7 @@ def status(self): if response.status_code == 202: self._logger.debug('Response accepted but no data yet, ' 'trying one more time...') - response = self._session.get(url) + response = self._session.get(url) try: data = response.json() except ValueError: @@ -188,7 +186,6 @@ def status(self): @property @cached(THERMOSTAT_STATE_CACHE) - @backoff.on_exception(backoff.expo, IncompleteStatus) def thermostat_states(self): """The thermostat states of toon, cached for 1 hour.""" url = '{api_url}/thermostat/states'.format(api_url=self._api_url) @@ -196,7 +193,7 @@ def thermostat_states(self): if response.status_code == 202: self._logger.debug('Response accepted but no data yet, ' 'trying one more time...') - response = self._session.get(url) + response = self._session.get(url) try: states = response.json().get('state', []) except ValueError: @@ -279,7 +276,6 @@ def get_smartplug_by_name(self, name): return next((plug for plug in self.smartplugs if plug.name.lower() == name.lower()), None) - @backoff.on_exception(backoff.expo, IncompleteStatus) def _get_status_value(self, value): try: output = self.status[value] From fa4deab334eb05876a3c4ab61c9f1d57b65ca1b1 Mon Sep 17 00:00:00 2001 From: Tom de Brouwer Date: Tue, 3 Dec 2019 20:37:02 +0100 Subject: [PATCH 2/2] Remove backoff from pip / requirement file --- Pipfile | 1 - Pipfile.lock | 8 -------- requirements.txt | 3 +-- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Pipfile b/Pipfile index a8fb957..5791d06 100644 --- a/Pipfile +++ b/Pipfile @@ -28,4 +28,3 @@ coloredlogs = "~=10.0" requests = "~=2.22.0" cachetools = "~=3.1.1" dateparser = "~=0.7.1" -backoff = "~=1.9.2" diff --git a/Pipfile.lock b/Pipfile.lock index 2c6d37c..f00d02c 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -14,14 +14,6 @@ ] }, "default": { - "backoff": { - "hashes": [ - "sha256:76224b65f1808fd61dc14129e3e9de50cb1f7efaef608b657f7b108863ee15a7", - "sha256:794e9765eb4acb5014c7e1e1fc4f69abc4d176a7c2b6753b8dae2f2e69af4df9" - ], - "index": "pypi", - "version": "==1.9.2" - }, "cachetools": { "hashes": [ "sha256:428266a1c0d36dc5aca63a2d7c5942e88c2c898d72139fca0e97fdd2380517ae", diff --git a/requirements.txt b/requirements.txt index 6f9ca3d..4d76b51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,5 +10,4 @@ coloredlogs~=10.0 requests~=2.22.0 cachetools~=3.1.1 -dateparser~=0.7.2 -backoff~=1.9.2 \ No newline at end of file +dateparser~=0.7.2 \ No newline at end of file