diff --git a/colorbleed/maya/lib.py b/colorbleed/maya/lib.py index efb29ed35c..c0f24fe6f2 100644 --- a/colorbleed/maya/lib.py +++ b/colorbleed/maya/lib.py @@ -12,14 +12,14 @@ from collections import OrderedDict, defaultdict from maya import cmds, mel -from avalon import maya, io +from avalon import Session, maya, io from cb.utils.maya import core log = logging.getLogger(__name__) project = io.find_one({"type": "project", - "name": os.environ["AVALON_PROJECT"]}, + "name": Session["AVALON_PROJECT"]}, projection={"config.template.publish": True, "_id": False}) TEMPLATE = project["config"]["template"]["publish"] @@ -656,8 +656,7 @@ def generate_ids(nodes): """Assign a new id of the current active context to the nodes""" # Get the asset ID from the database for the asset of current context - asset = os.environ["AVALON_ASSET"] - asset_id = io.find_one({"type": "asset", "name": asset}, + asset_id = io.find_one({"type": "asset", "name": Session["AVALON_ASSET"]}, projection={"_id": True}) for node in nodes: @@ -700,7 +699,7 @@ def get_representation_file(representation, template=TEMPLATE): """ context = representation["context"].copy() - context["root"] = os.environ["AVALON_ROOT"] + context["root"] = Session["AVALON_ROOT"] return template.format(**context) diff --git a/colorbleed/plugins/maya/load/load_rig.py b/colorbleed/plugins/maya/load/load_rig.py index ee54de2ad6..2057086b71 100644 --- a/colorbleed/plugins/maya/load/load_rig.py +++ b/colorbleed/plugins/maya/load/load_rig.py @@ -1,8 +1,6 @@ -import os - from maya import cmds -from avalon import api, maya +from avalon import api, Session, maya class RigLoader(api.Loader): @@ -56,7 +54,7 @@ class RigLoader(api.Loader): roots = cmds.ls(self[:], assemblies=True, long=True) assert roots, "No root nodes in rig, this is a bug." - asset = os.environ["AVALON_ASSET"] + asset = Session["AVALON_ASSET"] dependency = str(context["representation"]["_id"]) # Create the animation instance diff --git a/colorbleed/plugins/maya/publish/collect_renderlayers.py b/colorbleed/plugins/maya/publish/collect_renderlayers.py index 971c9b582f..4cad5d7b3c 100644 --- a/colorbleed/plugins/maya/publish/collect_renderlayers.py +++ b/colorbleed/plugins/maya/publish/collect_renderlayers.py @@ -1,9 +1,8 @@ -import os from maya import cmds import pyblish.api -from avalon import maya, api +from avalon import Session, maya, api import colorbleed.maya.lib as lib @@ -18,7 +17,7 @@ class CollectMindbenderMayaRenderlayers(pyblish.api.ContextPlugin): def process(self, context): registered_root = api.registered_root() - asset_name = os.environ["AVALON_ASSET"] + asset_name = Session["AVALON_ASSET"] current_file = context.data["currentFile"] relative_file = current_file.replace(registered_root, "{root}") diff --git a/colorbleed/plugins/publish/collect_assumed_destination.py b/colorbleed/plugins/publish/collect_assumed_destination.py index d57039e8fb..201fef67aa 100644 --- a/colorbleed/plugins/publish/collect_assumed_destination.py +++ b/colorbleed/plugins/publish/collect_assumed_destination.py @@ -1,7 +1,7 @@ import pyblish.api import os -import avalon.io as io +from avalon import Session, io class CollectAssumedDestination(pyblish.api.InstancePlugin): @@ -64,7 +64,7 @@ class CollectAssumedDestination(pyblish.api.InstancePlugin): # get all the stuff from the database subset_name = instance.data["subset"] asset_name = instance.data["asset"] - project_name = os.environ["AVALON_PROJECT"] + project_name = Session["AVALON_PROJECT"] project = io.find_one({"type": "project", "name": project_name}, @@ -95,9 +95,9 @@ class CollectAssumedDestination(pyblish.api.InstancePlugin): if version is not None: version_number += version["name"] - template_data = {"root": os.environ["AVALON_PROJECTS"], + template_data = {"root": Session["AVALON_PROJECTS"], "project": project_name, - "silo": os.environ["AVALON_SILO"], + "silo": Session["AVALON_SILO"], "asset": asset_name, "subset": subset_name, "version": version_number, diff --git a/colorbleed/plugins/publish/integrate.py b/colorbleed/plugins/publish/integrate.py index 2c96d69556..c4b9325b6e 100644 --- a/colorbleed/plugins/publish/integrate.py +++ b/colorbleed/plugins/publish/integrate.py @@ -4,7 +4,7 @@ import shutil import errno import pyblish.api -from avalon import api, io +from avalon import Session, api, io log = logging.getLogger(__name__) @@ -47,10 +47,10 @@ class IntegrateAsset(pyblish.api.InstancePlugin): def register(self, instance): # Required environment variables - PROJECT = os.environ["AVALON_PROJECT"] - ASSET = instance.data.get("asset") or os.environ["AVALON_ASSET"] - SILO = os.environ["AVALON_SILO"] - LOCATION = os.getenv("AVALON_LOCATION") + PROJECT = Session["AVALON_PROJECT"] + ASSET = instance.data.get("asset") or Session["AVALON_ASSET"] + SILO = Session["AVALON_SILO"] + LOCATION = Session("AVALON_LOCATION") context = instance.context # Atomicity