feat: basic error handling during dump process

This commit is contained in:
Swann Martinez 2019-08-22 15:35:21 +02:00
parent f864c225cd
commit 0cd291e75d
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
5 changed files with 53 additions and 48 deletions

View File

@ -19,6 +19,7 @@ def dump_image(image):
file = open(image.filepath_raw, "rb")
pixels = file.read()
else:
raise ValueError()
print("Image format not supported ")
return pixels

View File

@ -84,7 +84,7 @@ class ClientUpdate(Draw):
super().__init__()
def execute(self):
if hasattr(operators,"client"):
if hasattr(operators,"client") and self._client_uuid:
client = operators.client.get(self._client_uuid)
if client:

@ -1 +1 @@
Subproject commit e56b847a920470fd7e6b4c5ce613dab6979c5ed9
Subproject commit 1d01e9a9545d0da6e4c5eb241c945598c38b7a4c

View File

@ -107,7 +107,7 @@ class SessionStartOperator(bpy.types.Operator):
address=settings.ip,
port=settings.port
)
settings.is_admin = True
if settings.init_scene:
init_supported_datablocks(supported_bl_types)
else:

94
ui.py
View File

@ -4,15 +4,13 @@ from .libs.replication.constants import *
from .bl_types.bl_user import BlUser
ICONS = {'Image': 'IMAGE_DATA', 'Curve':'CURVE_DATA', 'Client':'SOLO_ON','Collection': 'FILE_FOLDER', 'Mesh': 'MESH_DATA', 'Object': 'OBJECT_DATA', 'Material': 'MATERIAL_DATA',
'Texture': 'TEXTURE_DATA', 'Scene': 'SCENE_DATA','AreaLight':'LIGHT_DATA', 'Light': 'LIGHT_DATA', 'SpotLight': 'LIGHT_DATA', 'SunLight': 'LIGHT_DATA', 'PointLight': 'LIGHT_DATA', 'Camera': 'CAMERA_DATA', 'Action': 'ACTION', 'Armature': 'ARMATURE_DATA', 'GreasePencil': 'GREASEPENCIL'}
PROP_STATES = [ 'KEYTYPE_BREAKDOWN_VEC',
'KEYTYPE_BREAKDOWN_VEC',
'KEYTYPE_KEYFRAME_VEC',
'KEYTYPE_KEYFRAME_VEC',
'KEYTYPE_JITTER_VEC',
'KEYTYPE_KEYFRAME_VEC']
PROP_STATES = [ 'ADDED',
'COMMITED',
'PUSHED',
'FETCHED',
'UP',
'CHANGED']
class SESSION_PT_settings(bpy.types.Panel):
"""Settings panel"""
bl_idname = "MULTIUSER_SETTINGS_PT_panel"
@ -27,6 +25,8 @@ class SESSION_PT_settings(bpy.types.Panel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
row = layout.row()
if hasattr(context.window_manager, 'session'):
settings = context.window_manager.session
@ -189,6 +189,44 @@ class SESSION_PT_user(bpy.types.Panel):
row = layout.row()
def draw_property(context,parent,property_uuid, level=0):
settings = context.window_manager.session
item = operators.client.get(property_uuid)
if item.str_type == 'BlUser' or item.state == ERROR:
return
area_msg = parent.row(align = True)
if level > 0:
for i in range(level):
area_msg.label(text="")
line = area_msg.box()
name = item.buffer['name']
detail_item_box = line.row(align = True)
if item.state == FETCHED:
detail_item_box.operator("session.apply",text="", icon=PROP_STATES[item.state]).target = item.uuid
else:
detail_item_box.label(text="", icon=PROP_STATES[item.state])
detail_item_box.label(text="",icon=item.icon)
detail_item_box.label(text="{} ".format(name))
right_icon = "DECORATE_UNLOCKED"
if item.owner == settings.username:
right_icon="DECORATE_UNLOCKED"
else:
right_icon="DECORATE_LOCKED"
ro = detail_item_box.operator("session.right", text="", icon=right_icon, emboss=settings.is_admin)
ro.key = property_uuid
detail_item_box.operator(
"session.remove_prop", text="", icon="X").property_path = property_uuid
class SESSION_PT_outliner(bpy.types.Panel):
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
bl_label = "Properties"
@ -206,6 +244,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
def draw(self, context):
layout = self.layout
if hasattr(context.window_manager,'session'):
settings = context.window_manager.session
scene = context.window_manager
@ -221,45 +260,10 @@ class SESSION_PT_outliner(bpy.types.Panel):
if client_keys and len(client_keys) > 0:
col = layout.column(align=True)
for key in client_keys:
item = operators.client.get(key)
if item.str_type == 'BlUser':
continue
area_msg = col.row(align = True)
item_box = area_msg.box()
name = "None"
#TODO: refactor that...
if hasattr(item.pointer,'name'):
name = item.pointer.name
else:
name = item.buffer['name']
detail_item_box = item_box.row()
detail_item_box.label(text="",icon=item.icon)
detail_item_box.label(text="{} ".format(name))
detail_item_box.label(text="{} ".format(item.owner))
if item.state == FETCHED:
detail_item_box.operator("session.apply", text=PROP_STATES[item.state]).target = item.uuid
else:
detail_item_box.label(text="{} ".format(PROP_STATES[item.state]))
detail_item_box.operator(
"session.remove_prop", text="", icon="X").property_path = key
right_icon = "DECORATE_UNLOCKED"
if item.owner == settings.username:
right_icon="DECORATE_UNLOCKED"
else:
right_icon="DECORATE_LOCKED"
ro = detail_item_box.operator("session.right", text="", icon=right_icon)
ro.key = key
draw_property(context,col,key)
else:
area_msg.label(text="Empty")
col.label(text="Empty")
classes = (