mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge pull request #18 from pypeclub/ftrack-action-details-iLLiCiT
Ftrack action details illicit
This commit is contained in:
commit
1e8de4aa62
4 changed files with 53 additions and 17 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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!'
|
||||
|
|
|
|||
|
|
@ -208,19 +208,43 @@ class DJVViewAction(object):
|
|||
|
||||
# Launching application
|
||||
if "values" in event["data"]:
|
||||
|
||||
filename = event['data']['values']['path']
|
||||
file_type = filename.split(".")[-1]
|
||||
|
||||
# TODO Is this proper way?
|
||||
try:
|
||||
fps = int(entities[0]['custom_attributes']['fps'])
|
||||
except:
|
||||
fps = 24
|
||||
|
||||
# TODO These should be obtained in another way
|
||||
start = 375
|
||||
end = 379
|
||||
fps = 24
|
||||
# TODO issequence is probably already built-in validation in ftrack
|
||||
isseq = re.findall('%[0-9]*d', filename)
|
||||
if len(isseq) > 0:
|
||||
padding = re.findall('%[0-9]*d', filename).pop()
|
||||
range = (padding % start) + '-' + (padding % end)
|
||||
filename = re.sub('%[0-9]*d', range, filename)
|
||||
if len(isseq) == 1:
|
||||
frames = []
|
||||
padding = re.findall('%[0-9]*d', filename).pop()
|
||||
index = filename.find(padding)
|
||||
|
||||
full_file = filename[0:index-1]
|
||||
file = full_file.split(os.sep)[-1]
|
||||
folder = os.path.dirname(full_file)
|
||||
|
||||
for fname in os.listdir(path=folder):
|
||||
if fname.endswith(file_type) and file in fname:
|
||||
frames.append(int(fname.split(".")[-2]))
|
||||
|
||||
if len(frames) > 0:
|
||||
start = min(frames)
|
||||
end = max(frames)
|
||||
|
||||
range = (padding % start) + '-' + (padding % end)
|
||||
filename = re.sub('%[0-9]*d', range, filename)
|
||||
else:
|
||||
print("")
|
||||
return {
|
||||
'success': False,
|
||||
'message': 'DJV View - Filename has more than one seqence identifier.'
|
||||
}
|
||||
|
||||
cmd = []
|
||||
# DJV path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue