Compare commits

...
Author SHA1 Message Date
Kevin FronczakandGitHub 19c9178db7 Merge pull request #223 from fronzbot/fronzbot-patch-1
Update README.rst
2020-04-15 11:51:55 -04:00
Kevin FronczakandGitHub 2ebf2db04d Update README.rst 2020-04-15 11:47:38 -04:00
Kevin FronczakandGitHub 26de89c1b9 Merge pull request #222 from fronzbot/no-camera-enabled-bug
Log response code and message if not trying to re-authorize
2020-04-15 11:26:14 -04:00
Kevin Fronczak 8f68aad238 Create codecov.yml for confugration 2020-04-15 11:21:38 -04:00
Kevin Fronczak 7b586e2947 Log response code and message if not trying to re-authorize (fixes #213) 2020-04-15 11:10:13 -04:00
Kevin FronczakandGitHub 800ddeaf7a Dev version bump 2020-04-15 11:09:46 -04:00
7 changed files with 28 additions and 8 deletions
+2 -2
View File
@@ -68,8 +68,8 @@ The credential file must be json formatted with a ``username`` and ``password``
.. code:: json .. code:: json
{ {
'username': 'YOUR USER NAME', "username": "YOUR USER NAME",
'password': 'YOUR PASSWORD' "password": "YOUR PASSWORD"
} }
Cameras are instantiated as individual ``BlinkCamera`` classes within a ``BlinkSyncModule`` instance. All of your sync modules are stored within the ``Blink.sync`` dictionary and can be accessed using the name of the sync module as the key (this is the name of your sync module in the Blink App). Cameras are instantiated as individual ``BlinkCamera`` classes within a ``BlinkSyncModule`` instance. All of your sync modules are stored within the ``Blink.sync`` dictionary and can be accessed using the name of the sync module as the key (this is the name of your sync module in the Blink App).
+1 -1
View File
@@ -4,7 +4,7 @@ import os
MAJOR_VERSION = 0 MAJOR_VERSION = 0
MINOR_VERSION = 14 MINOR_VERSION = 14
PATCH_VERSION = '3.dev0' PATCH_VERSION = '3.dev1'
__version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION) __version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
+2
View File
@@ -11,3 +11,5 @@ AUTH_TOKEN = (
"Authentication header incorrect. Are you sure you received your token?" "Authentication header incorrect. Are you sure you received your token?"
) )
REQUEST = (4, "Cannot perform request (get/post type incorrect)") REQUEST = (4, "Cannot perform request (get/post type incorrect)")
BLINK_ERRORS = [101, 400, 404]
+7 -2
View File
@@ -86,16 +86,21 @@ def http_req(blink, url='http://example.com', data=None, headers=None,
try: try:
response = blink.session.send(prepped, stream=stream) response = blink.session.send(prepped, stream=stream)
if json_resp and 'code' in response.json(): if json_resp and 'code' in response.json():
if is_retry: resp_dict = response.json()
code = resp_dict['code']
message = resp_dict['message']
if is_retry and code in ERROR.BLINK_ERRORS:
_LOGGER.error("Cannot obtain new token for server auth.") _LOGGER.error("Cannot obtain new token for server auth.")
return None return None
else: elif code in ERROR.BLINK_ERRORS:
headers = attempt_reauthorization(blink) headers = attempt_reauthorization(blink)
if not headers: if not headers:
raise exceptions.ConnectionError raise exceptions.ConnectionError
return http_req(blink, url=url, data=data, headers=headers, return http_req(blink, url=url, data=data, headers=headers,
reqtype=reqtype, stream=stream, reqtype=reqtype, stream=stream,
json_resp=json_resp, is_retry=True) json_resp=json_resp, is_retry=True)
_LOGGER.warning("Response from server: %s - %s", code, message)
except (exceptions.ConnectionError, exceptions.Timeout): except (exceptions.ConnectionError, exceptions.Timeout):
_LOGGER.info("Cannot connect to server with url %s.", url) _LOGGER.info("Cannot connect to server with url %s.", url)
if not is_retry: if not is_retry:
+13
View File
@@ -0,0 +1,13 @@
codecov:
branch: dev
coverage:
status:
project:
default:
threshold: 0.02
comment: true
require_ci_to_pass: yes
range: 65..90
round: down
precision: 1
+2 -2
View File
@@ -123,8 +123,8 @@ class TestBlinkSetup(unittest.TestCase):
def test_bad_request(self, mock_sess): def test_bad_request(self, mock_sess):
"""Check that we raise an Exception with a bad request.""" """Check that we raise an Exception with a bad request."""
self.blink.session = create_session() self.blink.session = create_session()
explog = ("ERROR:blinkpy.helpers.util:" explog = ("WARNING:blinkpy.helpers.util:"
"Cannot obtain new token for server auth.") "Response from server: 200 - foo")
with self.assertRaises(BlinkException): with self.assertRaises(BlinkException):
http_req(self.blink, reqtype='bad') http_req(self.blink, reqtype='bad')
+1 -1
View File
@@ -8,7 +8,7 @@ setenv =
LANG=en_US.UTF-8 LANG=en_US.UTF-8
PYTHONPATH = {toxinidir} PYTHONPATH = {toxinidir}
commands = commands =
pytest --timeout=9 --durations=10 pytest --timeout=9 --durations=10 --cov=blinkpy --cov-report term-missing {posargs}
deps = deps =
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt
-r{toxinidir}/requirements_test.txt -r{toxinidir}/requirements_test.txt