From 7b6eaf433a38d2a8dfe0e1648419775ec5112b80 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Fri, 26 Apr 2019 16:49:47 +0100 Subject: [PATCH] Validate required modules for AssetCreator action. --- pype/plugins/launcher/actions/AssetCreator.py | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pype/plugins/launcher/actions/AssetCreator.py b/pype/plugins/launcher/actions/AssetCreator.py index 579edebcea..9787aae002 100644 --- a/pype/plugins/launcher/actions/AssetCreator.py +++ b/pype/plugins/launcher/actions/AssetCreator.py @@ -1,9 +1,4 @@ -import os -import sys -import acre - from avalon import api, lib -from pype.tools import assetcreator from pype.api import Logger @@ -19,9 +14,23 @@ class AssetCreator(api.Action): def is_compatible(self, session): """Return whether the action is compatible with the session""" - if "AVALON_PROJECT" in session: - return True - return False + compatible = True + + # Check required modules. + module_names = [ + "ftrack_api", "ftrack_api_old", "pype.tools.assetcreator" + ] + for name in module_names: + try: + __import__(name) + except ImportError: + compatible = False + + # Check session environment. + if "AVALON_PROJECT" not in session: + compatible = False + + return compatible def process(self, session, **kwargs): asset = ''