From 2da8a47442ad381c6b503b71c9919ab290599f1b Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 5 Dec 2018 19:00:29 +0100 Subject: [PATCH 1/4] preparation for 'ftrack_resources' --- pype/ftrack/actions/action_Apps.py | 10 +++++++++- pype/ftrack/actions/ftrack_action_handler.py | 17 +++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/pype/ftrack/actions/action_Apps.py b/pype/ftrack/actions/action_Apps.py index 3d1bf093de..084ffa9aec 100644 --- a/pype/ftrack/actions/action_Apps.py +++ b/pype/ftrack/actions/action_Apps.py @@ -31,11 +31,19 @@ def registerApp(app, session): label = apptoml['ftrack_label'] icon = None + ftrack_resources = "" # Path to resources here + if 'icon' in apptoml: icon = apptoml['icon'] + if '{ftrack_resources}' in icon: + icon = icon.format(ftrack_resources) + + description = None + if 'description' in apptoml: + description = apptoml['description'] # register action - AppAction(session, label, name, executable, variant, icon).register() + AppAction(session, label, name, executable, variant, icon, description).register() def register(session): diff --git a/pype/ftrack/actions/ftrack_action_handler.py b/pype/ftrack/actions/ftrack_action_handler.py index 15c57dbb1c..89fa669992 100644 --- a/pype/ftrack/actions/ftrack_action_handler.py +++ b/pype/ftrack/actions/ftrack_action_handler.py @@ -14,9 +14,6 @@ import acre from pype import api as pype -log = pype.Logger.getLogger(__name__, "ftrack") - -log.debug("pype.Anatomy: {}".format(pype.Anatomy)) class AppAction(object): @@ -231,13 +228,9 @@ class AppAction(object): entity, id = entities[0] entity = session.get(entity, id) - silo = "Film" - if entity.entity_type == "AssetBuild": - silo = "Asset" - # set environments for Avalon os.environ["AVALON_PROJECT"] = entity['project']['full_name'] - os.environ["AVALON_SILO"] = silo + os.environ["AVALON_SILO"] = entity['ancestors'][0]['name'] os.environ["AVALON_ASSET"] = entity['parent']['name'] os.environ["AVALON_TASK"] = entity['name'] os.environ["AVALON_APP"] = self.identifier @@ -262,7 +255,7 @@ class AppAction(object): try: anatomy = anatomy.format(data) except Exception as e: - log.error("{0} Error in anatomy.format: {1}".format(__name__, e)) + self.log.error("{0} Error in anatomy.format: {1}".format(__name__, e)) os.environ["AVALON_WORKDIR"] = os.path.join(anatomy.work.root, anatomy.work.folder) # TODO Add paths to avalon setup from tomls @@ -328,7 +321,7 @@ class AppAction(object): try: fp = open(execfile) except PermissionError as p: - log.error('Access denied on {0} - {1}'. + self.log.error('Access denied on {0} - {1}'. format(execfile, p)) return { 'success': False, @@ -338,7 +331,7 @@ class AppAction(object): fp.close() # check executable permission if not os.access(execfile, os.X_OK): - log.error('No executable permission on {}'. + self.log.error('No executable permission on {}'. format(execfile)) return { 'success': False, @@ -347,7 +340,7 @@ class AppAction(object): } pass else: - log.error('Launcher doesn\'t exist - {}'. + self.log.error('Launcher doesn\'t exist - {}'. format(execfile)) return { 'success': False, From e19fbea3e9fb18c243a05ce034308e33eceb75ad Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Thu, 6 Dec 2018 15:20:05 +0100 Subject: [PATCH 2/4] Identifier is now full app name(with version), so same app won't launch twice if two versions are available. --- pype/ftrack/actions/action_Apps.py | 3 ++- pype/ftrack/actions/ftrack_action_handler.py | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pype/ftrack/actions/action_Apps.py b/pype/ftrack/actions/action_Apps.py index 3d1bf093de..76c6ba1e06 100644 --- a/pype/ftrack/actions/action_Apps.py +++ b/pype/ftrack/actions/action_Apps.py @@ -9,7 +9,7 @@ from app.api import Logger log = Logger.getLogger(__name__) def registerApp(app, session): - name = app['name'].split("_")[0] + name = app['name'].replace("_", ".") variant = "" try: variant = app['name'].split("_")[1] @@ -59,6 +59,7 @@ def register(session): appNames.append(app['name']) apps.append(app) + apps = sorted(apps, key=lambda x: x['name']) for app in apps: try: registerApp(app, session) diff --git a/pype/ftrack/actions/ftrack_action_handler.py b/pype/ftrack/actions/ftrack_action_handler.py index 15c57dbb1c..63561951d4 100644 --- a/pype/ftrack/actions/ftrack_action_handler.py +++ b/pype/ftrack/actions/ftrack_action_handler.py @@ -72,9 +72,7 @@ class AppAction(object): ), self._launch ) - self.log.info("Application '{}' - Registered successfully".format(self.label)) - - self.log.info("Application '{}' - Registered successfully".format(self.label)) + self.log.info("Application '{} {}' - Registered successfully".format(self.label,self.variant)) def _discover(self, event): args = self._translate_event( From 3b3a379b7a722a8438af091cbaf63e9832cd3a09 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 7 Dec 2018 01:12:34 +0100 Subject: [PATCH 3/4] fixing issue with apps not launchign at all after last merge --- pype/ftrack/actions/action_Apps.py | 3 ++- pype/ftrack/actions/ftrack_action_handler.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pype/ftrack/actions/action_Apps.py b/pype/ftrack/actions/action_Apps.py index 76c6ba1e06..23667290bd 100644 --- a/pype/ftrack/actions/action_Apps.py +++ b/pype/ftrack/actions/action_Apps.py @@ -9,7 +9,7 @@ from app.api import Logger log = Logger.getLogger(__name__) def registerApp(app, session): - name = app['name'].replace("_", ".") + name = app['name'] variant = "" try: variant = app['name'].split("_")[1] @@ -17,6 +17,7 @@ def registerApp(app, session): log.warning("'{0}' - App 'name' and 'variant' is not separated by '_' (variant is not set)".format(app['name'])) return + log.warning("app name {}".format(name)) abspath = lib.which_app(app['name']) if abspath == None: log.error("'{0}' - App don't have config toml file".format(app['name'])) diff --git a/pype/ftrack/actions/ftrack_action_handler.py b/pype/ftrack/actions/ftrack_action_handler.py index 63561951d4..fb49c40464 100644 --- a/pype/ftrack/actions/ftrack_action_handler.py +++ b/pype/ftrack/actions/ftrack_action_handler.py @@ -135,7 +135,7 @@ class AppAction(object): else: apps = [] for app in project['config']['apps']: - apps.append(app['name'].split("_")[0]) + apps.append(app['name']) if self.identifier not in apps: return False @@ -238,8 +238,8 @@ class AppAction(object): os.environ["AVALON_SILO"] = silo os.environ["AVALON_ASSET"] = entity['parent']['name'] os.environ["AVALON_TASK"] = entity['name'] - os.environ["AVALON_APP"] = self.identifier - os.environ["AVALON_APP_NAME"] = self.identifier + "_" + self.variant + os.environ["AVALON_APP"] = self.identifier.split("_")[0] + os.environ["AVALON_APP_NAME"] = self.identifier os.environ["FTRACK_TASKID"] = id @@ -280,7 +280,7 @@ class AppAction(object): parents.append(session.get(item['type'], item['id'])) # collect all the 'environment' attributes from parents - tools_attr = [os.environ["AVALON_APP_NAME"]] + tools_attr = [os.environ["AVALON_APP"], os.environ["AVALON_APP_NAME"]] for parent in reversed(parents): # check if the attribute is empty, if not use it if parent['custom_attributes']['tools_env']: From 3a38a907847f126df819da80f7e9b00ad3e23a8d Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 7 Dec 2018 09:24:07 +0100 Subject: [PATCH 4/4] ftrackRun renamed to ftrack_run --- pype/ftrack/{ftrackRun.py => ftrack_run.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pype/ftrack/{ftrackRun.py => ftrack_run.py} (100%) diff --git a/pype/ftrack/ftrackRun.py b/pype/ftrack/ftrack_run.py similarity index 100% rename from pype/ftrack/ftrackRun.py rename to pype/ftrack/ftrack_run.py