Added json.dumps to sync to avalon improvement thumb to child

This commit is contained in:
Jakub Trllo 2018-11-13 17:51:57 +01:00
parent ef4bc0e6e5
commit 11f28fcfa1
3 changed files with 21 additions and 9 deletions

View file

@ -5,6 +5,7 @@ import argparse
import logging
import os
import ftrack_api
import json
from ftrack_action_handler import BaseAction
from avalon import io, inventory, lib
@ -160,7 +161,9 @@ class SyncToAvalon(BaseAction):
job = session.create('Job', {
'user': user,
'status': 'running',
'data': {'description': 'Synch Ftrack to Avalon.'}
'data': json.dumps({
'description': 'Synch Ftrack to Avalon.'
})
})
try:

View file

@ -24,7 +24,7 @@ class ThumbToChildren(BaseAction):
def discover(self, session, entities, event):
''' Validation '''
if (len(entities) <= 0 or entities[0].entity_type in ['Project']):
if (len(entities) != 1 or entities[0].entity_type in ['Project']):
return False
return True
@ -53,11 +53,12 @@ class ThumbToChildren(BaseAction):
# inform the user that the job is done
job['status'] = 'done'
session.commit()
except:
# fail the job if something goes wrong
job['status'] = 'failed'
raise
finally:
session.commit()
return {
'success': True,

View file

@ -45,30 +45,38 @@ class ThumbToParent(BaseAction):
try:
for entity in entities:
parent = None
thumbid = None
if entity.entity_type.lower() == 'assetversion':
try:
parent = entity['task']
except:
par_ent = entity['link'][-2]
parent = session.get(par_ent['type'], par_ent['id'])
elif entity.entity_type.lower() == 'task':
parent = entity['parent']
else:
try:
parent = entity['parent']
except:
print("Durin Action 'Thumb to Parent' went something wrong")
thumbid = entity['thumbnail_id']
if parent and thumbid:
parent['thumbnail_id'] = thumbid
status = 'done'
else:
status = 'failed'
# inform the user that the job is done
job['status'] = 'done'
session.commit()
job['status'] = status or 'done'
except:
# fail the job if something goes wrong
job['status'] = 'failed'
raise
finally:
session.commit()
return {
'success': True,
'message': 'Created job for updating thumbnails!'