From ef4bc0e6e53dbe52872699898196a459ded17aa2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 9 Nov 2018 17:35:54 +0100 Subject: [PATCH 1/2] action DJV sets start/end frame by files in folder and fps by ftrack --- pype/ftrack/actions/djvview.py | 40 +++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/pype/ftrack/actions/djvview.py b/pype/ftrack/actions/djvview.py index 31c1812662..410fa4fde5 100644 --- a/pype/ftrack/actions/djvview.py +++ b/pype/ftrack/actions/djvview.py @@ -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 From 11f28fcfa11fdb92f4af7bcffd666d27f187ed0a Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 13 Nov 2018 17:51:57 +0100 Subject: [PATCH 2/2] Added json.dumps to sync to avalon improvement thumb to child --- pype/ftrack/actions/action_syncToAvalon.py | 5 ++++- pype/ftrack/actions/action_thumbToChildern.py | 5 +++-- pype/ftrack/actions/action_thumbToParent.py | 20 +++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/pype/ftrack/actions/action_syncToAvalon.py b/pype/ftrack/actions/action_syncToAvalon.py index 3808f5c8ff..f8c6275ada 100644 --- a/pype/ftrack/actions/action_syncToAvalon.py +++ b/pype/ftrack/actions/action_syncToAvalon.py @@ -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: diff --git a/pype/ftrack/actions/action_thumbToChildern.py b/pype/ftrack/actions/action_thumbToChildern.py index 54974c22d6..52d31ee4e5 100644 --- a/pype/ftrack/actions/action_thumbToChildern.py +++ b/pype/ftrack/actions/action_thumbToChildern.py @@ -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, diff --git a/pype/ftrack/actions/action_thumbToParent.py b/pype/ftrack/actions/action_thumbToParent.py index 82954ae0e5..ca9cd09aee 100644 --- a/pype/ftrack/actions/action_thumbToParent.py +++ b/pype/ftrack/actions/action_thumbToParent.py @@ -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!'