From a5b7597853bddeaf16bfb3c19272b17e8caa90f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 8 Mar 2016 17:56:13 +0100 Subject: [PATCH] Allow setting the Pillar server URL --- blender_cloud/__init__.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/blender_cloud/__init__.py b/blender_cloud/__init__.py index 4fab479..5298316 100644 --- a/blender_cloud/__init__.py +++ b/blender_cloud/__init__.py @@ -77,6 +77,37 @@ class BlenderCloudPreferences(AddonPreferences): sub.label(text=blender_id_text, icon=blender_id_icon) sub.label(text="* " + blender_id_help) + # options for Pillar + sub = layout.column() + sub.enabled = blender_id_icon != 'ERROR' + sub.prop(self, "pillar_server") + sub.operator("pillar.credentials_update") + + +class PillarCredentialsUpdate(Operator): + """Updates the Pillar URL and tests the new URL.""" + bl_idname = "pillar.credentials_update" + bl_label = "Update credentials" + + def execute(self, context): + active_user_id = getattr(bpy.context.window_manager, 'blender_id_active_profile', None) + if not active_user_id: + self.report({'ERROR'}, "No profile active found") + return {'CANCELLED'} + + # Test the new URL + endpoint = bpy.context.user_preferences.addons[__name__].preferences.pillar_server + pillar._pillar_api = None + try: + pillar.get_project_uuid('textures') # Just any query will do. + except Exception as e: + print(e) + self.report({'ERROR'}, 'Failed connection to %s' % endpoint) + return {'FINISHED'} + + self.report({'INFO'}, 'Updated cloud server address to %s' % endpoint) + return {'FINISHED'} + def register(): bpy.utils.register_module(__name__)