Skip to content
Snippets Groups Projects
Commit 7a513da9 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Show which Blender ID instance is communicated with in the addon prefs

This is only shown if it was overridden by setting the
BLENDER_ID_ENDPOINT environment variable. It makes Cloud development a
bit easier when it's explicit to which Blender ID (local dev or real
one) we're talking.
parent fa7f7ca3
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
- API change: `blender_id.get_subclient_user_id()` now returns `''` instead of `None` when the user - API change: `blender_id.get_subclient_user_id()` now returns `''` instead of `None` when the user
is not logged in. is not logged in.
- Log which Blender ID instance is communicated with. - Log which Blender ID instance is communicated with.
- Show which Blender ID instance is communicated with in the addon preferences,
if it was overridden by setting the BLENDER_ID_ENDPOINT environment variable.
# Version 1.5 (released 2018-07-03) # Version 1.5 (released 2018-07-03)
......
...@@ -239,16 +239,20 @@ class BlenderIdPreferences(AddonPreferences): ...@@ -239,16 +239,20 @@ class BlenderIdPreferences(AddonPreferences):
else: else:
exp_str = 'within seconds' exp_str = 'within seconds'
endpoint = communication.blender_id_endpoint()
if endpoint == communication.BLENDER_ID_ENDPOINT:
msg = 'You are logged in as %s.' % active_profile.username
else:
msg = 'You are logged in as %s at %s.' % (active_profile.username, endpoint)
col = layout.column(align=True)
col.label(text=msg, icon='WORLD_DATA')
if time_left.days < 14: if time_left.days < 14:
layout.label(text='You are logged in as %s.' % active_profile.username, col.label(text='Your token will expire %s. Please log out and log in again '
icon='WORLD_DATA') 'to refresh it.' % exp_str, icon='PREVIEW_RANGE')
layout.label(text='Your token will expire %s. Please log out and log in again '
'to refresh it.' % exp_str, icon='PREVIEW_RANGE')
else: else:
layout.label( col.label(text='Your authentication token expires %s.' % exp_str,
text='You are logged in as %s. Your authentication token expires %s.' icon='BLANK1')
% (active_profile.username, exp_str),
icon='WORLD_DATA')
row = layout.row().split(factor=0.8) row = layout.row().split(factor=0.8)
row.operator('blender_id.logout') row.operator('blender_id.logout')
...@@ -263,7 +267,7 @@ class BlenderIdPreferences(AddonPreferences): ...@@ -263,7 +267,7 @@ class BlenderIdPreferences(AddonPreferences):
class BlenderIdMixin: class BlenderIdMixin:
@staticmethod @staticmethod
def addon_prefs(context): def addon_prefs(context):
preferences = context.preferences.addons[__name__].preferences preferences = context.user_preferences.addons[__name__].preferences
preferences.reset_messages() preferences.reset_messages()
return preferences return preferences
...@@ -352,7 +356,7 @@ def register(): ...@@ -352,7 +356,7 @@ def register():
bpy.utils.register_class(BlenderIdPreferences) bpy.utils.register_class(BlenderIdPreferences)
bpy.utils.register_class(BlenderIdValidate) bpy.utils.register_class(BlenderIdValidate)
preferences = bpy.context.preferences.addons[__name__].preferences preferences = bpy.context.user_preferences.addons[__name__].preferences
preferences.reset_messages() preferences.reset_messages()
......
...@@ -24,6 +24,9 @@ import typing ...@@ -24,6 +24,9 @@ import typing
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# Can be overridden by setting the environment variable BLENDER_ID_ENDPOINT.
BLENDER_ID_ENDPOINT = 'https://www.blender.org/id/'
class BlenderIdCommError(RuntimeError): class BlenderIdCommError(RuntimeError):
"""Raised when there was an error communicating with Blender ID""" """Raised when there was an error communicating with Blender ID"""
...@@ -59,7 +62,7 @@ def blender_id_endpoint(endpoint_path=None): ...@@ -59,7 +62,7 @@ def blender_id_endpoint(endpoint_path=None):
if base_url: if base_url:
log.warning('Using overridden Blender ID url %s', base_url) log.warning('Using overridden Blender ID url %s', base_url)
else: else:
base_url = 'https://www.blender.org/id/' base_url = BLENDER_ID_ENDPOINT
log.info('Using standard Blender ID url %s', base_url) log.info('Using standard Blender ID url %s', base_url)
# urljoin() is None-safe for the 2nd parameter. # urljoin() is None-safe for the 2nd parameter.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment