Added proper error messages for when the project needs Attract setup.
When the 'shot' node type doesn't exist, we now show an error message about this (instead of causing an IndexError).
This commit is contained in:
parent
c57da7ab2b
commit
3da76ddb24
@ -106,7 +106,25 @@ class ToolsPanel(Panel):
|
|||||||
layout.operator('attract.shots_order_update')
|
layout.operator('attract.shots_order_update')
|
||||||
|
|
||||||
|
|
||||||
class AttractShotSubmitNew(Operator):
|
class AttractOperatorMixin:
|
||||||
|
"""Mix-in class for all Attract operators."""
|
||||||
|
|
||||||
|
def _project_needs_setup_error(self):
|
||||||
|
self.report({'ERROR'}, 'Your Blender Cloud project is not set up for Attract.')
|
||||||
|
return {'CANCELLED'}
|
||||||
|
|
||||||
|
def find_node_type(self, node_type_name: str) -> 'pillarsdk.NodeType':
|
||||||
|
from .. import pillar
|
||||||
|
|
||||||
|
node_type_list = pillar.call(NodeType.all, {'where': "name=='%s'" % node_type_name})
|
||||||
|
if not node_type_list._items:
|
||||||
|
return self._project_needs_setup_error()
|
||||||
|
|
||||||
|
node_type = node_type_list._items[0]
|
||||||
|
return node_type
|
||||||
|
|
||||||
|
|
||||||
|
class AttractShotSubmitNew(AttractOperatorMixin, Operator):
|
||||||
bl_idname = "attract.shot_submit_new"
|
bl_idname = "attract.shot_submit_new"
|
||||||
bl_label = "Submit to Attract"
|
bl_label = "Submit to Attract"
|
||||||
|
|
||||||
@ -116,17 +134,17 @@ class AttractShotSubmitNew(Operator):
|
|||||||
return not strip.atc_object_id
|
return not strip.atc_object_id
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
from blender_cloud import pillar
|
from .. import pillar
|
||||||
import blender_id
|
import blender_id
|
||||||
|
|
||||||
strip = active_strip(context)
|
strip = active_strip(context)
|
||||||
if strip.atc_object_id:
|
if strip.atc_object_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Filter the NodeType collection, but it's still a list
|
node_type = self.find_node_type('shot')
|
||||||
node_type_list = pillar.call(NodeType.all, {'where': "name=='shot'"})
|
if isinstance(node_type, set): # in case of error
|
||||||
# Get the 'shot' node type
|
return node_type
|
||||||
node_type = node_type_list['_items'][0]
|
|
||||||
# Define the shot properties
|
# Define the shot properties
|
||||||
prop = {'name': strip.name,
|
prop = {'name': strip.name,
|
||||||
'description': '',
|
'description': '',
|
||||||
@ -156,7 +174,7 @@ class AttractShotSubmitNew(Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class AttractShotRelink(Operator):
|
class AttractShotRelink(AttractOperatorMixin, Operator):
|
||||||
bl_idname = "attract.shot_relink"
|
bl_idname = "attract.shot_relink"
|
||||||
bl_label = "Relink to Attract"
|
bl_label = "Relink to Attract"
|
||||||
strip_atc_object_id = bpy.props.StringProperty()
|
strip_atc_object_id = bpy.props.StringProperty()
|
||||||
@ -190,7 +208,7 @@ class AttractShotRelink(Operator):
|
|||||||
col.prop(self, 'strip_atc_object_id', text='Shot ID')
|
col.prop(self, 'strip_atc_object_id', text='Shot ID')
|
||||||
|
|
||||||
|
|
||||||
class AttractShotSubmitUpdate(Operator):
|
class AttractShotSubmitUpdate(AttractOperatorMixin, Operator):
|
||||||
bl_idname = 'attract.shot_submit_update'
|
bl_idname = 'attract.shot_submit_update'
|
||||||
bl_label = 'Update'
|
bl_label = 'Update'
|
||||||
bl_description = 'Syncronizes local and remote changes'
|
bl_description = 'Syncronizes local and remote changes'
|
||||||
@ -211,7 +229,7 @@ class AttractShotSubmitUpdate(Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class AttractShotDelete(Operator):
|
class AttractShotDelete(AttractOperatorMixin, Operator):
|
||||||
bl_idname = 'attract.shot_delete'
|
bl_idname = 'attract.shot_delete'
|
||||||
bl_label = 'Delete'
|
bl_label = 'Delete'
|
||||||
bl_description = 'Remove from Attract'
|
bl_description = 'Remove from Attract'
|
||||||
@ -224,7 +242,7 @@ class AttractShotDelete(Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class AttractStripUnlink(Operator):
|
class AttractStripUnlink(AttractOperatorMixin, Operator):
|
||||||
bl_idname = 'attract.strip_unlink'
|
bl_idname = 'attract.strip_unlink'
|
||||||
bl_label = 'Unlink'
|
bl_label = 'Unlink'
|
||||||
bl_description = 'Remove Attract props from the strip'
|
bl_description = 'Remove Attract props from the strip'
|
||||||
@ -235,7 +253,7 @@ class AttractStripUnlink(Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class AttractShotsOrderUpdate(Operator):
|
class AttractShotsOrderUpdate(AttractOperatorMixin, Operator):
|
||||||
bl_idname = 'attract.shots_order_update'
|
bl_idname = 'attract.shots_order_update'
|
||||||
bl_label = 'Update shots order'
|
bl_label = 'Update shots order'
|
||||||
|
|
||||||
@ -244,8 +262,9 @@ class AttractShotsOrderUpdate(Operator):
|
|||||||
|
|
||||||
# Get all shot nodes from server, build dictionary using ObjectID
|
# Get all shot nodes from server, build dictionary using ObjectID
|
||||||
# as indexes
|
# as indexes
|
||||||
node_type_list = pillar.call(NodeType.all, {'where': "name=='shot'"})
|
node_type = self.find_node_type('shot')
|
||||||
node_type = node_type_list._items[0]
|
if isinstance(node_type, set): # in case of error
|
||||||
|
return node_type
|
||||||
|
|
||||||
shots = pillar.call(Node.all, {
|
shots = pillar.call(Node.all, {
|
||||||
'where': {'node_type': node_type._id},
|
'where': {'node_type': node_type._id},
|
||||||
|
Reference in New Issue
Block a user