Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2017-12-15 12:13:04 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2017-12-15 12:13:04 +0300
commit6cdbffbc229bf263fa4b9b82a6e33b591c32934c (patch)
tree205fe3ef606662c03d68e10c1cca13d411b5b258 /blender_id/communication.py
parent512687f54e26dc4cde5cf94455df3e395c23cae2 (diff)
Updated Blender ID add-on to version 1.4.1
- Improved error reporting when validating a token fails due to connection errors.
Diffstat (limited to 'blender_id/communication.py')
-rw-r--r--blender_id/communication.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/blender_id/communication.py b/blender_id/communication.py
index 90ccf9a1..5572b637 100644
--- a/blender_id/communication.py
+++ b/blender_id/communication.py
@@ -19,8 +19,11 @@
# <pep8 compliant>
import functools
+import logging
import typing
+log = logging.getLogger(__name__)
+
class BlenderIdCommError(RuntimeError):
"""Raised when there was an error communicating with Blender ID"""
@@ -84,8 +87,9 @@ def blender_id_server_authenticate(username, password) -> AuthResult:
except (requests.exceptions.SSLError,
requests.exceptions.HTTPError,
requests.exceptions.ConnectionError) as e:
- print('Exception POSTing to {}: {}'.format(url, e))
- return AuthResult(status, error_message=e)
+ msg = 'Exception POSTing to {}: {}'.format(url, e)
+ print(msg)
+ return AuthResult(success=False, error_message=msg)
if r.status_code == 200:
resp = r.json()
@@ -117,17 +121,21 @@ def blender_id_server_validate(token) -> typing.Tuple[typing.Optional[str], typi
import requests
import requests.exceptions
+ url = blender_id_endpoint('u/validate_token')
try:
- r = requests.post(blender_id_endpoint('u/validate_token'),
- data={'token': token}, verify=True)
+ r = requests.post(url, data={'token': token}, verify=True)
+ except requests.exceptions.ConnectionError:
+ log.exception('error connecting to Blender ID at %s', url)
+ return None, 'Unable to connect to Blender ID'
except requests.exceptions.RequestException as e:
- return (str(e), None)
+ log.exception('error validating token at %s', url)
+ return None, str(e)
if r.status_code != 200:
- return (None, 'Authentication token invalid')
+ return None, 'Authentication token invalid'
response = r.json()
- return (response['token_expires'], None)
+ return response['token_expires'], None
def blender_id_server_logout(user_id, token):