Validate required modules for AssetCreator action.

This commit is contained in:
Toke Jepsen 2019-04-26 16:49:47 +01:00
parent f5e5e407d3
commit 7b6eaf433a

View file

@ -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 = ''