Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

PS, AE - send actual context when another webserver is running #1811

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from avalon import api
import pyblish.api
import openpype.api
from avalon import aftereffects


class ValidateInstanceAssetRepair(pyblish.api.Action):
"""Repair the instance asset with value from Context."""

label = "Repair"
icon = "wrench"
on = "failed"

def process(self, context, plugin):

# Get the errored instances
failed = []
for result in context.data["results"]:
if (result["error"] is not None and result["instance"] is not None
and result["instance"] not in failed):
failed.append(result["instance"])

# Apply pyblish.logic to get the instances for the plug-in
instances = pyblish.api.instances_by_plugin(failed, plugin)
stub = aftereffects.stub()
for instance in instances:
data = stub.read(instance[0])

data["asset"] = api.Session["AVALON_ASSET"]
stub.imprint(instance[0], data)


class ValidateInstanceAsset(pyblish.api.InstancePlugin):
"""Validate the instance asset is the current selected context asset.

As it might happen that multiple worfiles are opened at same time,
switching between them would mess with selected context. (From Launcher
or Ftrack).

In that case outputs might be output under wrong asset!

Repair action will use Context asset value (from Workfiles or Launcher)
Closing and reopening with Workfiles will refresh Context value.
"""

label = "Validate Instance Asset"
hosts = ["aftereffects"]
actions = [ValidateInstanceAssetRepair]
order = openpype.api.ValidateContentsOrder

def process(self, instance):
instance_asset = instance.data["asset"]
current_asset = api.Session["AVALON_ASSET"]
msg = (
f"Instance asset {instance_asset} is not the same "
f"as current context {current_asset}. PLEASE DO:\n"
f"Repair with 'A' action to use '{current_asset}'.\n"
f"If that's not correct value, close workfile and "
f"reopen via Workfiles!"
)
assert instance_asset == current_asset, msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os

from avalon import api
import pyblish.api
import openpype.api
from avalon import photoshop
Expand Down Expand Up @@ -27,12 +26,20 @@ def process(self, context, plugin):
for instance in instances:
data = stub.read(instance[0])

data["asset"] = os.environ["AVALON_ASSET"]
data["asset"] = api.Session["AVALON_ASSET"]
stub.imprint(instance[0], data)


class ValidateInstanceAsset(pyblish.api.InstancePlugin):
"""Validate the instance asset is the current asset."""
"""Validate the instance asset is the current selected context asset.

As it might happen that multiple worfiles are opened, switching
between them would mess with selected context.
In that case outputs might be output under wrong asset!

Repair action will use Context asset value (from Workfiles or Launcher)
Closing and reopening with Workfiles will refresh Context value.
"""

label = "Validate Instance Asset"
hosts = ["photoshop"]
Expand All @@ -41,9 +48,12 @@ class ValidateInstanceAsset(pyblish.api.InstancePlugin):

def process(self, instance):
instance_asset = instance.data["asset"]
current_asset = os.environ["AVALON_ASSET"]
current_asset = api.Session["AVALON_ASSET"]
msg = (
"Instance asset is not the same as current asset:"
f"\nInstance: {instance_asset}\nCurrent: {current_asset}"
f"Instance asset {instance_asset} is not the same "
f"as current context {current_asset}. PLEASE DO:\n"
f"Repair with 'A' action to use '{current_asset}'.\n"
f"If that's not correct value, close workfile and "
f"reopen via Workfiles!"
)
assert instance_asset == current_asset, msg