Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19c9178db7 | ||
|
|
2ebf2db04d | ||
|
|
26de89c1b9 | ||
|
|
8f68aad238 | ||
|
|
7b586e2947 | ||
|
|
800ddeaf7a |
+2
-2
@@ -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).
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -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]
|
||||||
|
|||||||
@@ -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
@@ -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
|
||||||
@@ -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')
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user